Skip to content

Commit

Permalink
fix negative amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodebrute committed Oct 19, 2024
1 parent 66cf824 commit ccecd19
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6510,15 +6510,20 @@ function getReportFromHoldRequestsOnyxData(
const firstHoldTransaction = holdTransactions.at(0);
const newParentReportActionID = rand64();

const optimisticExpenseReport = ReportUtils.buildOptimisticExpenseReport(
chatReport.reportID,
chatReport.policyID ?? iouReport?.policyID ?? '',
recipient.accountID ?? 1,
holdTransactions.reduce((acc, transaction) => acc + TransactionUtils.getAmount(transaction), 0),
getCurrency(firstHoldTransaction),
false,
newParentReportActionID,
);
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport);
const holdTransactionAmount = holdTransactions.reduce((acc, transaction) => acc + TransactionUtils.getAmount(transaction), 0);
const optimisticExpenseReport = isPolicyExpenseChat
? ReportUtils.buildOptimisticExpenseReport(
chatReport.reportID,
chatReport.policyID ?? iouReport?.policyID ?? '',
recipient.accountID ?? 1,
holdTransactionAmount,
getCurrency(firstHoldTransaction),
false,
newParentReportActionID,
)
: ReportUtils.buildOptimisticIOUReport(recipient.accountID ?? 1, iouReport?.managerID ?? 1, holdTransactionAmount, chatReport.reportID, getCurrency(firstHoldTransaction), false);

const optimisticExpenseReportPreview = ReportUtils.buildOptimisticReportPreview(
chatReport,
optimisticExpenseReport,
Expand Down

0 comments on commit ccecd19

Please sign in to comment.