Support single bulk email
This commit is contained in:
parent
abc08eeafd
commit
d4fa06301f
|
|
@ -757,6 +757,15 @@ abstract class InvoiceEntity extends Object
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userCompany.canEditEntity(this)) {
|
if (userCompany.canEditEntity(this)) {
|
||||||
|
if (multiselect) {
|
||||||
|
if (entityType == EntityType.quote) {
|
||||||
|
actions.add(EntityAction.bulkEmailQuote);
|
||||||
|
} else if (entityType == EntityType.credit) {
|
||||||
|
actions.add(EntityAction.bulkEmailCredit);
|
||||||
|
} else if (entityType == EntityType.invoice) {
|
||||||
|
actions.add(EntityAction.bulkEmailInvoice);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (entityType == EntityType.quote) {
|
if (entityType == EntityType.quote) {
|
||||||
actions.add(EntityAction.emailQuote);
|
actions.add(EntityAction.emailQuote);
|
||||||
} else if (entityType == EntityType.credit) {
|
} else if (entityType == EntityType.credit) {
|
||||||
|
|
@ -764,6 +773,7 @@ abstract class InvoiceEntity extends Object
|
||||||
} else if (entityType == EntityType.invoice) {
|
} else if (entityType == EntityType.invoice) {
|
||||||
actions.add(EntityAction.emailInvoice);
|
actions.add(EntityAction.emailInvoice);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isPayable && userCompany.canCreate(EntityType.payment)) {
|
if (isPayable && userCompany.canCreate(EntityType.payment)) {
|
||||||
actions.add(EntityAction.newPayment);
|
actions.add(EntityAction.newPayment);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,10 @@ class EntityAction extends EnumClass {
|
||||||
static const EntityAction emailInvoice = _$emailInvoice;
|
static const EntityAction emailInvoice = _$emailInvoice;
|
||||||
static const EntityAction emailQuote = _$emailQuote;
|
static const EntityAction emailQuote = _$emailQuote;
|
||||||
static const EntityAction emailCredit = _$emailCredit;
|
static const EntityAction emailCredit = _$emailCredit;
|
||||||
static const EntityAction emailPayment = _$emailPayment;
|
static const EntityAction bulkEmailInvoice = _$bulkEmailInvoice;
|
||||||
|
static const EntityAction bulkEmailQuote = _$bulkEmailQuote;
|
||||||
|
static const EntityAction bulkEmailCredit = _$bulkEmailCredit;
|
||||||
|
static const EntityAction bulkEmailPayment = _$bulkEmailPayment;
|
||||||
static const EntityAction markSent = _$markSent;
|
static const EntityAction markSent = _$markSent;
|
||||||
static const EntityAction markPaid = _$markPaid;
|
static const EntityAction markPaid = _$markPaid;
|
||||||
static const EntityAction newClient = _$newClient;
|
static const EntityAction newClient = _$newClient;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,12 @@ const EntityAction _$download = const EntityAction._('download');
|
||||||
const EntityAction _$emailInvoice = const EntityAction._('emailInvoice');
|
const EntityAction _$emailInvoice = const EntityAction._('emailInvoice');
|
||||||
const EntityAction _$emailQuote = const EntityAction._('emailQuote');
|
const EntityAction _$emailQuote = const EntityAction._('emailQuote');
|
||||||
const EntityAction _$emailCredit = const EntityAction._('emailCredit');
|
const EntityAction _$emailCredit = const EntityAction._('emailCredit');
|
||||||
const EntityAction _$emailPayment = const EntityAction._('emailPayment');
|
const EntityAction _$bulkEmailInvoice =
|
||||||
|
const EntityAction._('bulkEmailInvoice');
|
||||||
|
const EntityAction _$bulkEmailQuote = const EntityAction._('bulkEmailQuote');
|
||||||
|
const EntityAction _$bulkEmailCredit = const EntityAction._('bulkEmailCredit');
|
||||||
|
const EntityAction _$bulkEmailPayment =
|
||||||
|
const EntityAction._('bulkEmailPayment');
|
||||||
const EntityAction _$markSent = const EntityAction._('markSent');
|
const EntityAction _$markSent = const EntityAction._('markSent');
|
||||||
const EntityAction _$markPaid = const EntityAction._('markPaid');
|
const EntityAction _$markPaid = const EntityAction._('markPaid');
|
||||||
const EntityAction _$newClient = const EntityAction._('newClient');
|
const EntityAction _$newClient = const EntityAction._('newClient');
|
||||||
|
|
@ -103,8 +108,14 @@ EntityAction _$valueOf(String name) {
|
||||||
return _$emailQuote;
|
return _$emailQuote;
|
||||||
case 'emailCredit':
|
case 'emailCredit':
|
||||||
return _$emailCredit;
|
return _$emailCredit;
|
||||||
case 'emailPayment':
|
case 'bulkEmailInvoice':
|
||||||
return _$emailPayment;
|
return _$bulkEmailInvoice;
|
||||||
|
case 'bulkEmailQuote':
|
||||||
|
return _$bulkEmailQuote;
|
||||||
|
case 'bulkEmailCredit':
|
||||||
|
return _$bulkEmailCredit;
|
||||||
|
case 'bulkEmailPayment':
|
||||||
|
return _$bulkEmailPayment;
|
||||||
case 'markSent':
|
case 'markSent':
|
||||||
return _$markSent;
|
return _$markSent;
|
||||||
case 'markPaid':
|
case 'markPaid':
|
||||||
|
|
@ -191,7 +202,10 @@ final BuiltSet<EntityAction> _$values =
|
||||||
_$emailInvoice,
|
_$emailInvoice,
|
||||||
_$emailQuote,
|
_$emailQuote,
|
||||||
_$emailCredit,
|
_$emailCredit,
|
||||||
_$emailPayment,
|
_$bulkEmailInvoice,
|
||||||
|
_$bulkEmailQuote,
|
||||||
|
_$bulkEmailCredit,
|
||||||
|
_$bulkEmailPayment,
|
||||||
_$markSent,
|
_$markSent,
|
||||||
_$markPaid,
|
_$markPaid,
|
||||||
_$newClient,
|
_$newClient,
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ abstract class PaymentEntity extends Object
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client != null && client.hasEmailAddress) {
|
if (client != null && client.hasEmailAddress) {
|
||||||
actions.add(EntityAction.emailPayment);
|
actions.add(EntityAction.bulkEmailPayment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,7 @@ Future handleCreditAction(
|
||||||
creditIds));
|
creditIds));
|
||||||
break;
|
break;
|
||||||
case EntityAction.emailCredit:
|
case EntityAction.emailCredit:
|
||||||
|
case EntityAction.bulkEmailCredit:
|
||||||
bool emailValid = true;
|
bool emailValid = true;
|
||||||
creditIds.forEach((element) {
|
creditIds.forEach((element) {
|
||||||
final client = state.clientState.get(credit.clientId);
|
final client = state.clientState.get(credit.clientId);
|
||||||
|
|
@ -469,7 +470,7 @@ Future handleCreditAction(
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (creditIds.length == 1) {
|
if (action == EntityAction.emailCredit) {
|
||||||
store.dispatch(ShowEmailCredit(
|
store.dispatch(ShowEmailCredit(
|
||||||
completer:
|
completer:
|
||||||
snackBarCompleter<Null>(context, localization.emailedCredit),
|
snackBarCompleter<Null>(context, localization.emailedCredit),
|
||||||
|
|
|
||||||
|
|
@ -564,6 +564,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
||||||
invoiceIds));
|
invoiceIds));
|
||||||
break;
|
break;
|
||||||
case EntityAction.emailInvoice:
|
case EntityAction.emailInvoice:
|
||||||
|
case EntityAction.bulkEmailInvoice:
|
||||||
bool emailValid = true;
|
bool emailValid = true;
|
||||||
invoiceIds.forEach((element) {
|
invoiceIds.forEach((element) {
|
||||||
final client = state.clientState.get(invoice.clientId);
|
final client = state.clientState.get(invoice.clientId);
|
||||||
|
|
@ -587,7 +588,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (invoiceIds.length == 1) {
|
if (action == EntityAction.emailInvoice) {
|
||||||
store.dispatch(ShowEmailInvoice(
|
store.dispatch(ShowEmailInvoice(
|
||||||
completer:
|
completer:
|
||||||
snackBarCompleter<Null>(context, localization.emailedInvoice),
|
snackBarCompleter<Null>(context, localization.emailedInvoice),
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ void handlePaymentAction(
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case EntityAction.emailPayment:
|
case EntityAction.bulkEmailPayment:
|
||||||
store.dispatch(EmailPaymentRequest(
|
store.dispatch(EmailPaymentRequest(
|
||||||
snackBarCompleter<Null>(context, localization.emailedPayment),
|
snackBarCompleter<Null>(context, localization.emailedPayment),
|
||||||
paymentIds));
|
paymentIds));
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ Middleware<AppState> _emailPayment(PaymentRepository repository) {
|
||||||
final action = dynamicAction as EmailPaymentRequest;
|
final action = dynamicAction as EmailPaymentRequest;
|
||||||
repository
|
repository
|
||||||
.bulkAction(store.state.credentials, action.paymentIds,
|
.bulkAction(store.state.credentials, action.paymentIds,
|
||||||
EntityAction.emailPayment)
|
EntityAction.bulkEmailPayment)
|
||||||
.then((List<PaymentEntity> payments) {
|
.then((List<PaymentEntity> payments) {
|
||||||
store.dispatch(EmailPaymentSuccess());
|
store.dispatch(EmailPaymentSuccess());
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
|
|
|
||||||
|
|
@ -470,6 +470,7 @@ Future handleQuoteAction(
|
||||||
quoteIds));
|
quoteIds));
|
||||||
break;
|
break;
|
||||||
case EntityAction.emailQuote:
|
case EntityAction.emailQuote:
|
||||||
|
case EntityAction.bulkEmailQuote:
|
||||||
bool emailValid = true;
|
bool emailValid = true;
|
||||||
quoteIds.forEach((element) {
|
quoteIds.forEach((element) {
|
||||||
final client = state.clientState.get(quote.clientId);
|
final client = state.clientState.get(quote.clientId);
|
||||||
|
|
@ -493,7 +494,7 @@ Future handleQuoteAction(
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (quoteIds.length == 1) {
|
if (action == EntityAction.emailQuote) {
|
||||||
store.dispatch(ShowEmailQuote(
|
store.dispatch(ShowEmailQuote(
|
||||||
completer:
|
completer:
|
||||||
snackBarCompleter<Null>(context, localization.emailedQuote),
|
snackBarCompleter<Null>(context, localization.emailedQuote),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
static final Map<String, Map<String, String>> _localizedValues = {
|
static final Map<String, Map<String, String>> _localizedValues = {
|
||||||
'en': {
|
'en': {
|
||||||
// STARTER: lang key - do not remove comment
|
// STARTER: lang key - do not remove comment
|
||||||
|
'bulk_email_invoice': 'Email Invoice',
|
||||||
|
'bulk_email_quote': 'Email Quote',
|
||||||
|
'bulk_email_credit': 'Email Credit',
|
||||||
'from_name': 'From Name',
|
'from_name': 'From Name',
|
||||||
'enabling_may_degrade_performance': 'Enabling may degrade performance',
|
'enabling_may_degrade_performance': 'Enabling may degrade performance',
|
||||||
'disabling_may_improve_performance': 'Disabling may improve performance',
|
'disabling_may_improve_performance': 'Disabling may improve performance',
|
||||||
|
|
@ -62603,6 +62606,18 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
_localizedValues[localeCode]['from_name'] ??
|
_localizedValues[localeCode]['from_name'] ??
|
||||||
_localizedValues['en']['from_name'];
|
_localizedValues['en']['from_name'];
|
||||||
|
|
||||||
|
String get bulkEmailInvoice =>
|
||||||
|
_localizedValues[localeCode]['bulk_email_invoice'] ??
|
||||||
|
_localizedValues['en']['bulk_email_invoice'];
|
||||||
|
|
||||||
|
String get bulkEmailQuote =>
|
||||||
|
_localizedValues[localeCode]['bulk_email_quote'] ??
|
||||||
|
_localizedValues['en']['bulk_email_quote'];
|
||||||
|
|
||||||
|
String get bulkEmailCredit =>
|
||||||
|
_localizedValues[localeCode]['bulk_email_credit'] ??
|
||||||
|
_localizedValues['en']['bulk_email_credit'];
|
||||||
|
|
||||||
// STARTER: lang field - do not remove comment
|
// STARTER: lang field - do not remove comment
|
||||||
|
|
||||||
String lookup(String key) {
|
String lookup(String key) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,10 @@ IconData getEntityActionIcon(EntityAction entityAction) {
|
||||||
return Icons.public;
|
return Icons.public;
|
||||||
case EntityAction.markPaid:
|
case EntityAction.markPaid:
|
||||||
return Icons.payment;
|
return Icons.payment;
|
||||||
case EntityAction.emailPayment:
|
case EntityAction.bulkEmailPayment:
|
||||||
|
case EntityAction.bulkEmailCredit:
|
||||||
|
case EntityAction.bulkEmailInvoice:
|
||||||
|
case EntityAction.bulkEmailQuote:
|
||||||
case EntityAction.emailQuote:
|
case EntityAction.emailQuote:
|
||||||
case EntityAction.emailInvoice:
|
case EntityAction.emailInvoice:
|
||||||
case EntityAction.emailCredit:
|
case EntityAction.emailCredit:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue