fix: Add the missing columns to the payment received and made models

This commit is contained in:
Ahmed Bouhuolia
2024-09-01 15:00:51 +02:00
parent 7c07d6b5ff
commit 7f5ffb8da1
9 changed files with 79 additions and 3 deletions

View File

@@ -74,6 +74,7 @@ export interface IPaymentReceivedEntryDTO {
export interface IPaymentsReceivedFilter extends IDynamicListFilterDTO { export interface IPaymentsReceivedFilter extends IDynamicListFilterDTO {
stringifiedFilterRoles?: string; stringifiedFilterRoles?: string;
filterQuery?: (trx: Knex.Transaction) => void;
} }
export interface IPaymentReceivePageEntry { export interface IPaymentReceivePageEntry {

View File

@@ -5,6 +5,8 @@ export default {
sortField: 'bill_date', sortField: 'bill_date',
}, },
exportable: true, exportable: true,
exportFlattenOn: 'entries',
importable: true, importable: true,
importAggregator: 'group', importAggregator: 'group',
importAggregateOn: 'entries', importAggregateOn: 'entries',
@@ -77,7 +79,7 @@ export default {
paymentDate: { paymentDate: {
name: 'bill_payment.field.payment_date', name: 'bill_payment.field.payment_date',
type: 'date', type: 'date',
accessor: 'formattedPaymentDate' accessor: 'formattedPaymentDate',
}, },
paymentNumber: { paymentNumber: {
name: 'bill_payment.field.payment_number', name: 'bill_payment.field.payment_number',
@@ -111,6 +113,34 @@ export default {
name: 'bill_payment.field.reference', name: 'bill_payment.field.reference',
type: 'text', type: 'text',
}, },
entries: {
name: 'Entries',
accessor: 'entries',
type: 'collection',
collectionOf: 'object',
columns: {
date: {
name: 'Bill date',
accessor: 'bill.formattedBillDate',
},
billNo: {
name: 'Bill No.',
accessor: 'bill.billNo',
},
billRefNo: {
name: 'Bill Reference No.',
accessor: 'bill.referenceNo',
},
billAmount: {
name: 'Bill Amount',
accessor: 'bill.totalFormatted',
},
paidAmount: {
name: 'Paid Amount',
accessor: 'paymentAmountFormatted',
},
},
},
}, },
fields2: { fields2: {
vendorId: { vendorId: {

View File

@@ -1,6 +1,9 @@
export default { export default {
importable: true, importable: true,
exportable: true, exportable: true,
exportFlattenOn: 'entries',
importAggregator: 'group', importAggregator: 'group',
importAggregateOn: 'entries', importAggregateOn: 'entries',
importAggregateBy: 'paymentReceiveNo', importAggregateBy: 'paymentReceiveNo',
@@ -72,7 +75,7 @@ export default {
amount: { amount: {
name: 'payment_receive.field.amount', name: 'payment_receive.field.amount',
type: 'number', type: 'number',
accessor: 'formattedAmount' accessor: 'formattedAmount',
}, },
referenceNo: { referenceNo: {
name: 'payment_receive.field.reference_no', name: 'payment_receive.field.reference_no',
@@ -92,6 +95,34 @@ export default {
type: 'text', type: 'text',
printable: false, printable: false,
}, },
entries: {
name: 'Entries',
accessor: 'entries',
type: 'collection',
collectionOf: 'object',
columns: {
date: {
name: 'Invoice date',
accessor: 'invoice.invoiceDateFormatted',
},
invoiceNo: {
name: 'Invoice No.',
accessor: 'invoice.invoiceNo',
},
invoiceRefNo: {
name: 'Invoice Reference No.',
accessor: 'invoice.referenceNo',
},
invoiceAmount: {
name: 'Invoice Amount',
accessor: 'invoice.totalFormatted',
},
paidAmount: {
name: 'Paid Amount',
accessor: 'paymentAmountFormatted',
},
},
},
created_at: { created_at: {
name: 'payment_receive.field.created_at', name: 'payment_receive.field.created_at',
type: 'date', type: 'date',

View File

@@ -13,7 +13,7 @@ export default {
importAggregateBy: 'estimateNumber', importAggregateBy: 'estimateNumber',
print: { print: {
pageTitle: 'Sale Estimates' pageTitle: 'Sale Estimates',
}, },
fields: { fields: {
@@ -142,6 +142,7 @@ export default {
delivered: { delivered: {
name: 'Delivered', name: 'Delivered',
type: 'boolean', type: 'boolean',
accessor: 'isDelivered',
exportable: true, exportable: true,
printable: false, printable: false,
}, },

View File

@@ -155,6 +155,7 @@ export default {
name: 'invoice.field.delivered', name: 'invoice.field.delivered',
type: 'boolean', type: 'boolean',
printable: false, printable: false,
accessor: 'isDelivered',
}, },
entries: { entries: {
name: 'Entries', name: 'Entries',

View File

@@ -14,12 +14,16 @@ export class BillPaymentExportable extends Exportable {
* @returns * @returns
*/ */
public exportable(tenantId: number, query: any) { public exportable(tenantId: number, query: any) {
const filterQuery = (builder) => {
builder.withGraphFetched('entries.bill');
};
const parsedQuery = { const parsedQuery = {
sortOrder: 'desc', sortOrder: 'desc',
columnSortBy: 'created_at', columnSortBy: 'created_at',
...query, ...query,
page: 1, page: 1,
pageSize: EXPORT_SIZE_LIMIT, pageSize: EXPORT_SIZE_LIMIT,
filterQuery
} as any; } as any;
return this.billPaymentsApplication return this.billPaymentsApplication

View File

@@ -52,6 +52,7 @@ export class GetBillPayments {
builder.withGraphFetched('paymentAccount'); builder.withGraphFetched('paymentAccount');
dynamicList.buildQuery()(builder); dynamicList.buildQuery()(builder);
filter?.filterQuery && filter?.filterQuery(builder);
}) })
.pagination(filter.page - 1, filter.pageSize); .pagination(filter.page - 1, filter.pageSize);

View File

@@ -50,7 +50,9 @@ export class GetPaymentReceives {
.onBuild((builder) => { .onBuild((builder) => {
builder.withGraphFetched('customer'); builder.withGraphFetched('customer');
builder.withGraphFetched('depositAccount'); builder.withGraphFetched('depositAccount');
dynamicList.buildQuery()(builder); dynamicList.buildQuery()(builder);
filterDTO?.filterQuery && filterDTO.filterQuery(builder);
}) })
.pagination(filter.page - 1, filter.pageSize); .pagination(filter.page - 1, filter.pageSize);

View File

@@ -16,6 +16,10 @@ export class PaymentsReceivedExportable extends Exportable {
* @returns * @returns
*/ */
public exportable(tenantId: number, query: IPaymentsReceivedFilter) { public exportable(tenantId: number, query: IPaymentsReceivedFilter) {
const filterQuery = (builder) => {
builder.withGraphFetched('entries.invoice');
};
const parsedQuery = { const parsedQuery = {
sortOrder: 'desc', sortOrder: 'desc',
columnSortBy: 'created_at', columnSortBy: 'created_at',
@@ -24,6 +28,7 @@ export class PaymentsReceivedExportable extends Exportable {
structure: IAccountsStructureType.Flat, structure: IAccountsStructureType.Flat,
page: 1, page: 1,
pageSize: EXPORT_SIZE_LIMIT, pageSize: EXPORT_SIZE_LIMIT,
filterQuery,
} as IPaymentsReceivedFilter; } as IPaymentsReceivedFilter;
return this.paymentReceivedApp return this.paymentReceivedApp