Expense changes

This commit is contained in:
Hillel Coren 2021-01-11 21:12:00 +02:00
parent 1fb118b076
commit d02313a89d
4 changed files with 19 additions and 7 deletions

View File

@ -56,7 +56,9 @@ class ExpenseFields {
static const String currencyId = 'currency_id'; static const String currencyId = 'currency_id';
static const String categoryId = 'category_id'; static const String categoryId = 'category_id';
static const String category = 'category'; static const String category = 'category';
static const String netAmount = 'net_amount';
static const String amount = 'amount'; static const String amount = 'amount';
static const String taxAmount = 'tax_amount';
static const String expenseDate = 'date'; static const String expenseDate = 'date';
static const String paymentDate = 'payment_date'; static const String paymentDate = 'payment_date';
static const String exchangeRate = 'exchange_rate'; static const String exchangeRate = 'exchange_rate';
@ -317,6 +319,9 @@ abstract class ExpenseEntity extends Object
final ExpenseEntity expenseB = sortAscending ? expense : this; final ExpenseEntity expenseB = sortAscending ? expense : this;
switch (sortField) { switch (sortField) {
case ExpenseFields.netAmount:
response = expenseA.netAmount.compareTo(expenseB.netAmount);
break;
case ExpenseFields.amount: case ExpenseFields.amount:
response = expenseA.amount.compareTo(expenseB.amount); response = expenseA.amount.compareTo(expenseB.amount);
break; break;
@ -590,7 +595,7 @@ abstract class ExpenseEntity extends Object
double get convertedExchangeRate => exchangeRate == 0 ? 1 : exchangeRate; double get convertedExchangeRate => exchangeRate == 0 ? 1 : exchangeRate;
double get convertedAmount => round(amount * convertedExchangeRate, 2); double get convertedAmount => round(grossAmount * convertedExchangeRate, 2);
double get convertedAmountWithTax => double get convertedAmountWithTax =>
round(grossAmount * convertedExchangeRate, 2); round(grossAmount * convertedExchangeRate, 2);

View File

@ -83,10 +83,10 @@ class EntityPresenter {
'tax_amount', 'tax_amount',
'tax_paid', 'tax_paid',
'payment_amount', 'payment_amount',
'net_amount',
'net_balance', 'net_balance',
'rate', 'rate',
'calculated_rate', 'calculated_rate',
'duration', 'duration',
'net_amount',
].contains(field); ].contains(field);
} }

View File

@ -24,6 +24,8 @@ class ExpensePresenter extends EntityPresenter {
...getDefaultTableFields(userCompany), ...getDefaultTableFields(userCompany),
...EntityPresenter.getBaseFields(), ...EntityPresenter.getBaseFields(),
ExpenseFields.number, ExpenseFields.number,
ExpenseFields.netAmount,
ExpenseFields.taxAmount,
ExpenseFields.privateNotes, ExpenseFields.privateNotes,
ExpenseFields.shouldBeInvoiced, ExpenseFields.shouldBeInvoiced,
ExpenseFields.transactionId, ExpenseFields.transactionId,
@ -71,8 +73,15 @@ class ExpensePresenter extends EntityPresenter {
.listDisplayName); .listDisplayName);
case ExpenseFields.expenseDate: case ExpenseFields.expenseDate:
return Text(formatDate(expense.paymentDate, context)); return Text(formatDate(expense.paymentDate, context));
case ExpenseFields.netAmount:
return Text(formatNumber(expense.netAmount, context,
currencyId: expense.currencyId));
case ExpenseFields.amount: case ExpenseFields.amount:
return Text(formatNumber(expense.amount, context)); return Text(formatNumber(expense.amount, context,
currencyId: expense.currencyId));
case ExpenseFields.taxAmount:
return Text(formatNumber(expense.taxAmount, context,
currencyId: expense.currencyId));
case ExpenseFields.publicNotes: case ExpenseFields.publicNotes:
return Text(expense.publicNotes); return Text(expense.publicNotes);
case ExpenseFields.number: case ExpenseFields.number:

View File

@ -51250,8 +51250,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get searchTaskStatus => String get searchTaskStatus =>
_localizedValues[localeCode]['search_task_status']; _localizedValues[localeCode]['search_task_status'];
String get expenseTotal => String get expenseTotal => _localizedValues[localeCode]['expense_total'];
_localizedValues[localeCode]['expense_total'];
String get expenseCategory => String get expenseCategory =>
_localizedValues[localeCode]['expense_category']; _localizedValues[localeCode]['expense_category'];
@ -52434,8 +52433,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get projectNumber => String get projectNumber =>
_localizedValues[localeCode]['project_number'] ?? ''; _localizedValues[localeCode]['project_number'] ?? '';
String get projectName => String get projectName => _localizedValues[localeCode]['project_name'] ?? '';
_localizedValues[localeCode]['project_name'] ?? '';
String get taskNumber => _localizedValues[localeCode]['task_number'] ?? ''; String get taskNumber => _localizedValues[localeCode]['task_number'] ?? '';