Skip to content

Commit

Permalink
Merge pull request Expensify#30820 from Expensify/georgia-nonReimburs…
Browse files Browse the repository at this point in the history
…ableTotal-fix

Fix Out of Pocket Spend / Company Spend Totals calculation in NewDot
  • Loading branch information
luacmartins authored Nov 3, 2023
2 parents 69227b4 + c975ed9 commit 7b546b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,15 +1492,18 @@ function getMoneyRequestSpendBreakdown(report, allReportsDict = null) {
}
if (moneyRequestReport) {
let nonReimbursableSpend = lodashGet(moneyRequestReport, 'nonReimbursableTotal', 0);
let reimbursableSpend = lodashGet(moneyRequestReport, 'total', 0);
let totalSpend = lodashGet(moneyRequestReport, 'total', 0);

if (nonReimbursableSpend + reimbursableSpend !== 0) {
if (nonReimbursableSpend + totalSpend !== 0) {
// There is a possibility that if the Expense report has a negative total.
// This is because there are instances where you can get a credit back on your card,
// or you enter a negative expense to “offset” future expenses
nonReimbursableSpend = isExpenseReport(moneyRequestReport) ? nonReimbursableSpend * -1 : Math.abs(nonReimbursableSpend);
reimbursableSpend = isExpenseReport(moneyRequestReport) ? reimbursableSpend * -1 : Math.abs(reimbursableSpend);
const totalDisplaySpend = nonReimbursableSpend + reimbursableSpend;
totalSpend = isExpenseReport(moneyRequestReport) ? totalSpend * -1 : Math.abs(totalSpend);

const totalDisplaySpend = totalSpend;
const reimbursableSpend = totalDisplaySpend - nonReimbursableSpend;

return {
nonReimbursableSpend,
reimbursableSpend,
Expand Down

0 comments on commit 7b546b0

Please sign in to comment.