Skip to content

Commit

Permalink
Fix invoice item report cost/profit when currencies are different
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Feb 14, 2024
1 parent a9252c6 commit f53aa99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/ui/reports/credit_item_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ ReportResult lineItemReport(
} else {
cost = productId == null ? 0.0 : productMap[productId]!.cost;
}
value = lineItem.netTotal(credit, precision) - cost;
value = (lineItem.netTotal(credit, precision) *
1 /
credit.exchangeRate) -
cost;
if (column == CreditItemReportFields.markup && cost != 0) {
value = '${round(value / cost * 100, 2)}%';
}
Expand Down Expand Up @@ -229,7 +232,10 @@ ReportResult lineItemReport(
value: value,
currencyId: column == CreditItemReportFields.quantity
? null
: client.currencyId));
: column == CreditItemReportFields.profit ||
column == CreditItemReportFields.cost
? userCompany.company.currencyId
: client.currencyId));
} else {
row.add(credit.getReportString(value: value));
}
Expand Down
10 changes: 8 additions & 2 deletions lib/ui/reports/quote_item_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ ReportResult lineItemReport(
} else {
cost = productId == null ? 0.0 : productMap[productId]!.cost;
}
value = lineItem.netTotal(invoice, precision) - cost;
value = (lineItem.netTotal(invoice, precision) *
1 /
invoice.exchangeRate) -
cost;
if (column == QuoteItemReportFields.markup && cost != 0) {
value = '${round(value / cost * 100, 2)}%';
}
Expand Down Expand Up @@ -225,7 +228,10 @@ ReportResult lineItemReport(
value: value,
currencyId: column == QuoteItemReportFields.quantity
? null
: client.currencyId));
: column == QuoteItemReportFields.profit ||
column == QuoteItemReportFields.cost
? userCompany.company.currencyId
: client.currencyId));
} else {
row.add(invoice.getReportString(value: value));
}
Expand Down

0 comments on commit f53aa99

Please sign in to comment.