fix: discount and adjustment fields

This commit is contained in:
Ahmed Bouhuolia
2024-12-04 12:18:20 +02:00
parent 6ab461a212
commit 7dd09e2903
5 changed files with 21 additions and 7 deletions

View File

@@ -153,7 +153,7 @@ export default class BillsController extends BaseController {
check('discount_type')
.default(DiscountType.Amount)
.isIn([DiscountType.Amount, DiscountType.Percentage]),
check('discount').optional().isDecimal().toFloat(),
check('discount').optional({ nullable: true }).isDecimal().toFloat(),
// # Adjustment
check('adjustment').optional({ nullable: true }).isNumeric().toFloat(),
@@ -204,7 +204,7 @@ export default class BillsController extends BaseController {
check('discount_type')
.default(DiscountType.Amount)
.isIn([DiscountType.Amount, DiscountType.Percentage]),
check('discount').optional().isDecimal().toFloat(),
check('discount').optional({ nullable: true }).isDecimal().toFloat(),
// # Adjustment
check('adjustment').optional({ nullable: true }).isNumeric().toFloat(),

View File

@@ -204,13 +204,13 @@ export default class SalesEstimatesController extends BaseController {
check('pdf_template_id').optional({ nullable: true }).isNumeric().toInt(),
// # Discount
check('discount').optional().isNumeric().toFloat(),
check('discount').optional({ nullable: true }).isNumeric().toFloat(),
check('discount_type')
.default(DiscountType.Amount)
.isIn([DiscountType.Amount, DiscountType.Percentage]),
// # Adjustment
check('adjustment').optional().isNumeric().toFloat(),
check('adjustment').optional({ nullable: true }).isNumeric().toFloat(),
];
}

View File

@@ -25,7 +25,7 @@ export default function EstimateDetailTableFooter() {
value={estimate.formatted_subtotal}
borderStyle={TotalLineBorderStyle.SingleDark}
/>
{estimate?.discount_amount > 0 && (
{estimate?.discount_amount_formatted && (
<TotalLine
title={
estimate.discount_percentage_formatted
@@ -36,6 +36,13 @@ export default function EstimateDetailTableFooter() {
textStyle={TotalLineTextStyle.Regular}
/>
)}
{estimate?.adjustment_formatted && (
<TotalLine
title="Adjustment"
value={estimate.adjustment_formatted}
textStyle={TotalLineTextStyle.Regular}
/>
)}
<TotalLine
title={<T id={'estimate.details.total'} />}
value={estimate.total_formatted}

View File

@@ -37,7 +37,7 @@ export function InvoiceDetailTableFooter() {
textStyle={TotalLineTextStyle.Regular}
/>
)}
{invoice?.adjustment > 0 && (
{invoice?.adjustment_formatted && (
<TotalLine
title="Adjustment"
value={invoice.adjustment_formatted}

View File

@@ -25,7 +25,7 @@ export default function VendorCreditDetailDrawerFooter() {
value={vendorCredit.formatted_subtotal}
borderStyle={TotalLineBorderStyle.SingleDark}
/>
{vendorCredit.discount_amount_formatted && (
{vendorCredit?.discount_amount_formatted && (
<TotalLine
title={
vendorCredit.discount_percentage_formatted
@@ -36,6 +36,13 @@ export default function VendorCreditDetailDrawerFooter() {
textStyle={TotalLineTextStyle.Regular}
/>
)}
{vendorCredit?.adjustment_formatted && (
<TotalLine
title={'Adjustment'}
value={vendorCredit.adjustment_formatted}
textStyle={TotalLineTextStyle.Regular}
/>
)}
<TotalLine
title={<T id={'vendor_credit.drawer.label_total'} />}
value={vendorCredit.formatted_amount}