refactor: dynamic list to nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-01-12 18:22:48 +02:00
parent ddaea20d16
commit 270b421a6c
117 changed files with 4232 additions and 1493 deletions

View File

@@ -14,6 +14,10 @@ export default (Model) =>
return this.defaultViews.find((view) => view.slug === viewSlug) || null;
}
/**
* Retrieve the default views.
* @returns {IView[]}
*/
static getDefaultViews() {
return this.defaultViews;
}

View File

@@ -0,0 +1,31 @@
// import { IModel, ISortOrder } from "./Model";
import { ISortOrder } from "@/interfaces";
// export interface IDynamicFilter {
// setModel(model: IModel): void;
// buildQuery(): void;
// getResponseMeta();
// }
export interface IFilterRole {
fieldKey: string;
value: string;
condition?: string;
index?: number;
comparator?: string;
}
export interface IDynamicListFilter {
customViewId?: number;
filterRoles?: IFilterRole[];
columnSortBy: ISortOrder;
sortOrder: string;
stringifiedFilterRoles: string;
searchKeyword?: string;
}
// Search role.
export interface ISearchRole {
fieldKey: string;
comparator: string;
}

View File

@@ -19,14 +19,12 @@ export default class VendorCreditInventoryTransactions {
* @param {Knex.Transaction} trx
*/
public createInventoryTransactions = async (
tenantId: number,
vendorCredit: IVendorCredit,
trx: Knex.Transaction
): Promise<void> => {
// Loads the inventory items entries of the given sale invoice.
const inventoryEntries =
await this.itemsEntriesService.filterInventoryEntries(
tenantId,
vendorCredit.entries
);
@@ -43,7 +41,6 @@ export default class VendorCreditInventoryTransactions {
};
// Writes inventory tranactions.
await this.inventoryService.recordInventoryTransactionsFromItemsEntries(
tenantId,
transaction,
false,
trx
@@ -52,38 +49,33 @@ export default class VendorCreditInventoryTransactions {
/**
* Edits vendor credit associated inventory transactions.
* @param {number} tenantId
* @param {number} creditNoteId
* @param {ICreditNote} creditNote
* @param {Knex.Transactions} trx
* @param {number} vendorCreditId - Vendor credit id.
* @param {IVendorCredit} vendorCredit - Vendor credit.
* @param {Knex.Transactions} trx - Knex transaction.
*/
public editInventoryTransactions = async (
tenantId: number,
public async editInventoryTransactions(
vendorCreditId: number,
vendorCredit: IVendorCredit,
trx?: Knex.Transaction
): Promise<void> => {
): Promise<void> {
// Deletes inventory transactions.
await this.deleteInventoryTransactions(tenantId, vendorCreditId, trx);
await this.deleteInventoryTransactions(vendorCreditId, trx);
// Re-write inventory transactions.
await this.createInventoryTransactions(tenantId, vendorCredit, trx);
await this.createInventoryTransactions(vendorCredit, trx);
};
/**
* Deletes credit note associated inventory transactions.
* @param {number} tenantId - Tenant id.
* @param {number} creditNoteId - Credit note id.
* @param {Knex.Transaction} trx -
* @param {number} vendorCreditId - Vendor credit id.
* @param {Knex.Transaction} trx - Knex transaction.
*/
public deleteInventoryTransactions = async (
tenantId: number,
public async deleteInventoryTransactions(
vendorCreditId: number,
trx?: Knex.Transaction
): Promise<void> => {
): Promise<void> {
// Deletes the inventory transactions by the given reference id and type.
await this.inventoryService.deleteInventoryTransactions(
tenantId,
vendorCreditId,
'VendorCredit',
trx