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