Filter by client when entering a payment
This commit is contained in:
parent
3bb348000f
commit
9a336c2e84
|
|
@ -1016,6 +1016,7 @@ void createEntity({
|
|||
bool force = false,
|
||||
Completer completer,
|
||||
Completer cancelCompleter,
|
||||
BaseEntity filterEntity,
|
||||
}) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
|
|
@ -1038,6 +1039,14 @@ void createEntity({
|
|||
store.dispatch(ToggleEditorLayout(entity.entityType));
|
||||
}
|
||||
|
||||
if (filterEntity != null) {
|
||||
if (uiState.filterEntityType != filterEntity.entityType ||
|
||||
uiState.filterEntityId != filterEntity.id) {
|
||||
store.dispatch(ClearEntitySelection(entityType: entity.entityType));
|
||||
store.dispatch(FilterByEntity(entity: filterEntity));
|
||||
}
|
||||
}
|
||||
|
||||
switch (entity.entityType) {
|
||||
case EntityType.client:
|
||||
store.dispatch(EditClient(
|
||||
|
|
|
|||
|
|
@ -462,6 +462,7 @@ Future handleCreditAction(
|
|||
final localization = AppLocalization.of(context);
|
||||
final credit = credits.first as InvoiceEntity;
|
||||
final creditIds = credits.map((credit) => credit.id).toList();
|
||||
final client = state.clientState.get(credit.clientId);
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.edit:
|
||||
|
|
@ -497,7 +498,7 @@ Future handleCreditAction(
|
|||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
editEntity(entity: state.clientState.get(credit.clientId));
|
||||
editEntity(entity: client);
|
||||
},
|
||||
child: Text(localization.editClient.toUpperCase()))
|
||||
]);
|
||||
|
|
@ -587,13 +588,12 @@ Future handleCreditAction(
|
|||
case EntityAction.applyCredit:
|
||||
createEntity(
|
||||
context: context,
|
||||
entity: PaymentEntity(
|
||||
state: state, client: state.clientState.get(credit.clientId))
|
||||
.rebuild((b) => b
|
||||
..typeId = kPaymentTypeCredit
|
||||
..credits.addAll(credits
|
||||
.map((credit) => PaymentableEntity.fromCredit(credit))
|
||||
.toList())),
|
||||
entity: PaymentEntity(state: state, client: client).rebuild((b) => b
|
||||
..typeId = kPaymentTypeCredit
|
||||
..credits.addAll(credits
|
||||
.map((credit) => PaymentableEntity.fromCredit(credit))
|
||||
.toList())),
|
||||
filterEntity: client,
|
||||
);
|
||||
break;
|
||||
case EntityAction.download:
|
||||
|
|
|
|||
|
|
@ -528,6 +528,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
final localization = AppLocalization.of(context);
|
||||
final invoice = invoices.first as InvoiceEntity;
|
||||
final invoiceIds = invoices.map((invoice) => invoice.id).toList();
|
||||
final client = state.clientState.get(invoice.clientId);
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.edit:
|
||||
|
|
@ -616,7 +617,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
editEntity(entity: state.clientState.get(invoice.clientId));
|
||||
editEntity(entity: client);
|
||||
},
|
||||
child: Text(localization.editClient.toUpperCase()))
|
||||
]);
|
||||
|
|
@ -694,13 +695,12 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
case EntityAction.newPayment:
|
||||
createEntity(
|
||||
context: context,
|
||||
entity: PaymentEntity(
|
||||
state: state, client: state.clientState.get(invoice.clientId))
|
||||
.rebuild((b) => b
|
||||
..invoices.addAll(invoices
|
||||
.where((invoice) => !(invoice as InvoiceEntity).isPaid)
|
||||
.map((invoice) => PaymentableEntity.fromInvoice(invoice))
|
||||
.toList())),
|
||||
entity: PaymentEntity(state: state, client: client).rebuild((b) => b
|
||||
..invoices.addAll(invoices
|
||||
.where((invoice) => !(invoice as InvoiceEntity).isPaid)
|
||||
.map((invoice) => PaymentableEntity.fromInvoice(invoice))
|
||||
.toList())),
|
||||
filterEntity: client,
|
||||
);
|
||||
break;
|
||||
case EntityAction.download:
|
||||
|
|
|
|||
Loading…
Reference in New Issue