Use company currency for purchase order
This commit is contained in:
parent
d283afeec5
commit
31963ca7aa
|
|
@ -27,9 +27,11 @@ class InvoiceItemListTile extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String cost = formatNumber(invoiceItem.cost, context,
|
||||
clientId: invoice.clientId, roundToPrecision: false);
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId,
|
||||
roundToPrecision: false);
|
||||
final String qty = formatNumber(invoiceItem.quantity, context,
|
||||
clientId: invoice.clientId, formatNumberType: FormatNumberType.double);
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId,
|
||||
formatNumberType: FormatNumberType.double);
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
|
|
@ -44,10 +46,10 @@ class InvoiceItemListTile extends StatelessWidget {
|
|||
subtitle += ' • ${localization.discount} ';
|
||||
if (invoice.isAmountDiscount) {
|
||||
subtitle += formatNumber(invoiceItem.discount, context,
|
||||
clientId: invoice.clientId);
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId);
|
||||
} else {
|
||||
subtitle += formatNumber(invoiceItem.discount, context,
|
||||
clientId: invoice.clientId,
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId,
|
||||
formatNumberType: FormatNumberType.percent);
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +117,8 @@ class InvoiceItemListTile extends StatelessWidget {
|
|||
Expanded(child: Text(invoiceItem.productKey)),
|
||||
Text(formatNumber(
|
||||
invoiceItem.total(invoice, precision), context,
|
||||
clientId: invoice.clientId)),
|
||||
clientId:
|
||||
invoice.isPurchaseOrder ? null : invoice.clientId)),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
|
|
|
|||
|
|
@ -847,7 +847,9 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
precision:
|
||||
precisionForInvoice(state, invoice)),
|
||||
context,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
),
|
||||
if (invoice.isOld &&
|
||||
(invoice.isInvoice || invoice.isQuote))
|
||||
|
|
@ -861,7 +863,9 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
'__invoice_paid_to_date_${invoice.paidToDate}_${invoice.clientId}__'),
|
||||
initialValue: formatNumber(
|
||||
invoice.paidToDate, context,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
),
|
||||
if (company.hasCustomSurcharge)
|
||||
CustomSurcharges(
|
||||
|
|
@ -941,7 +945,9 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
state, invoice)) -
|
||||
invoice.paidToDate,
|
||||
context,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
),
|
||||
if (invoice.partial != 0)
|
||||
TextFormField(
|
||||
|
|
@ -954,7 +960,9 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
'__invoice_total_${invoice.partial}_${invoice.clientId}__'),
|
||||
initialValue: formatNumber(
|
||||
invoice.partial, context,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
),
|
||||
]),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -435,7 +435,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
formatNumber(item.cost, context,
|
||||
formatNumberType:
|
||||
FormatNumberType.inputMoney,
|
||||
clientId: invoice.clientId) ??
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId) ??
|
||||
'',
|
||||
textAlign: TextAlign.right,
|
||||
);
|
||||
|
|
@ -444,7 +446,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
formatNumber(item.quantity, context,
|
||||
formatNumberType:
|
||||
FormatNumberType.inputAmount,
|
||||
clientId: invoice.clientId) ??
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId) ??
|
||||
'',
|
||||
textAlign: TextAlign.right,
|
||||
);
|
||||
|
|
@ -453,7 +457,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
formatNumber(item.discount, context,
|
||||
formatNumberType:
|
||||
FormatNumberType.inputAmount,
|
||||
clientId: invoice.clientId) ??
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId) ??
|
||||
'',
|
||||
textAlign: TextAlign.right,
|
||||
);
|
||||
|
|
@ -470,7 +476,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
Expanded(
|
||||
child: Text(
|
||||
formatNumber(item.total(invoice, precision), context,
|
||||
clientId: invoice.clientId) ??
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId) ??
|
||||
'',
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
|
|
@ -955,7 +963,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
initialValue: formatNumber(
|
||||
lineItems[index].cost, context,
|
||||
formatNumberType: FormatNumberType.inputMoney,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
onChanged: (value) => _onChanged(
|
||||
lineItems[index].rebuild(
|
||||
(b) => b..cost = parseDouble(value)),
|
||||
|
|
@ -983,7 +993,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
lineItems[index].quantity, context,
|
||||
formatNumberType:
|
||||
FormatNumberType.inputAmount,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
onChanged: (value) => _onChanged(
|
||||
lineItems[index].rebuild(
|
||||
(b) => b..quantity = parseDouble(value)),
|
||||
|
|
@ -1011,7 +1023,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
lineItems[index].discount, context,
|
||||
formatNumberType:
|
||||
FormatNumberType.inputAmount,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
onChanged: (value) => _onChanged(
|
||||
lineItems[index].rebuild(
|
||||
(b) => b..discount = parseDouble(value)),
|
||||
|
|
@ -1034,7 +1048,9 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
enabled: false,
|
||||
initialValue: formatNumber(
|
||||
lineItems[index].total(invoice, precision), context,
|
||||
clientId: invoice.clientId),
|
||||
clientId: invoice.isPurchaseOrder
|
||||
? null
|
||||
: invoice.clientId),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ class InvoiceOverview extends StatelessWidget {
|
|||
: invoice.isQuote
|
||||
? localization.quoteAmount
|
||||
: localization.invoiceAmount,
|
||||
value:
|
||||
formatNumber(invoice.amount, context, clientId: invoice.clientId),
|
||||
value: formatNumber(invoice.amount, context,
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId),
|
||||
secondLabel: invoice.isCredit
|
||||
? localization.creditRemaining
|
||||
: (invoice.isQuote || invoice.isRecurringInvoice)
|
||||
|
|
@ -112,7 +112,7 @@ class InvoiceOverview extends StatelessWidget {
|
|||
secondValue:
|
||||
[EntityType.invoice, EntityType.credit].contains(invoice.entityType)
|
||||
? formatNumber(invoice.balanceOrAmount, context,
|
||||
clientId: invoice.clientId)
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId)
|
||||
: null,
|
||||
),
|
||||
ListDivider(),
|
||||
|
|
@ -158,11 +158,12 @@ class InvoiceOverview extends StatelessWidget {
|
|||
if (invoice.isInvoice && !invoice.isPaid)
|
||||
InvoiceFields.nextSendDate: formatDate(invoice.nextSendDate, context),
|
||||
InvoiceFields.partial: formatNumber(invoice.partial, context,
|
||||
clientId: invoice.clientId, zeroIsNull: true),
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId,
|
||||
zeroIsNull: true),
|
||||
InvoiceFields.partialDueDate: formatDate(invoice.partialDueDate, context),
|
||||
InvoiceFields.poNumber: invoice.poNumber,
|
||||
InvoiceFields.discount: formatNumber(invoice.discount, context,
|
||||
clientId: invoice.clientId,
|
||||
clientId: invoice.isPurchaseOrder ? null : invoice.clientId,
|
||||
zeroIsNull: true,
|
||||
formatNumberType: invoice.isAmountDiscount
|
||||
? FormatNumberType.money
|
||||
|
|
@ -306,11 +307,12 @@ class InvoiceOverview extends StatelessWidget {
|
|||
paymentMap.entries.forEach((entry) {
|
||||
final payment = entry.value;
|
||||
final paymentable = entry.key;
|
||||
String amount =
|
||||
formatNumber(paymentable.amount, context, clientId: client.id);
|
||||
String amount = formatNumber(paymentable.amount, context,
|
||||
clientId: invoice.isPurchaseOrder ? null : client.id);
|
||||
if (paymentable.amount != payment.amount) {
|
||||
amount +=
|
||||
'/' + formatNumber(payment.amount, context, clientId: client.id);
|
||||
amount += '/' +
|
||||
formatNumber(payment.amount, context,
|
||||
clientId: invoice.isPurchaseOrder ? null : client.id);
|
||||
}
|
||||
|
||||
widgets.add(
|
||||
|
|
@ -327,11 +329,12 @@ class InvoiceOverview extends StatelessWidget {
|
|||
creditMap.entries.forEach((entry) {
|
||||
final credit = entry.value;
|
||||
final paymentable = entry.key;
|
||||
String amount =
|
||||
formatNumber(paymentable.amount, context, clientId: client.id);
|
||||
String amount = formatNumber(paymentable.amount, context,
|
||||
clientId: invoice.isPurchaseOrder ? null : client.id);
|
||||
if (paymentable.amount != credit.amount) {
|
||||
amount +=
|
||||
'/' + formatNumber(credit.amount, context, clientId: client.id);
|
||||
amount += '/' +
|
||||
formatNumber(credit.amount, context,
|
||||
clientId: invoice.isPurchaseOrder ? null : client.id);
|
||||
}
|
||||
|
||||
widgets.add(
|
||||
|
|
@ -389,7 +392,9 @@ class InvoiceOverview extends StatelessWidget {
|
|||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
formatNumber(amount, context, clientId: invoice.clientId),
|
||||
formatNumber(amount, context,
|
||||
clientId:
|
||||
invoice.isPurchaseOrder ? null : invoice.clientId),
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ class PurchaseOrderPresenter extends EntityPresenter {
|
|||
case PurchaseOrderFields.amount:
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(formatNumber(purchaseOrder.amount, context,
|
||||
clientId: purchaseOrder.clientId)),
|
||||
child: Text(formatNumber(purchaseOrder.amount, context)),
|
||||
);
|
||||
case PurchaseOrderFields.dueDate:
|
||||
return Text(formatDate(purchaseOrder.dueDate, context));
|
||||
|
|
@ -105,8 +104,7 @@ class PurchaseOrderPresenter extends EntityPresenter {
|
|||
case PurchaseOrderFields.discount:
|
||||
return Text(purchaseOrder.isAmountDiscount
|
||||
? formatNumber(purchaseOrder.discount, context,
|
||||
formatNumberType: FormatNumberType.money,
|
||||
clientId: purchaseOrder.clientId)
|
||||
formatNumberType: FormatNumberType.money)
|
||||
: formatNumber(purchaseOrder.discount, context,
|
||||
formatNumberType: FormatNumberType.percent));
|
||||
case PurchaseOrderFields.poNumber:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Package imports:
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja_flutter/redux/reports/reports_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:memoize/memoize.dart';
|
||||
|
||||
// Project imports:
|
||||
|
|
@ -15,7 +14,7 @@ import 'package:invoiceninja_flutter/utils/enums.dart';
|
|||
enum PurchaseOrderReportFields {
|
||||
id,
|
||||
amount,
|
||||
converted_amount,
|
||||
//converted_amount,
|
||||
vendor,
|
||||
vendor_number,
|
||||
//vendor_balance,
|
||||
|
|
@ -158,10 +157,12 @@ ReportResult purchaseOrderReport(
|
|||
case PurchaseOrderReportFields.amount:
|
||||
value = purchaseOrder.amount;
|
||||
break;
|
||||
/*
|
||||
case PurchaseOrderReportFields.converted_amount:
|
||||
value =
|
||||
round(purchaseOrder.amount * 1 / purchaseOrder.exchangeRate, 2);
|
||||
break;
|
||||
*/
|
||||
case PurchaseOrderReportFields.number:
|
||||
value = purchaseOrder.number;
|
||||
break;
|
||||
|
|
@ -300,8 +301,9 @@ ReportResult purchaseOrderReport(
|
|||
value = vendor.city;
|
||||
break;
|
||||
case PurchaseOrderReportFields.currency:
|
||||
value =
|
||||
staticState.currencyMap[vendor.currencyId]?.listDisplayName ?? '';
|
||||
value = staticState.currencyMap[userCompany.company.currencyId]
|
||||
?.listDisplayName ??
|
||||
'';
|
||||
break;
|
||||
case PurchaseOrderReportFields.is_viewed:
|
||||
value = purchaseOrder.isViewed;
|
||||
|
|
@ -367,15 +369,17 @@ ReportResult purchaseOrderReport(
|
|||
if (value.runtimeType == bool) {
|
||||
row.add(purchaseOrder.getReportBool(value: value));
|
||||
} else if (value.runtimeType == double || value.runtimeType == int) {
|
||||
/*
|
||||
String currencyId = vendor.currencyId;
|
||||
if ([
|
||||
PurchaseOrderReportFields.converted_amount,
|
||||
].contains(column)) {
|
||||
currencyId = userCompany.company.currencyId;
|
||||
}
|
||||
*/
|
||||
row.add(purchaseOrder.getReportDouble(
|
||||
value: value,
|
||||
currencyId: currencyId,
|
||||
currencyId: userCompany.company.currencyId,
|
||||
exchangeRate: purchaseOrder.exchangeRate,
|
||||
));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue