Working on reversing invoices
This commit is contained in:
parent
0e03178b06
commit
a9560b27f1
|
|
@ -961,11 +961,9 @@ abstract class InvoiceEntity extends Object
|
||||||
actions.add(EntityAction.cancel);
|
actions.add(EntityAction.cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (userCompany.canCreate(EntityType.credit)) {
|
if (userCompany.canCreate(EntityType.credit)) {
|
||||||
actions.add(EntityAction.reverse);
|
actions.add(EntityAction.reverse);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -304,25 +304,6 @@ class MarkInvoicesPaidFailure implements StopSaving {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReverseInvoicesRequest implements StartSaving {
|
|
||||||
ReverseInvoicesRequest(this.completer, this.invoiceIds);
|
|
||||||
|
|
||||||
final Completer completer;
|
|
||||||
final List<String> invoiceIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ReverseInvoicesSuccess implements StopSaving {
|
|
||||||
ReverseInvoicesSuccess(this.invoices);
|
|
||||||
|
|
||||||
final List<InvoiceEntity> invoices;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ReverseInvoicesFailure implements StopSaving {
|
|
||||||
ReverseInvoicesFailure(this.error);
|
|
||||||
|
|
||||||
final Object error;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CancelInvoicesRequest implements StartSaving {
|
class CancelInvoicesRequest implements StartSaving {
|
||||||
CancelInvoicesRequest(this.completer, this.invoiceIds);
|
CancelInvoicesRequest(this.completer, this.invoiceIds);
|
||||||
|
|
||||||
|
|
@ -549,13 +530,6 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
||||||
invoiceIds));
|
invoiceIds));
|
||||||
break;
|
break;
|
||||||
case EntityAction.reverse:
|
case EntityAction.reverse:
|
||||||
store.dispatch(ReverseInvoicesRequest(
|
|
||||||
snackBarCompleter<Null>(
|
|
||||||
context,
|
|
||||||
invoiceIds.length == 1
|
|
||||||
? localization.reversedInvoice
|
|
||||||
: localization.reversedInvoices),
|
|
||||||
invoiceIds));
|
|
||||||
break;
|
break;
|
||||||
case EntityAction.cancel:
|
case EntityAction.cancel:
|
||||||
store.dispatch(CancelInvoicesRequest(
|
store.dispatch(CancelInvoicesRequest(
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
|
||||||
final bulkEmailInvoices = _bulkEmailInvoices(repository);
|
final bulkEmailInvoices = _bulkEmailInvoices(repository);
|
||||||
final markInvoiceSent = _markInvoiceSent(repository);
|
final markInvoiceSent = _markInvoiceSent(repository);
|
||||||
final markInvoicePaid = _markInvoicePaid(repository);
|
final markInvoicePaid = _markInvoicePaid(repository);
|
||||||
final reverseInvoices = _reverseInvoices(repository);
|
|
||||||
final cancelInvoices = _cancelInvoices(repository);
|
final cancelInvoices = _cancelInvoices(repository);
|
||||||
final downloadInvoices = _downloadInvoices(repository);
|
final downloadInvoices = _downloadInvoices(repository);
|
||||||
final saveDocument = _saveDocument(repository);
|
final saveDocument = _saveDocument(repository);
|
||||||
|
|
@ -59,7 +58,6 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
|
||||||
TypedMiddleware<AppState, BulkEmailInvoicesRequest>(bulkEmailInvoices),
|
TypedMiddleware<AppState, BulkEmailInvoicesRequest>(bulkEmailInvoices),
|
||||||
TypedMiddleware<AppState, MarkInvoicesSentRequest>(markInvoiceSent),
|
TypedMiddleware<AppState, MarkInvoicesSentRequest>(markInvoiceSent),
|
||||||
TypedMiddleware<AppState, MarkInvoicesPaidRequest>(markInvoicePaid),
|
TypedMiddleware<AppState, MarkInvoicesPaidRequest>(markInvoicePaid),
|
||||||
TypedMiddleware<AppState, ReverseInvoicesRequest>(reverseInvoices),
|
|
||||||
TypedMiddleware<AppState, CancelInvoicesRequest>(cancelInvoices),
|
TypedMiddleware<AppState, CancelInvoicesRequest>(cancelInvoices),
|
||||||
TypedMiddleware<AppState, DownloadInvoicesRequest>(downloadInvoices),
|
TypedMiddleware<AppState, DownloadInvoicesRequest>(downloadInvoices),
|
||||||
TypedMiddleware<AppState, SaveInvoiceDocumentRequest>(saveDocument),
|
TypedMiddleware<AppState, SaveInvoiceDocumentRequest>(saveDocument),
|
||||||
|
|
@ -173,30 +171,6 @@ Middleware<AppState> _cancelInvoices(InvoiceRepository repository) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Middleware<AppState> _reverseInvoices(InvoiceRepository repository) {
|
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
|
||||||
final action = dynamicAction as ReverseInvoicesRequest;
|
|
||||||
repository
|
|
||||||
.bulkAction(
|
|
||||||
store.state.credentials, action.invoiceIds, EntityAction.reverse)
|
|
||||||
.then((List<InvoiceEntity> invoices) {
|
|
||||||
store.dispatch(ReverseInvoicesSuccess(invoices));
|
|
||||||
store.dispatch(RefreshData());
|
|
||||||
if (action.completer != null) {
|
|
||||||
action.completer.complete(null);
|
|
||||||
}
|
|
||||||
}).catchError((Object error) {
|
|
||||||
print(error);
|
|
||||||
store.dispatch(ReverseInvoicesFailure(error));
|
|
||||||
if (action.completer != null) {
|
|
||||||
action.completer.completeError(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
next(action);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as ArchiveInvoicesRequest;
|
final action = dynamicAction as ArchiveInvoicesRequest;
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,6 @@ final invoicesReducer = combineReducers<InvoiceState>([
|
||||||
TypedReducer<InvoiceState, LoadInvoiceSuccess>(_updateInvoice),
|
TypedReducer<InvoiceState, LoadInvoiceSuccess>(_updateInvoice),
|
||||||
TypedReducer<InvoiceState, MarkInvoicesSentSuccess>(_markInvoicesSentSuccess),
|
TypedReducer<InvoiceState, MarkInvoicesSentSuccess>(_markInvoicesSentSuccess),
|
||||||
TypedReducer<InvoiceState, MarkInvoicesPaidSuccess>(_markInvoicesPaidSuccess),
|
TypedReducer<InvoiceState, MarkInvoicesPaidSuccess>(_markInvoicesPaidSuccess),
|
||||||
TypedReducer<InvoiceState, ReverseInvoicesSuccess>(_reverseInvoicesSuccess),
|
|
||||||
TypedReducer<InvoiceState, CancelInvoicesSuccess>(_cancelInvoicesSuccess),
|
TypedReducer<InvoiceState, CancelInvoicesSuccess>(_cancelInvoicesSuccess),
|
||||||
TypedReducer<InvoiceState, EmailInvoiceSuccess>(_emailInvoiceSuccess),
|
TypedReducer<InvoiceState, EmailInvoiceSuccess>(_emailInvoiceSuccess),
|
||||||
TypedReducer<InvoiceState, ArchiveInvoicesSuccess>(_archiveInvoiceSuccess),
|
TypedReducer<InvoiceState, ArchiveInvoicesSuccess>(_archiveInvoiceSuccess),
|
||||||
|
|
@ -338,15 +337,6 @@ InvoiceState _markInvoicesPaidSuccess(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceState _reverseInvoicesSuccess(
|
|
||||||
InvoiceState invoiceState, ReverseInvoicesSuccess action) {
|
|
||||||
return invoiceState.rebuild((b) {
|
|
||||||
for (final invoice in action.invoices) {
|
|
||||||
b.map[invoice.id] = invoice;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
InvoiceState _cancelInvoicesSuccess(
|
InvoiceState _cancelInvoicesSuccess(
|
||||||
InvoiceState invoiceState, CancelInvoicesSuccess action) {
|
InvoiceState invoiceState, CancelInvoicesSuccess action) {
|
||||||
return invoiceState.rebuild((b) {
|
return invoiceState.rebuild((b) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
//#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
||||||
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
//auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||||
|
|
||||||
#include <flutter/dart_project.h>
|
#include <flutter/dart_project.h>
|
||||||
#include <flutter/flutter_view_controller.h>
|
#include <flutter/flutter_view_controller.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue