Expense changes
This commit is contained in:
parent
27741ed1c4
commit
1fb118b076
|
|
@ -542,30 +542,42 @@ abstract class ExpenseEntity extends Object
|
||||||
@override
|
@override
|
||||||
FormatNumberType get listDisplayAmountType => FormatNumberType.money;
|
FormatNumberType get listDisplayAmountType => FormatNumberType.money;
|
||||||
|
|
||||||
double get amountWithTax {
|
double get taxAmount {
|
||||||
var total = amount;
|
var total = 0.0;
|
||||||
|
|
||||||
if (usesInclusiveTaxes) {
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taxAmount1 != 0 || taxAmount2 != 0 || taxAmount3 != 0) {
|
if (taxAmount1 != 0 || taxAmount2 != 0 || taxAmount3 != 0) {
|
||||||
total += taxAmount1 + taxAmount2 + taxAmount3;
|
total += taxAmount1 + taxAmount2 + taxAmount3;
|
||||||
} else {
|
} else {
|
||||||
if (taxRate1 != 0) {
|
if (usesInclusiveTaxes) {
|
||||||
total += amount * taxRate1 / 100;
|
if (taxRate1 != 0) {
|
||||||
}
|
total += amount - (amount / (1 + (taxRate1 / 100)));
|
||||||
if (taxRate2 != 0) {
|
}
|
||||||
total += amount * taxRate2 / 100;
|
if (taxRate2 != 0) {
|
||||||
}
|
total += amount - (amount / (1 + (taxRate2 / 100)));
|
||||||
if (taxRate3 != 0) {
|
}
|
||||||
total += amount * taxRate3 / 100;
|
if (taxRate3 != 0) {
|
||||||
|
total += amount - (amount / (1 + (taxRate3 / 100)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (taxRate1 != 0) {
|
||||||
|
total += amount * taxRate1 / 100;
|
||||||
|
}
|
||||||
|
if (taxRate2 != 0) {
|
||||||
|
total += amount * taxRate2 / 100;
|
||||||
|
}
|
||||||
|
if (taxRate3 != 0) {
|
||||||
|
total += amount * taxRate3 / 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double get netAmount => usesInclusiveTaxes ? amount - taxAmount : amount;
|
||||||
|
|
||||||
|
double get grossAmount => usesInclusiveTaxes ? amount : amount + taxAmount;
|
||||||
|
|
||||||
String get statusId {
|
String get statusId {
|
||||||
if (isInvoiced) {
|
if (isInvoiced) {
|
||||||
return kExpenseStatusInvoiced;
|
return kExpenseStatusInvoiced;
|
||||||
|
|
@ -581,7 +593,7 @@ abstract class ExpenseEntity extends Object
|
||||||
double get convertedAmount => round(amount * convertedExchangeRate, 2);
|
double get convertedAmount => round(amount * convertedExchangeRate, 2);
|
||||||
|
|
||||||
double get convertedAmountWithTax =>
|
double get convertedAmountWithTax =>
|
||||||
round(amountWithTax * convertedExchangeRate, 2);
|
round(grossAmount * convertedExchangeRate, 2);
|
||||||
|
|
||||||
bool get isInvoiced => invoiceId != null && invoiceId.isNotEmpty;
|
bool get isInvoiced => invoiceId != null && invoiceId.isNotEmpty;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -663,7 +663,7 @@ List<ChartDataGroup> chartExpenses(
|
||||||
expenseMap.forEach((int, expense) {
|
expenseMap.forEach((int, expense) {
|
||||||
final currencyId = expense.currencyId;
|
final currencyId = expense.currencyId;
|
||||||
final date = expense.date;
|
final date = expense.date;
|
||||||
double amount = expense.amountWithTax;
|
double amount = expense.grossAmount;
|
||||||
|
|
||||||
if (expense.isDeleted) {
|
if (expense.isDeleted) {
|
||||||
// skip it
|
// skip it
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ double calculateVendorBalance(String vendorId, String currencyId,
|
||||||
if (expense.vendorId == vendorId &&
|
if (expense.vendorId == vendorId &&
|
||||||
expense.isActive &&
|
expense.isActive &&
|
||||||
(currencyId == null || expense.currencyId == currencyId)) {
|
(currencyId == null || expense.currencyId == currencyId)) {
|
||||||
total += expense.amountWithTax;
|
total += expense.grossAmount;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ class _ExpenseEditState extends State<ExpenseEdit>
|
||||||
child: Text(
|
child: Text(
|
||||||
localization.expenseTotal +
|
localization.expenseTotal +
|
||||||
': ' +
|
': ' +
|
||||||
formatNumber(expense.amountWithTax, context,
|
formatNumber(expense.grossAmount, context,
|
||||||
currencyId: expense.currencyId),
|
currencyId: expense.currencyId),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: viewModel.state.prefState.enableDarkMode
|
color: viewModel.state.prefState.enableDarkMode
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ class ExpenseEditSettingsState extends State<ExpenseEditSettings> {
|
||||||
label: localization.enterTaxes,
|
label: localization.enterTaxes,
|
||||||
enabledLabel: localization.byAmount,
|
enabledLabel: localization.byAmount,
|
||||||
disabledLabel: localization.byRate,
|
disabledLabel: localization.byRate,
|
||||||
value: company.calculateExpenseTaxByAmount ?? false,
|
value: false,
|
||||||
onChanged: (value) => viewModel.onChanged(expense
|
onChanged: (value) => viewModel.onChanged(expense
|
||||||
.rebuild((b) => b..calculateExpenseTaxByAmount = value)),
|
.rebuild((b) => b..calculateExpenseTaxByAmount = value)),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class ExpenseOverview extends StatelessWidget {
|
||||||
statusLabel:
|
statusLabel:
|
||||||
localization.lookup('expense_status_${expense.statusId}'),
|
localization.lookup('expense_status_${expense.statusId}'),
|
||||||
label: localization.amount,
|
label: localization.amount,
|
||||||
value: formatNumber(expense.amountWithTax, context,
|
value: formatNumber(expense.grossAmount, context,
|
||||||
currencyId: expense.currencyId),
|
currencyId: expense.currencyId),
|
||||||
secondLabel: localization.converted,
|
secondLabel: localization.converted,
|
||||||
secondValue: formatNumber(
|
secondValue: formatNumber(
|
||||||
|
|
@ -111,7 +111,7 @@ class ExpenseOverview extends StatelessWidget {
|
||||||
statusLabel:
|
statusLabel:
|
||||||
localization.lookup('expense_status_${expense.statusId}'),
|
localization.lookup('expense_status_${expense.statusId}'),
|
||||||
label: localization.amount,
|
label: localization.amount,
|
||||||
value: formatNumber(expense.amountWithTax, context,
|
value: formatNumber(expense.grossAmount, context,
|
||||||
currencyId: expense.currencyId),
|
currencyId: expense.currencyId),
|
||||||
),
|
),
|
||||||
ListDivider(),
|
ListDivider(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue