diff --git a/lib/constants.dart b/lib/constants.dart index 77563031d..c5af1dc46 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -216,6 +216,26 @@ const kTaxCategories = { kTaxCategoryReverseTax: 'reverse_tax', }; +const String kEInvoiceTypeEN16931 = 'EN16931'; +const String kEInvoiceTypeXInvoice_2_2 = 'XInvoice_2_2'; +const String kEInvoiceTypeXInvoice_2_1 = 'XInvoice_2_1'; +const String kEInvoiceTypeXInvoice_2_0 = 'XInvoice_2_0'; +const String kEInvoiceTypeXInvoice_1_0 = 'XInvoice_1_0'; +const String kEInvoiceTypeXInvoice_Extended = 'XInvoice-Extended'; +const String kEInvoiceTypeXInvoice_BasicWL = 'XInvoice-BasicWL'; +const String kEInvoiceTypeXInvoice_Basic = 'XInvoice-Basic'; + +const kEInvoiceTypes = [ + kEInvoiceTypeEN16931, + kEInvoiceTypeXInvoice_2_2, + kEInvoiceTypeXInvoice_2_1, + kEInvoiceTypeXInvoice_2_0, + kEInvoiceTypeXInvoice_1_0, + kEInvoiceTypeXInvoice_Extended, + kEInvoiceTypeXInvoice_BasicWL, + kEInvoiceTypeXInvoice_Basic, +]; + const String kCountryUnitedStates = '840'; const String kCountryAustralia = '36'; const String kCountryCanada = '124'; diff --git a/lib/data/models/company_model.dart b/lib/data/models/company_model.dart index 2b3095404..629361c4b 100644 --- a/lib/data/models/company_model.dart +++ b/lib/data/models/company_model.dart @@ -124,7 +124,6 @@ abstract class CompanyEntity extends Object convertExpenseCurrency: false, notifyVendorWhenPaid: false, calculateTaxes: false, - enableEInvoice: false, taxData: TaxDataEntity(), groups: BuiltList(), taxRates: BuiltList(), @@ -314,9 +313,6 @@ abstract class CompanyEntity extends Object @BuiltValueField(wireName: 'notify_vendor_when_paid') bool get notifyVendorWhenPaid; - @BuiltValueField(wireName: 'enable_e_invoice') - bool get enableEInvoice; - BuiltList get groups; BuiltList get activities; @@ -758,7 +754,6 @@ abstract class CompanyEntity extends Object ..convertExpenseCurrency = false ..notifyVendorWhenPaid = false ..calculateTaxes = false - ..enableEInvoice = false ..taxData.replace(TaxDataEntity()) ..systemLogs.replace(BuiltList()) ..subscriptions.replace(BuiltList()) diff --git a/lib/data/models/company_model.g.dart b/lib/data/models/company_model.g.dart index 88111238d..4346a6908 100644 --- a/lib/data/models/company_model.g.dart +++ b/lib/data/models/company_model.g.dart @@ -182,9 +182,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer { 'notify_vendor_when_paid', serializers.serialize(object.notifyVendorWhenPaid, specifiedType: const FullType(bool)), - 'enable_e_invoice', - serializers.serialize(object.enableEInvoice, - specifiedType: const FullType(bool)), 'groups', serializers.serialize(object.groups, specifiedType: @@ -637,10 +634,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer { result.notifyVendorWhenPaid = serializers.deserialize(value, specifiedType: const FullType(bool)) as bool; break; - case 'enable_e_invoice': - result.enableEInvoice = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool; - break; case 'groups': result.groups.replace(serializers.deserialize(value, specifiedType: const FullType( @@ -1926,8 +1919,6 @@ class _$CompanyEntity extends CompanyEntity { @override final bool notifyVendorWhenPaid; @override - final bool enableEInvoice; - @override final BuiltList groups; @override final BuiltList activities; @@ -2107,7 +2098,6 @@ class _$CompanyEntity extends CompanyEntity { this.convertPaymentCurrency, this.convertExpenseCurrency, this.notifyVendorWhenPaid, - this.enableEInvoice, this.groups, this.activities, this.taxRates, @@ -2265,8 +2255,6 @@ class _$CompanyEntity extends CompanyEntity { convertExpenseCurrency, r'CompanyEntity', 'convertExpenseCurrency'); BuiltValueNullFieldError.checkNotNull( notifyVendorWhenPaid, r'CompanyEntity', 'notifyVendorWhenPaid'); - BuiltValueNullFieldError.checkNotNull( - enableEInvoice, r'CompanyEntity', 'enableEInvoice'); BuiltValueNullFieldError.checkNotNull(groups, r'CompanyEntity', 'groups'); BuiltValueNullFieldError.checkNotNull( activities, r'CompanyEntity', 'activities'); @@ -2434,7 +2422,6 @@ class _$CompanyEntity extends CompanyEntity { convertPaymentCurrency == other.convertPaymentCurrency && convertExpenseCurrency == other.convertExpenseCurrency && notifyVendorWhenPaid == other.notifyVendorWhenPaid && - enableEInvoice == other.enableEInvoice && groups == other.groups && activities == other.activities && taxRates == other.taxRates && @@ -2553,7 +2540,6 @@ class _$CompanyEntity extends CompanyEntity { _$hash = $jc(_$hash, convertPaymentCurrency.hashCode); _$hash = $jc(_$hash, convertExpenseCurrency.hashCode); _$hash = $jc(_$hash, notifyVendorWhenPaid.hashCode); - _$hash = $jc(_$hash, enableEInvoice.hashCode); _$hash = $jc(_$hash, groups.hashCode); _$hash = $jc(_$hash, activities.hashCode); _$hash = $jc(_$hash, taxRates.hashCode); @@ -2672,7 +2658,6 @@ class _$CompanyEntity extends CompanyEntity { ..add('convertPaymentCurrency', convertPaymentCurrency) ..add('convertExpenseCurrency', convertExpenseCurrency) ..add('notifyVendorWhenPaid', notifyVendorWhenPaid) - ..add('enableEInvoice', enableEInvoice) ..add('groups', groups) ..add('activities', activities) ..add('taxRates', taxRates) @@ -2971,11 +2956,6 @@ class CompanyEntityBuilder set notifyVendorWhenPaid(bool notifyVendorWhenPaid) => _$this._notifyVendorWhenPaid = notifyVendorWhenPaid; - bool _enableEInvoice; - bool get enableEInvoice => _$this._enableEInvoice; - set enableEInvoice(bool enableEInvoice) => - _$this._enableEInvoice = enableEInvoice; - ListBuilder _groups; ListBuilder get groups => _$this._groups ??= new ListBuilder(); @@ -3368,7 +3348,6 @@ class CompanyEntityBuilder _convertPaymentCurrency = $v.convertPaymentCurrency; _convertExpenseCurrency = $v.convertExpenseCurrency; _notifyVendorWhenPaid = $v.notifyVendorWhenPaid; - _enableEInvoice = $v.enableEInvoice; _groups = $v.groups.toBuilder(); _activities = $v.activities.toBuilder(); _taxRates = $v.taxRates.toBuilder(); @@ -3518,7 +3497,6 @@ class CompanyEntityBuilder convertPaymentCurrency: BuiltValueNullFieldError.checkNotNull(convertPaymentCurrency, r'CompanyEntity', 'convertPaymentCurrency'), convertExpenseCurrency: BuiltValueNullFieldError.checkNotNull(convertExpenseCurrency, r'CompanyEntity', 'convertExpenseCurrency'), notifyVendorWhenPaid: BuiltValueNullFieldError.checkNotNull(notifyVendorWhenPaid, r'CompanyEntity', 'notifyVendorWhenPaid'), - enableEInvoice: BuiltValueNullFieldError.checkNotNull(enableEInvoice, r'CompanyEntity', 'enableEInvoice'), groups: groups.build(), activities: activities.build(), taxRates: taxRates.build(), diff --git a/lib/data/models/settings_model.dart b/lib/data/models/settings_model.dart index ef9522a55..edc0620b2 100644 --- a/lib/data/models/settings_model.dart +++ b/lib/data/models/settings_model.dart @@ -988,6 +988,10 @@ abstract class SettingsEntity @BuiltValueField(wireName: 'show_task_item_description') bool get showTaskItemDescription; + @nullable + @BuiltValueField(wireName: 'enable_e_invoice') + bool get enableEInvoice; + @nullable @BuiltValueField(wireName: 'e_invoice_type') String get eInvoiceType; diff --git a/lib/data/models/settings_model.g.dart b/lib/data/models/settings_model.g.dart index 92ac7061b..9e0ee9a18 100644 --- a/lib/data/models/settings_model.g.dart +++ b/lib/data/models/settings_model.g.dart @@ -1513,6 +1513,13 @@ class _$SettingsEntitySerializer ..add( serializers.serialize(value, specifiedType: const FullType(bool))); } + value = object.enableEInvoice; + if (value != null) { + result + ..add('enable_e_invoice') + ..add( + serializers.serialize(value, specifiedType: const FullType(bool))); + } value = object.eInvoiceType; if (value != null) { result @@ -2407,6 +2414,10 @@ class _$SettingsEntitySerializer result.showTaskItemDescription = serializers.deserialize(value, specifiedType: const FullType(bool)) as bool; break; + case 'enable_e_invoice': + result.enableEInvoice = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; case 'e_invoice_type': result.eInvoiceType = serializers.deserialize(value, specifiedType: const FullType(String)) as String; @@ -2924,6 +2935,8 @@ class _$SettingsEntity extends SettingsEntity { @override final bool showTaskItemDescription; @override + final bool enableEInvoice; + @override final String eInvoiceType; @override final String defaultExpensePaymentTypeId; @@ -3147,6 +3160,7 @@ class _$SettingsEntity extends SettingsEntity { this.shareInvoiceQuoteColumns, this.allowBillableTaskItems, this.showTaskItemDescription, + this.enableEInvoice, this.eInvoiceType, this.defaultExpensePaymentTypeId}) : super._(); @@ -3383,6 +3397,7 @@ class _$SettingsEntity extends SettingsEntity { shareInvoiceQuoteColumns == other.shareInvoiceQuoteColumns && allowBillableTaskItems == other.allowBillableTaskItems && showTaskItemDescription == other.showTaskItemDescription && + enableEInvoice == other.enableEInvoice && eInvoiceType == other.eInvoiceType && defaultExpensePaymentTypeId == other.defaultExpensePaymentTypeId; } @@ -3607,6 +3622,7 @@ class _$SettingsEntity extends SettingsEntity { _$hash = $jc(_$hash, shareInvoiceQuoteColumns.hashCode); _$hash = $jc(_$hash, allowBillableTaskItems.hashCode); _$hash = $jc(_$hash, showTaskItemDescription.hashCode); + _$hash = $jc(_$hash, enableEInvoice.hashCode); _$hash = $jc(_$hash, eInvoiceType.hashCode); _$hash = $jc(_$hash, defaultExpensePaymentTypeId.hashCode); _$hash = $jf(_$hash); @@ -3836,6 +3852,7 @@ class _$SettingsEntity extends SettingsEntity { ..add('shareInvoiceQuoteColumns', shareInvoiceQuoteColumns) ..add('allowBillableTaskItems', allowBillableTaskItems) ..add('showTaskItemDescription', showTaskItemDescription) + ..add('enableEInvoice', enableEInvoice) ..add('eInvoiceType', eInvoiceType) ..add('defaultExpensePaymentTypeId', defaultExpensePaymentTypeId)) .toString(); @@ -4902,6 +4919,11 @@ class SettingsEntityBuilder set showTaskItemDescription(bool showTaskItemDescription) => _$this._showTaskItemDescription = showTaskItemDescription; + bool _enableEInvoice; + bool get enableEInvoice => _$this._enableEInvoice; + set enableEInvoice(bool enableEInvoice) => + _$this._enableEInvoice = enableEInvoice; + String _eInvoiceType; String get eInvoiceType => _$this._eInvoiceType; set eInvoiceType(String eInvoiceType) => _$this._eInvoiceType = eInvoiceType; @@ -5131,6 +5153,7 @@ class SettingsEntityBuilder _shareInvoiceQuoteColumns = $v.shareInvoiceQuoteColumns; _allowBillableTaskItems = $v.allowBillableTaskItems; _showTaskItemDescription = $v.showTaskItemDescription; + _enableEInvoice = $v.enableEInvoice; _eInvoiceType = $v.eInvoiceType; _defaultExpensePaymentTypeId = $v.defaultExpensePaymentTypeId; _$v = null; @@ -5373,6 +5396,7 @@ class SettingsEntityBuilder shareInvoiceQuoteColumns: shareInvoiceQuoteColumns, allowBillableTaskItems: allowBillableTaskItems, showTaskItemDescription: showTaskItemDescription, + enableEInvoice: enableEInvoice, eInvoiceType: eInvoiceType, defaultExpensePaymentTypeId: defaultExpensePaymentTypeId); } catch (_) { diff --git a/lib/ui/settings/email_settings.dart b/lib/ui/settings/email_settings.dart index 1b36ee905..2af10619a 100644 --- a/lib/ui/settings/email_settings.dart +++ b/lib/ui/settings/email_settings.dart @@ -455,11 +455,7 @@ class _EmailSettingsState extends State { maxLines: 6, keyboardType: TextInputType.multiline, ), - ], - ), - FormCard( - isLast: true, - children: [ + SizedBox(height: 16), BoolDropdownButton( label: localization.showEmailFooter, value: state.settingsUIState.isFiltered @@ -469,6 +465,11 @@ class _EmailSettingsState extends State { onChanged: (value) => viewModel.onSettingsChanged( settings.rebuild((b) => b..showEmailFooter = value)), ), + ], + ), + FormCard( + isLast: true, + children: [ BoolDropdownButton( label: localization.attachPdf, value: settings.pdfEmailAttachment, @@ -490,6 +491,31 @@ class _EmailSettingsState extends State { onChanged: (value) => viewModel.onSettingsChanged( settings.rebuild((b) => b..ublEmailAttachment = value)), ), + BoolDropdownButton( + label: localization.enableEInvoice, + value: settings.enableEInvoice, + iconData: MdiIcons.fileXmlBox, + onChanged: (value) => viewModel.onSettingsChanged( + settings.rebuild((b) => b..enableEInvoice = value)), + ), + if (settings.enableEInvoice == true) + Padding( + padding: const EdgeInsets.only(top: 16), + child: AppDropdownButton( + labelText: localization.eInvoiceType, + showBlank: state.uiState.settingsUIState.isFiltered, + value: settings.eInvoiceType, + onChanged: (dynamic value) { + viewModel.onSettingsChanged( + settings.rebuild((b) => b..eInvoiceType = value)); + }, + items: kEInvoiceTypes + .map((type) => DropdownMenuItem( + child: Text(type), + value: type, + )) + .toList()), + ) ], ), ], diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 8e0aab236..8e25a20a3 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -18,6 +18,8 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'enable_e_invoice': 'Enable E-Invoice', + 'e_invoice_type': 'E-Invoice Type', 'reduced_tax': 'Reduced Tax', 'override_tax': 'Override Tax', 'zero_rated': 'Zero Rated', @@ -99393,6 +99395,14 @@ mixin LocalizationsProvider on LocaleCodeAware { _localizedValues[localeCode]['reverse_tax'] ?? _localizedValues['en']['reverse_tax']; + String get enableEInvoice => + _localizedValues[localeCode]['enable_e_invoice'] ?? + _localizedValues['en']['enable_e_invoice']; + + String get eInvoiceType => + _localizedValues[localeCode]['e_invoice_type'] ?? + _localizedValues['en']['e_invoice_type']; + // STARTER: lang field - do not remove comment String lookup(String key) {