mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: add paid amount attr and formatting to SaleReceipt transformer
This commit is contained in:
@@ -55,6 +55,9 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
|||||||
'discountAmount',
|
'discountAmount',
|
||||||
'discountPercentage',
|
'discountPercentage',
|
||||||
|
|
||||||
|
'paid',
|
||||||
|
'paidLocal',
|
||||||
|
|
||||||
'isClosed',
|
'isClosed',
|
||||||
'isDraft',
|
'isDraft',
|
||||||
];
|
];
|
||||||
@@ -130,6 +133,22 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
|||||||
return this.adjustment * this.exchangeRate;
|
return this.adjustment * this.exchangeRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receipt paid amount.
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
get paid() {
|
||||||
|
return this.total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receipt paid amount in local currency.
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
get paidLocal() {
|
||||||
|
return this.paid * this.exchangeRate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detarmine whether the sale receipt closed.
|
* Detarmine whether the sale receipt closed.
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export class SaleReceiptTransformer extends Transformer {
|
|||||||
'formattedReceiptDate',
|
'formattedReceiptDate',
|
||||||
'formattedClosedAtDate',
|
'formattedClosedAtDate',
|
||||||
'formattedCreatedAt',
|
'formattedCreatedAt',
|
||||||
|
'paidFormatted',
|
||||||
'entries',
|
'entries',
|
||||||
'attachments',
|
'attachments',
|
||||||
];
|
];
|
||||||
@@ -130,6 +131,18 @@ export class SaleReceiptTransformer extends Transformer {
|
|||||||
return receipt.discountPercentage ? `${receipt.discountPercentage}%` : '';
|
return receipt.discountPercentage ? `${receipt.discountPercentage}%` : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves formatted paid amount.
|
||||||
|
* @param receipt
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
protected paidFormatted = (receipt: ISaleReceipt): string => {
|
||||||
|
return formatNumber(receipt.paid, {
|
||||||
|
currencyCode: receipt.currencyCode,
|
||||||
|
excerptZero: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves formatted adjustment amount.
|
* Retrieves formatted adjustment amount.
|
||||||
* @param receipt
|
* @param receipt
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ import styled from 'styled-components';
|
|||||||
import { defaultTo } from 'lodash';
|
import { defaultTo } from 'lodash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ButtonLink,
|
|
||||||
CustomerDrawerLink,
|
CustomerDrawerLink,
|
||||||
CommercialDocHeader,
|
CommercialDocHeader,
|
||||||
CommercialDocTopHeader,
|
CommercialDocTopHeader,
|
||||||
ExchangeRateDetailItem,
|
ExchangeRateDetailItem,
|
||||||
Row,
|
Row,
|
||||||
Col,
|
Col,
|
||||||
FormatDate,
|
|
||||||
DetailsMenu,
|
DetailsMenu,
|
||||||
DetailItem,
|
DetailItem,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
@@ -66,6 +64,7 @@ export default function ReceiptDetailHeader() {
|
|||||||
/>
|
/>
|
||||||
</DetailsMenu>
|
</DetailsMenu>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col xs={6}>
|
<Col xs={6}>
|
||||||
<DetailsMenu
|
<DetailsMenu
|
||||||
direction={'horizantal'}
|
direction={'horizantal'}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
TotalLine,
|
TotalLine,
|
||||||
TotalLineBorderStyle,
|
TotalLineBorderStyle,
|
||||||
TotalLineTextStyle,
|
TotalLineTextStyle,
|
||||||
FormatNumber,
|
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useReceiptDetailDrawerContext } from './ReceiptDetailDrawerProvider';
|
import { useReceiptDetailDrawerContext } from './ReceiptDetailDrawerProvider';
|
||||||
|
|
||||||
@@ -51,8 +50,8 @@ export default function ReceiptDetailTableFooter() {
|
|||||||
/>
|
/>
|
||||||
<TotalLine
|
<TotalLine
|
||||||
title={<T id={'receipt.details.payment_amount'} />}
|
title={<T id={'receipt.details.payment_amount'} />}
|
||||||
value={receipt.formatted_amount}
|
value={receipt.paid_formatted}
|
||||||
borderStyle={TotalLineBorderStyle.DoubleDark}
|
borderStyle={TotalLineBorderStyle.SingleDark}
|
||||||
/>
|
/>
|
||||||
<TotalLine
|
<TotalLine
|
||||||
title={<T id={'receipt.details.due_amount'} />}
|
title={<T id={'receipt.details.due_amount'} />}
|
||||||
|
|||||||
Reference in New Issue
Block a user