Skip to content

Commit

Permalink
fix: display adjustment in minues
Browse files Browse the repository at this point in the history
  • Loading branch information
abouolia committed Dec 8, 2024
1 parent 46719ef commit 11d7a40
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/server/src/models/Bill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class Bill extends mixin(TenantModel, [

return R.compose(
R.add(adjustmentAmount),
R.subtract(this.discountAmount),
R.subtract(R.__, this.discountAmount),
R.when(R.always(this.isInclusiveTax), R.add(this.taxAmountWithheld))
)(this.subtotal);
}
Expand Down
11 changes: 11 additions & 0 deletions packages/server/src/models/SaleReceipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export default class SaleReceipt extends mixin(TenantModel, [
'total',
'totalLocal',

'adjustment',
'adjustmentLocal',

'discountAmount',
'discountPercentage',

Expand Down Expand Up @@ -119,6 +122,14 @@ export default class SaleReceipt extends mixin(TenantModel, [
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.
* @return {boolean}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class VendorCreditTransformer extends Transformer {
'discountAmountFormatted',
'discountPercentageFormatted',
'adjustmentFormatted',
'totalFormatted',
'entries',
'attachments',
];
Expand Down Expand Up @@ -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.
* @param {IVendorCredit} vendorCredit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function BillDetailTableFooter() {
textStyle={TotalLineTextStyle.Regular}
/>
)}
{bill.adjustment > 0 && (
{bill.adjustment_formatted && (
<TotalLine
title={'Adjustment'}
value={bill.adjustment_formatted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function CreditNoteDetailTableFooter() {
value={creditNote.discount_amount_formatted}
/>
)}
{creditNote.adjustment > 0 && (
{creditNote.adjustment_formatted && (
<TotalLine
title={'Adjustment'}
value={creditNote.adjustment_formatted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function ReceiptDetailTableFooter() {
textStyle={TotalLineTextStyle.Regular}
/>
)}
{receipt.adjustment > 0 && (
{receipt.adjustment_formatted && (
<TotalLine
title={'Adjustment'}
value={receipt.adjustment_formatted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function VendorCreditDetailDrawerFooter() {
)}
<TotalLine
title={<T id={'vendor_credit.drawer.label_total'} />}
value={vendorCredit.formatted_amount}
value={vendorCredit.total_formatted}
borderStyle={TotalLineBorderStyle.DoubleDark}
textStyle={TotalLineTextStyle.Bold}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import styled from 'styled-components';
import { defaultTo } from 'lodash';

import {
FormatDate,
T,
Row,
Col,
Expand All @@ -29,13 +28,14 @@ export default function VendorCreditDetailHeader() {
<CommercialDocTopHeader>
<DetailsMenu>
<AmountItem label={intl.get('amount')}>
<span class="big-number">{vendorCredit.formatted_amount}</span>
<span class="big-number">{vendorCredit.total_formatted}</span>
</AmountItem>
<StatusItem>
<VendorCreditDetailsStatus vendorCredit={vendorCredit} />
</StatusItem>
</DetailsMenu>
</CommercialDocTopHeader>

<Row>
<Col xs={6}>
<DetailsMenu direction={'horizantal'} minLabelSize={'180px'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export const useInvoiceTotal = () => {
return R.compose(
R.when(R.always(isExclusiveTax), R.add(totalTaxAmount)),
R.subtract(R.__, discountAmount),
R.add(R.__, adjustmentAmount),
R.add(adjustmentAmount),
)(subtotal);
};

Expand Down

0 comments on commit 11d7a40

Please sign in to comment.