mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix(server): add formatted values to responses transformers
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Transformer } from '@/lib/Transformer/Transformer';
|
||||
import { formatNumber } from '@/utils';
|
||||
|
||||
export class BillPaymentEntryTransformer extends Transformer {
|
||||
/**
|
||||
* Include these attributes to bill payment object.
|
||||
* @returns {Array}
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return ['paymentAmountFormatted'];
|
||||
};
|
||||
|
||||
/**
|
||||
* Retreives the payment amount formatted.
|
||||
* @returns {string}
|
||||
*/
|
||||
protected paymentAmountFormatted(entry) {
|
||||
return formatNumber(entry.paymentAmount, { money: false });
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IBillPayment } from '@/interfaces';
|
||||
import { Transformer } from '@/lib/Transformer/Transformer';
|
||||
import { formatNumber } from 'utils';
|
||||
import { BillPaymentEntryTransformer } from './BillPaymentEntryTransformer';
|
||||
|
||||
export class BillPaymentTransformer extends Transformer {
|
||||
/**
|
||||
@@ -8,7 +9,7 @@ export class BillPaymentTransformer extends Transformer {
|
||||
* @returns {Array}
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return ['formattedPaymentDate', 'formattedAmount'];
|
||||
return ['formattedPaymentDate', 'formattedAmount', 'entries'];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -30,4 +31,11 @@ export class BillPaymentTransformer extends Transformer {
|
||||
currencyCode: billPayment.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retreives the bill payment entries.
|
||||
*/
|
||||
protected entries = (billPayment) => {
|
||||
return this.item(billPayment.entries, new BillPaymentEntryTransformer());
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user