diff --git a/lib/data/models/vendor_model.dart b/lib/data/models/vendor_model.dart index 266dad40e..46ca427f6 100644 --- a/lib/data/models/vendor_model.dart +++ b/lib/data/models/vendor_model.dart @@ -456,6 +456,9 @@ abstract class VendorEntity extends Object bool get hasUser => assignedUserId != null && assignedUserId.isNotEmpty; + bool get hasEmailAddress => + contacts.where((contact) => contact.email?.isNotEmpty).isNotEmpty; + static Serializer get serializer => _$vendorEntitySerializer; bool get hasNameSet { diff --git a/lib/redux/purchase_order/purchase_order_actions.dart b/lib/redux/purchase_order/purchase_order_actions.dart index 2f6c99d35..8eaa55db3 100644 --- a/lib/redux/purchase_order/purchase_order_actions.dart +++ b/lib/redux/purchase_order/purchase_order_actions.dart @@ -549,17 +549,17 @@ void handlePurchaseOrderAction(BuildContext context, case EntityAction.bulkSendEmail: bool emailValid = true; purchaseOrders.forEach((purchaseOrder) { - final client = state.clientState.get( - (purchaseOrder as InvoiceEntity).clientId, + final vendor = state.vendorState.get( + (purchaseOrder as InvoiceEntity).vendorId, ); - if (!client.hasEmailAddress) { + if (!vendor.hasEmailAddress) { emailValid = false; } }); if (!emailValid) { showMessageDialog( context: context, - message: localization.clientEmailNotSet, + message: localization.vendorEmailNotSet, secondaryActions: [ TextButton( onPressed: () { diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 9310970a6..837f9065d 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'vendor_email_not_set': 'Vendor does not have an email address set', 'bulk_send_email': 'Send Email', 'marked_purchase_order_as_sent': 'Successfully marked purchase order as sent', @@ -70805,6 +70806,10 @@ mixin LocalizationsProvider on LocaleCodeAware { _localizedValues[localeCode]['cancelled_purchase_orders'] ?? _localizedValues['en']['cancelled_purchase_orders']; + String get vendorEmailNotSet => + _localizedValues[localeCode]['vendor_email_not_set'] ?? + _localizedValues['en']['vendor_email_not_set']; + // STARTER: lang field - do not remove comment String lookup(String key) {