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