Cancel/reverse invoices
This commit is contained in:
parent
6d1c7d2996
commit
fea3fd231a
|
|
@ -463,7 +463,7 @@ abstract class ActivityEntity
|
|||
EntityType get entityType {
|
||||
if (['1', '2', '3', '26'].contains(activityTypeId)) {
|
||||
return EntityType.client;
|
||||
} else if (['4', '5', '6', '7', '8', '9', '25', '53']
|
||||
} else if (['4', '5', '6', '7', '8', '9', '25', '53', '58', '59']
|
||||
.contains(activityTypeId)) {
|
||||
return EntityType.invoice;
|
||||
} else if (['10', '11', '12', '13', '27'].contains(activityTypeId)) {
|
||||
|
|
|
|||
|
|
@ -518,6 +518,11 @@ abstract class InvoiceEntity extends Object
|
|||
actions.add(EntityAction.markPaid);
|
||||
}
|
||||
|
||||
if (!isQuote && !isCredit && isSent) {
|
||||
actions.add(EntityAction.cancel);
|
||||
actions.add(EntityAction.reverse);
|
||||
}
|
||||
|
||||
if (isQuote && !isApproved) {
|
||||
actions.add(EntityAction.convert);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ class EntityAction extends EnumClass {
|
|||
static const EntityAction resume = _$resume;
|
||||
static const EntityAction stop = _$stop;
|
||||
static const EntityAction toggleMultiselect = _$toggleMultiselect;
|
||||
static const EntityAction reverse = _$reverse;
|
||||
static const EntityAction cancel = _$cancel;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ const EntityAction _$resume = const EntityAction._('resume');
|
|||
const EntityAction _$stop = const EntityAction._('stop');
|
||||
const EntityAction _$toggleMultiselect =
|
||||
const EntityAction._('toggleMultiselect');
|
||||
const EntityAction _$reverse = const EntityAction._('reverse');
|
||||
const EntityAction _$cancel = const EntityAction._('cancel');
|
||||
|
||||
EntityAction _$valueOf(String name) {
|
||||
switch (name) {
|
||||
|
|
@ -112,6 +114,10 @@ EntityAction _$valueOf(String name) {
|
|||
return _$stop;
|
||||
case 'toggleMultiselect':
|
||||
return _$toggleMultiselect;
|
||||
case 'reverse':
|
||||
return _$reverse;
|
||||
case 'cancel':
|
||||
return _$cancel;
|
||||
default:
|
||||
throw new ArgumentError(name);
|
||||
}
|
||||
|
|
@ -153,6 +159,8 @@ final BuiltSet<EntityAction> _$values =
|
|||
_$resume,
|
||||
_$stop,
|
||||
_$toggleMultiselect,
|
||||
_$reverse,
|
||||
_$cancel,
|
||||
]);
|
||||
|
||||
Serializer<EntityAction> _$entityActionSerializer =
|
||||
|
|
|
|||
|
|
@ -252,6 +252,44 @@ class MarkInvoicesPaidFailure implements StopSaving {
|
|||
final dynamic error;
|
||||
}
|
||||
|
||||
class ReverseInvoicesRequest implements StartSaving {
|
||||
ReverseInvoicesRequest(this.completer, this.invoiceIds);
|
||||
|
||||
final Completer completer;
|
||||
final List<String> invoiceIds;
|
||||
}
|
||||
|
||||
class ReverseInvoicesSuccess implements StopSaving, PersistData {
|
||||
ReverseInvoicesSuccess(this.invoices);
|
||||
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class ReverseInvoicesFailure implements StopSaving {
|
||||
ReverseInvoicesFailure(this.invoices);
|
||||
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class CancelInvoicesRequest implements StartSaving {
|
||||
CancelInvoicesRequest(this.completer, this.invoiceIds);
|
||||
|
||||
final Completer completer;
|
||||
final List<String> invoiceIds;
|
||||
}
|
||||
|
||||
class CancelInvoicesSuccess implements StopSaving, PersistData {
|
||||
CancelInvoicesSuccess(this.invoices);
|
||||
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class CancelInvoicesFailure implements StopSaving {
|
||||
CancelInvoicesFailure(this.invoices);
|
||||
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class ArchiveInvoicesRequest implements StartSaving {
|
||||
ArchiveInvoicesRequest(this.completer, this.invoiceIds);
|
||||
|
||||
|
|
@ -404,6 +442,24 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
: localization.markedInvoicesAsSent),
|
||||
invoiceIds));
|
||||
break;
|
||||
case EntityAction.reverse:
|
||||
store.dispatch(ReverseInvoicesRequest(
|
||||
snackBarCompleter<Null>(
|
||||
context,
|
||||
invoiceIds.length == 1
|
||||
? localization.reversedInvoice
|
||||
: localization.reversedInvoices),
|
||||
invoiceIds));
|
||||
break;
|
||||
case EntityAction.cancel:
|
||||
store.dispatch(CancelInvoicesRequest(
|
||||
snackBarCompleter<Null>(
|
||||
context,
|
||||
invoiceIds.length == 1
|
||||
? localization.cancelledInvoice
|
||||
: localization.cancelledInvoices),
|
||||
invoiceIds));
|
||||
break;
|
||||
case EntityAction.markPaid:
|
||||
store.dispatch(MarkInvoicesPaidRequest(
|
||||
snackBarCompleter<Null>(
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'cancelled_invoice': 'Successfully cancelled invoice',
|
||||
'cancelled_invoices': 'Successfully cancelled invoices',
|
||||
'reversed_invoice': 'Successfully reversed invoice',
|
||||
'reversed_invoices': 'Successfully reversed invoices',
|
||||
'reverse': 'Reverse',
|
||||
'full_name': 'Full Name',
|
||||
'city_state_postal': 'City/State/Postal',
|
||||
'postal_city_state': 'Postal/City/State',
|
||||
|
|
@ -1015,6 +1020,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
'activity_55': '',
|
||||
'activity_56': '',
|
||||
'activity_57': 'System failed to email invoice :invoice',
|
||||
'activity_58': ':user reversed invoice :invoice',
|
||||
'activity_59': ':user cancelled invoice :invoice',
|
||||
'one_time_password': 'One Time Password',
|
||||
'emailed_quote': 'Successfully emailed quote',
|
||||
'emailed_credit': 'Successfully emailed credit',
|
||||
|
|
@ -34650,6 +34657,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
|
||||
String get activity_57 => _localizedValues[localeCode]['activity_57'] ?? '';
|
||||
|
||||
String get activity_58 => _localizedValues[localeCode]['activity_58'] ?? '';
|
||||
|
||||
String get activity_59 => _localizedValues[localeCode]['activity_59'] ?? '';
|
||||
|
||||
String get oneTimePassword =>
|
||||
_localizedValues[localeCode]['one_time_password'] ?? '';
|
||||
|
||||
|
|
@ -36393,6 +36404,20 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
String get postalCityState =>
|
||||
_localizedValues[localeCode]['postal_city_state'] ?? '';
|
||||
|
||||
String get reverse => _localizedValues[localeCode]['reverse'] ?? '';
|
||||
|
||||
String get cancelledInvoice =>
|
||||
_localizedValues[localeCode]['cancelled_invoice'] ?? '';
|
||||
|
||||
String get cancelledInvoices =>
|
||||
_localizedValues[localeCode]['cancelled_invoices'] ?? '';
|
||||
|
||||
String get reversedInvoice =>
|
||||
_localizedValues[localeCode]['reversed_invoice'] ?? '';
|
||||
|
||||
String get reversedInvoices =>
|
||||
_localizedValues[localeCode]['reversed_invoices'] ?? '';
|
||||
|
||||
String lookup(String key) {
|
||||
final lookupKey = toSnakeCase(key);
|
||||
return _localizedValues[localeCode][lookupKey] ??
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ IconData getEntityActionIcon(EntityAction entityAction) {
|
|||
return Icons.settings;
|
||||
case EntityAction.refund:
|
||||
return Icons.remove_circle_outline;
|
||||
case EntityAction.reverse:
|
||||
return Icons.undo;
|
||||
case EntityAction.cancel:
|
||||
return Icons.stop;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue