Transaction table/reports

This commit is contained in:
Hillel Coren 2022-12-05 15:33:00 +02:00
parent 59d2124d52
commit 0e03cce3b6
4 changed files with 14 additions and 1 deletions

View File

@ -54,6 +54,7 @@ class TransactionFields {
static const String currency = 'currency'; static const String currency = 'currency';
static const String vendor = 'vendor'; static const String vendor = 'vendor';
static const String category = 'category'; static const String category = 'category';
static const String payment = 'payment';
static const String bankAccountId = 'bank_account_id'; static const String bankAccountId = 'bank_account_id';
static const String bankAccount = 'bank_account'; static const String bankAccount = 'bank_account';
static const String invoiceIds = 'invoice_ids'; static const String invoiceIds = 'invoice_ids';

View File

@ -359,6 +359,7 @@ class ReportsScreenVM {
state.expenseCategoryState.map, state.expenseCategoryState.map,
state.invoiceState.map, state.invoiceState.map,
state.bankAccountState.map, state.bankAccountState.map,
state.paymentState.map,
state.staticState, state.staticState,
); );
} }

View File

@ -21,6 +21,7 @@ enum TransactionReportFields {
withdrawal, withdrawal,
vendor, vendor,
category, category,
payment,
bankAccount, bankAccount,
invoices, invoices,
expenseNumber, expenseNumber,
@ -31,7 +32,7 @@ enum TransactionReportFields {
updated_at, updated_at,
} }
var memoizedTransactionReport = memo9(( var memoizedTransactionReport = memo10((
UserCompanyEntity userCompany, UserCompanyEntity userCompany,
ReportsUIState reportsUIState, ReportsUIState reportsUIState,
BuiltMap<String, TransactionEntity> transactionMap, BuiltMap<String, TransactionEntity> transactionMap,
@ -40,6 +41,7 @@ var memoizedTransactionReport = memo9((
BuiltMap<String, ExpenseCategoryEntity> categoryMap, BuiltMap<String, ExpenseCategoryEntity> categoryMap,
BuiltMap<String, InvoiceEntity> invoiceMap, BuiltMap<String, InvoiceEntity> invoiceMap,
BuiltMap<String, BankAccountEntity> bankAccountMap, BuiltMap<String, BankAccountEntity> bankAccountMap,
BuiltMap<String, PaymentEntity> paymentMap,
StaticState staticState, StaticState staticState,
) => ) =>
transactionReport( transactionReport(
@ -51,6 +53,7 @@ var memoizedTransactionReport = memo9((
categoryMap, categoryMap,
invoiceMap, invoiceMap,
bankAccountMap, bankAccountMap,
paymentMap,
staticState, staticState,
)); ));
@ -63,6 +66,7 @@ ReportResult transactionReport(
BuiltMap<String, ExpenseCategoryEntity> categoryMap, BuiltMap<String, ExpenseCategoryEntity> categoryMap,
BuiltMap<String, InvoiceEntity> invoiceMap, BuiltMap<String, InvoiceEntity> invoiceMap,
BuiltMap<String, BankAccountEntity> bankAccountMap, BuiltMap<String, BankAccountEntity> bankAccountMap,
BuiltMap<String, PaymentEntity> paymentMap,
StaticState staticState, StaticState staticState,
) { ) {
final List<List<ReportElement>> data = []; final List<List<ReportElement>> data = [];
@ -142,6 +146,9 @@ ReportResult transactionReport(
case TransactionReportFields.bankAccount: case TransactionReportFields.bankAccount:
value = bankAccountMap[transaction.bankAccountId]?.name ?? ''; value = bankAccountMap[transaction.bankAccountId]?.name ?? '';
break; break;
case TransactionReportFields.payment:
value = paymentMap[transaction.paymentId]?.number ?? '';
break;
case TransactionReportFields.defaultCategory: case TransactionReportFields.defaultCategory:
value = transaction.category; value = transaction.category;
break; break;

View File

@ -32,6 +32,7 @@ class TransactionPresenter extends EntityPresenter {
TransactionFields.amount, TransactionFields.amount,
TransactionFields.vendor, TransactionFields.vendor,
TransactionFields.category, TransactionFields.category,
TransactionFields.payment,
TransactionFields.defaultCategory, TransactionFields.defaultCategory,
]; ];
} }
@ -83,6 +84,9 @@ class TransactionPresenter extends EntityPresenter {
state.bankAccountState.get(transaction.bankAccountId); state.bankAccountState.get(transaction.bankAccountId);
return LinkTextRelatedEntity( return LinkTextRelatedEntity(
entity: bankAccount, relation: transaction); entity: bankAccount, relation: transaction);
case TransactionFields.payment:
final payment = state.paymentState.get(transaction.paymentId);
return LinkTextRelatedEntity(entity: payment, relation: transaction);
case TransactionFields.invoices: case TransactionFields.invoices:
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints(maxWidth: kTableColumnWidthMax), constraints: BoxConstraints(maxWidth: kTableColumnWidthMax),