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 3942cb8 commit a9252c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/ui/reports/invoice_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(invoice, precision) - cost;
value = (lineItem.netTotal(invoice, precision) *
1 /
invoice.exchangeRate) -
cost;
if (column == InvoiceItemReportFields.markup && cost != 0) {
value = '${round(value / cost * 100, 2)}%';
}
Expand Down Expand Up @@ -229,7 +232,10 @@ ReportResult lineItemReport(
value: value,
currencyId: column == InvoiceItemReportFields.quantity
? null
: client.currencyId));
: column == InvoiceItemReportFields.profit ||
column == InvoiceItemReportFields.cost
? userCompany.company.currencyId
: client.currencyId));
} else {
row.add(invoice.getReportString(value: value));
}
Expand Down

0 comments on commit a9252c6

Please sign in to comment.