Browse Source

Adjust last bulk milestone payment to be the remaining amount to divide

tags/Baseline_180220205_Frontend
Wayne 8 months ago
parent
commit
236f144657
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/components/CreateProject/BulkAddPaymentModal.tsx

+ 5
- 1
src/components/CreateProject/BulkAddPaymentModal.tsx View File

@@ -96,6 +96,9 @@ const BulkAddPaymentModal: React.FC<Props> = ({
description description
) { ) {
const dividedAmount = truncateMoney(amountToDivide / numberOfEntries)!; const dividedAmount = truncateMoney(amountToDivide / numberOfEntries)!;
const amountForLastItem = truncateMoney(
amountToDivide - dividedAmount * (numberOfEntries - 1),
)!;
return Array(numberOfEntries) return Array(numberOfEntries)
.fill(undefined) .fill(undefined)
.map((_, index) => { .map((_, index) => {
@@ -109,7 +112,8 @@ const BulkAddPaymentModal: React.FC<Props> = ({


return { return {
id: getID(), id: getID(),
amount: dividedAmount,
amount:
index === numberOfEntries - 1 ? amountForLastItem : dividedAmount,
description: replaceTemplateString(description, { description: replaceTemplateString(description, {
"{index}": (index + 1).toString(), "{index}": (index + 1).toString(),
"{date}": date.format(OUTPUT_DATE_FORMAT), "{date}": date.format(OUTPUT_DATE_FORMAT),


Loading…
Cancel
Save