fix: display adjustment in minues

This commit is contained in:
Ahmed Bouhuolia
2024-12-08 14:47:03 +02:00
parent 46719ef361
commit 11d7a40326
9 changed files with 29 additions and 8 deletions

View File

@@ -136,7 +136,7 @@ export default class Bill extends mixin(TenantModel, [
return R.compose( return R.compose(
R.add(adjustmentAmount), R.add(adjustmentAmount),
R.subtract(this.discountAmount), R.subtract(R.__, this.discountAmount),
R.when(R.always(this.isInclusiveTax), R.add(this.taxAmountWithheld)) R.when(R.always(this.isInclusiveTax), R.add(this.taxAmountWithheld))
)(this.subtotal); )(this.subtotal);
} }

View File

@@ -49,6 +49,9 @@ export default class SaleReceipt extends mixin(TenantModel, [
'total', 'total',
'totalLocal', 'totalLocal',
'adjustment',
'adjustmentLocal',
'discountAmount', 'discountAmount',
'discountPercentage', 'discountPercentage',
@@ -119,6 +122,14 @@ export default class SaleReceipt extends mixin(TenantModel, [
return this.total * this.exchangeRate; return this.total * this.exchangeRate;
} }
/**
* Adjustment amount in local currency.
* @returns {number}
*/
get adjustmentLocal() {
return this.adjustment * this.exchangeRate;
}
/** /**
* Detarmine whether the sale receipt closed. * Detarmine whether the sale receipt closed.
* @return {boolean} * @return {boolean}

View File

@@ -20,6 +20,7 @@ export class VendorCreditTransformer extends Transformer {
'discountAmountFormatted', 'discountAmountFormatted',
'discountPercentageFormatted', 'discountPercentageFormatted',
'adjustmentFormatted', 'adjustmentFormatted',
'totalFormatted',
'entries', 'entries',
'attachments', 'attachments',
]; ];
@@ -118,6 +119,15 @@ export class VendorCreditTransformer extends Transformer {
}); });
}; };
/**
* Retrieves the formatted total.
* @param {IVendorCredit} credit
* @returns {string}
*/
protected totalFormatted = (credit) => {
return formatNumber(credit.total, { currencyCode: credit.currencyCode });
};
/** /**
* Retrieves the entries of the bill. * Retrieves the entries of the bill.
* @param {IVendorCredit} vendorCredit * @param {IVendorCredit} vendorCredit

View File

@@ -42,7 +42,7 @@ export function BillDetailTableFooter() {
textStyle={TotalLineTextStyle.Regular} textStyle={TotalLineTextStyle.Regular}
/> />
)} )}
{bill.adjustment > 0 && ( {bill.adjustment_formatted && (
<TotalLine <TotalLine
title={'Adjustment'} title={'Adjustment'}
value={bill.adjustment_formatted} value={bill.adjustment_formatted}

View File

@@ -33,7 +33,7 @@ export default function CreditNoteDetailTableFooter() {
value={creditNote.discount_amount_formatted} value={creditNote.discount_amount_formatted}
/> />
)} )}
{creditNote.adjustment > 0 && ( {creditNote.adjustment_formatted && (
<TotalLine <TotalLine
title={'Adjustment'} title={'Adjustment'}
value={creditNote.adjustment_formatted} value={creditNote.adjustment_formatted}

View File

@@ -36,7 +36,7 @@ export default function ReceiptDetailTableFooter() {
textStyle={TotalLineTextStyle.Regular} textStyle={TotalLineTextStyle.Regular}
/> />
)} )}
{receipt.adjustment > 0 && ( {receipt.adjustment_formatted && (
<TotalLine <TotalLine
title={'Adjustment'} title={'Adjustment'}
value={receipt.adjustment_formatted} value={receipt.adjustment_formatted}

View File

@@ -45,7 +45,7 @@ export default function VendorCreditDetailDrawerFooter() {
)} )}
<TotalLine <TotalLine
title={<T id={'vendor_credit.drawer.label_total'} />} title={<T id={'vendor_credit.drawer.label_total'} />}
value={vendorCredit.formatted_amount} value={vendorCredit.total_formatted}
borderStyle={TotalLineBorderStyle.DoubleDark} borderStyle={TotalLineBorderStyle.DoubleDark}
textStyle={TotalLineTextStyle.Bold} textStyle={TotalLineTextStyle.Bold}
/> />

View File

@@ -5,7 +5,6 @@ import styled from 'styled-components';
import { defaultTo } from 'lodash'; import { defaultTo } from 'lodash';
import { import {
FormatDate,
T, T,
Row, Row,
Col, Col,
@@ -29,13 +28,14 @@ export default function VendorCreditDetailHeader() {
<CommercialDocTopHeader> <CommercialDocTopHeader>
<DetailsMenu> <DetailsMenu>
<AmountItem label={intl.get('amount')}> <AmountItem label={intl.get('amount')}>
<span class="big-number">{vendorCredit.formatted_amount}</span> <span class="big-number">{vendorCredit.total_formatted}</span>
</AmountItem> </AmountItem>
<StatusItem> <StatusItem>
<VendorCreditDetailsStatus vendorCredit={vendorCredit} /> <VendorCreditDetailsStatus vendorCredit={vendorCredit} />
</StatusItem> </StatusItem>
</DetailsMenu> </DetailsMenu>
</CommercialDocTopHeader> </CommercialDocTopHeader>
<Row> <Row>
<Col xs={6}> <Col xs={6}>
<DetailsMenu direction={'horizantal'} minLabelSize={'180px'}> <DetailsMenu direction={'horizantal'} minLabelSize={'180px'}>

View File

@@ -455,7 +455,7 @@ export const useInvoiceTotal = () => {
return R.compose( return R.compose(
R.when(R.always(isExclusiveTax), R.add(totalTaxAmount)), R.when(R.always(isExclusiveTax), R.add(totalTaxAmount)),
R.subtract(R.__, discountAmount), R.subtract(R.__, discountAmount),
R.add(R.__, adjustmentAmount), R.add(adjustmentAmount),
)(subtotal); )(subtotal);
}; };