Bank transactions
This commit is contained in:
parent
9619d2adb6
commit
ec28887740
|
|
@ -49,10 +49,14 @@ class TransactionFields {
|
||||||
static const String date = 'date';
|
static const String date = 'date';
|
||||||
static const String amount = 'amount';
|
static const String amount = 'amount';
|
||||||
static const String currencyId = 'currency_id';
|
static const String currencyId = 'currency_id';
|
||||||
|
static const String currency = 'currency';
|
||||||
static const String category = 'category';
|
static const String category = 'category';
|
||||||
static const String bankAccountId = 'bank_account_id';
|
static const String bankAccountId = 'bank_account_id';
|
||||||
|
static const String bankAccount = 'bank_account';
|
||||||
static const String invoiceId = 'invoice_id';
|
static const String invoiceId = 'invoice_id';
|
||||||
|
static const String invoice = 'invoice';
|
||||||
static const String expenseId = 'expense_id';
|
static const String expenseId = 'expense_id';
|
||||||
|
static const String expense = 'expense';
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class TransactionEntity extends Object
|
abstract class TransactionEntity extends Object
|
||||||
|
|
@ -195,13 +199,13 @@ abstract class TransactionEntity extends Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get listDisplayName => null;
|
String get listDisplayName => description;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double get listDisplayAmount => null;
|
double get listDisplayAmount => amount;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FormatNumberType get listDisplayAmountType => null;
|
FormatNumberType get listDisplayAmountType => FormatNumberType.money;
|
||||||
|
|
||||||
// ignore: unused_element
|
// ignore: unused_element
|
||||||
static void _initializeBuilder(TransactionEntityBuilder builder) => builder
|
static void _initializeBuilder(TransactionEntityBuilder builder) => builder
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,64 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/link_text.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/strings.dart';
|
||||||
|
|
||||||
class TransactionPresenter extends EntityPresenter {
|
class TransactionPresenter extends EntityPresenter {
|
||||||
static List<String> getDefaultTableFields(UserCompanyEntity userCompany) {
|
static List<String> getDefaultTableFields(UserCompanyEntity userCompany) {
|
||||||
return [];
|
return [
|
||||||
|
TransactionFields.date,
|
||||||
|
TransactionFields.amount,
|
||||||
|
TransactionFields.category,
|
||||||
|
TransactionFields.description,
|
||||||
|
TransactionFields.bankAccount,
|
||||||
|
TransactionFields.invoice,
|
||||||
|
TransactionFields.expense,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<String> getAllTableFields(UserCompanyEntity userCompany) {
|
static List<String> getAllTableFields(UserCompanyEntity userCompany) {
|
||||||
return [
|
return [
|
||||||
...getDefaultTableFields(userCompany),
|
...getDefaultTableFields(userCompany),
|
||||||
...EntityPresenter.getBaseFields(),
|
...EntityPresenter.getBaseFields(),
|
||||||
|
TransactionFields.currency,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget getField({String field, BuildContext context}) {
|
Widget getField({String field, BuildContext context}) {
|
||||||
//final state = StoreProvider.of<AppState>(context).state;
|
final state = StoreProvider.of<AppState>(context).state;
|
||||||
//final transaction = entity as InvoiceEntity;
|
final transaction = entity as TransactionEntity;
|
||||||
|
|
||||||
switch (field) {
|
switch (field) {
|
||||||
|
case TransactionFields.date:
|
||||||
|
return Text(formatDate(transaction.date, context));
|
||||||
|
case TransactionFields.amount:
|
||||||
|
return Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Text(formatNumber(transaction.amount, context,
|
||||||
|
currencyId: transaction.currencyId)),
|
||||||
|
);
|
||||||
|
case TransactionFields.category:
|
||||||
|
return Text(toTitleCase(transaction.category.toLowerCase()));
|
||||||
|
case TransactionFields.description:
|
||||||
|
return Text(transaction.description);
|
||||||
|
case TransactionFields.bankAccount:
|
||||||
|
final bankAccount =
|
||||||
|
state.bankAccountState.get(transaction.bankAccountId);
|
||||||
|
return LinkTextRelatedEntity(
|
||||||
|
entity: bankAccount, relation: transaction);
|
||||||
|
case TransactionFields.invoice:
|
||||||
|
final invoice = state.invoiceState.get(transaction.invoiceId);
|
||||||
|
return LinkTextRelatedEntity(entity: invoice, relation: transaction);
|
||||||
|
case TransactionFields.expense:
|
||||||
|
final expense = state.expenseState.get(transaction.expenseId);
|
||||||
|
return LinkTextRelatedEntity(entity: expense, relation: transaction);
|
||||||
|
case TransactionFields.currency:
|
||||||
|
return Text(state.bankAccountState.get(transaction.bankAccountId).name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getField(field: field, context: context);
|
return super.getField(field: field, context: context);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ String toTitleCase(String text) {
|
||||||
return 'URL';
|
return 'URL';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (word.length <= 1) {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
final first = word.substring(0, 1).toUpperCase();
|
final first = word.substring(0, 1).toUpperCase();
|
||||||
final rest = word.substring(1);
|
final rest = word.substring(1);
|
||||||
return '$first$rest';
|
return '$first$rest';
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class StubPresenter extends EntityPresenter {
|
||||||
@override
|
@override
|
||||||
Widget getField({String field, BuildContext context}) {
|
Widget getField({String field, BuildContext context}) {
|
||||||
//final state = StoreProvider.of<AppState>(context).state;
|
//final state = StoreProvider.of<AppState>(context).state;
|
||||||
//final stub = entity as InvoiceEntity;
|
//final stub = entity as StubEntity;
|
||||||
|
|
||||||
switch (field) {
|
switch (field) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue