Add UI for e-invoicing

This commit is contained in:
Hillel Coren 2023-04-27 12:39:58 +03:00
parent c9fa9b1be9
commit 50fb1e6058
7 changed files with 89 additions and 32 deletions

View File

@ -216,6 +216,26 @@ const kTaxCategories = {
kTaxCategoryReverseTax: 'reverse_tax', 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 kCountryUnitedStates = '840';
const String kCountryAustralia = '36'; const String kCountryAustralia = '36';
const String kCountryCanada = '124'; const String kCountryCanada = '124';

View File

@ -124,7 +124,6 @@ abstract class CompanyEntity extends Object
convertExpenseCurrency: false, convertExpenseCurrency: false,
notifyVendorWhenPaid: false, notifyVendorWhenPaid: false,
calculateTaxes: false, calculateTaxes: false,
enableEInvoice: false,
taxData: TaxDataEntity(), taxData: TaxDataEntity(),
groups: BuiltList<GroupEntity>(), groups: BuiltList<GroupEntity>(),
taxRates: BuiltList<TaxRateEntity>(), taxRates: BuiltList<TaxRateEntity>(),
@ -314,9 +313,6 @@ abstract class CompanyEntity extends Object
@BuiltValueField(wireName: 'notify_vendor_when_paid') @BuiltValueField(wireName: 'notify_vendor_when_paid')
bool get notifyVendorWhenPaid; bool get notifyVendorWhenPaid;
@BuiltValueField(wireName: 'enable_e_invoice')
bool get enableEInvoice;
BuiltList<GroupEntity> get groups; BuiltList<GroupEntity> get groups;
BuiltList<ActivityEntity> get activities; BuiltList<ActivityEntity> get activities;
@ -758,7 +754,6 @@ abstract class CompanyEntity extends Object
..convertExpenseCurrency = false ..convertExpenseCurrency = false
..notifyVendorWhenPaid = false ..notifyVendorWhenPaid = false
..calculateTaxes = false ..calculateTaxes = false
..enableEInvoice = false
..taxData.replace(TaxDataEntity()) ..taxData.replace(TaxDataEntity())
..systemLogs.replace(BuiltList<SystemLogEntity>()) ..systemLogs.replace(BuiltList<SystemLogEntity>())
..subscriptions.replace(BuiltList<SubscriptionEntity>()) ..subscriptions.replace(BuiltList<SubscriptionEntity>())

View File

@ -182,9 +182,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
'notify_vendor_when_paid', 'notify_vendor_when_paid',
serializers.serialize(object.notifyVendorWhenPaid, serializers.serialize(object.notifyVendorWhenPaid,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'enable_e_invoice',
serializers.serialize(object.enableEInvoice,
specifiedType: const FullType(bool)),
'groups', 'groups',
serializers.serialize(object.groups, serializers.serialize(object.groups,
specifiedType: specifiedType:
@ -637,10 +634,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
result.notifyVendorWhenPaid = serializers.deserialize(value, result.notifyVendorWhenPaid = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'enable_e_invoice':
result.enableEInvoice = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'groups': case 'groups':
result.groups.replace(serializers.deserialize(value, result.groups.replace(serializers.deserialize(value,
specifiedType: const FullType( specifiedType: const FullType(
@ -1926,8 +1919,6 @@ class _$CompanyEntity extends CompanyEntity {
@override @override
final bool notifyVendorWhenPaid; final bool notifyVendorWhenPaid;
@override @override
final bool enableEInvoice;
@override
final BuiltList<GroupEntity> groups; final BuiltList<GroupEntity> groups;
@override @override
final BuiltList<ActivityEntity> activities; final BuiltList<ActivityEntity> activities;
@ -2107,7 +2098,6 @@ class _$CompanyEntity extends CompanyEntity {
this.convertPaymentCurrency, this.convertPaymentCurrency,
this.convertExpenseCurrency, this.convertExpenseCurrency,
this.notifyVendorWhenPaid, this.notifyVendorWhenPaid,
this.enableEInvoice,
this.groups, this.groups,
this.activities, this.activities,
this.taxRates, this.taxRates,
@ -2265,8 +2255,6 @@ class _$CompanyEntity extends CompanyEntity {
convertExpenseCurrency, r'CompanyEntity', 'convertExpenseCurrency'); convertExpenseCurrency, r'CompanyEntity', 'convertExpenseCurrency');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
notifyVendorWhenPaid, r'CompanyEntity', 'notifyVendorWhenPaid'); notifyVendorWhenPaid, r'CompanyEntity', 'notifyVendorWhenPaid');
BuiltValueNullFieldError.checkNotNull(
enableEInvoice, r'CompanyEntity', 'enableEInvoice');
BuiltValueNullFieldError.checkNotNull(groups, r'CompanyEntity', 'groups'); BuiltValueNullFieldError.checkNotNull(groups, r'CompanyEntity', 'groups');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
activities, r'CompanyEntity', 'activities'); activities, r'CompanyEntity', 'activities');
@ -2434,7 +2422,6 @@ class _$CompanyEntity extends CompanyEntity {
convertPaymentCurrency == other.convertPaymentCurrency && convertPaymentCurrency == other.convertPaymentCurrency &&
convertExpenseCurrency == other.convertExpenseCurrency && convertExpenseCurrency == other.convertExpenseCurrency &&
notifyVendorWhenPaid == other.notifyVendorWhenPaid && notifyVendorWhenPaid == other.notifyVendorWhenPaid &&
enableEInvoice == other.enableEInvoice &&
groups == other.groups && groups == other.groups &&
activities == other.activities && activities == other.activities &&
taxRates == other.taxRates && taxRates == other.taxRates &&
@ -2553,7 +2540,6 @@ class _$CompanyEntity extends CompanyEntity {
_$hash = $jc(_$hash, convertPaymentCurrency.hashCode); _$hash = $jc(_$hash, convertPaymentCurrency.hashCode);
_$hash = $jc(_$hash, convertExpenseCurrency.hashCode); _$hash = $jc(_$hash, convertExpenseCurrency.hashCode);
_$hash = $jc(_$hash, notifyVendorWhenPaid.hashCode); _$hash = $jc(_$hash, notifyVendorWhenPaid.hashCode);
_$hash = $jc(_$hash, enableEInvoice.hashCode);
_$hash = $jc(_$hash, groups.hashCode); _$hash = $jc(_$hash, groups.hashCode);
_$hash = $jc(_$hash, activities.hashCode); _$hash = $jc(_$hash, activities.hashCode);
_$hash = $jc(_$hash, taxRates.hashCode); _$hash = $jc(_$hash, taxRates.hashCode);
@ -2672,7 +2658,6 @@ class _$CompanyEntity extends CompanyEntity {
..add('convertPaymentCurrency', convertPaymentCurrency) ..add('convertPaymentCurrency', convertPaymentCurrency)
..add('convertExpenseCurrency', convertExpenseCurrency) ..add('convertExpenseCurrency', convertExpenseCurrency)
..add('notifyVendorWhenPaid', notifyVendorWhenPaid) ..add('notifyVendorWhenPaid', notifyVendorWhenPaid)
..add('enableEInvoice', enableEInvoice)
..add('groups', groups) ..add('groups', groups)
..add('activities', activities) ..add('activities', activities)
..add('taxRates', taxRates) ..add('taxRates', taxRates)
@ -2971,11 +2956,6 @@ class CompanyEntityBuilder
set notifyVendorWhenPaid(bool notifyVendorWhenPaid) => set notifyVendorWhenPaid(bool notifyVendorWhenPaid) =>
_$this._notifyVendorWhenPaid = notifyVendorWhenPaid; _$this._notifyVendorWhenPaid = notifyVendorWhenPaid;
bool _enableEInvoice;
bool get enableEInvoice => _$this._enableEInvoice;
set enableEInvoice(bool enableEInvoice) =>
_$this._enableEInvoice = enableEInvoice;
ListBuilder<GroupEntity> _groups; ListBuilder<GroupEntity> _groups;
ListBuilder<GroupEntity> get groups => ListBuilder<GroupEntity> get groups =>
_$this._groups ??= new ListBuilder<GroupEntity>(); _$this._groups ??= new ListBuilder<GroupEntity>();
@ -3368,7 +3348,6 @@ class CompanyEntityBuilder
_convertPaymentCurrency = $v.convertPaymentCurrency; _convertPaymentCurrency = $v.convertPaymentCurrency;
_convertExpenseCurrency = $v.convertExpenseCurrency; _convertExpenseCurrency = $v.convertExpenseCurrency;
_notifyVendorWhenPaid = $v.notifyVendorWhenPaid; _notifyVendorWhenPaid = $v.notifyVendorWhenPaid;
_enableEInvoice = $v.enableEInvoice;
_groups = $v.groups.toBuilder(); _groups = $v.groups.toBuilder();
_activities = $v.activities.toBuilder(); _activities = $v.activities.toBuilder();
_taxRates = $v.taxRates.toBuilder(); _taxRates = $v.taxRates.toBuilder();
@ -3518,7 +3497,6 @@ class CompanyEntityBuilder
convertPaymentCurrency: BuiltValueNullFieldError.checkNotNull(convertPaymentCurrency, r'CompanyEntity', 'convertPaymentCurrency'), convertPaymentCurrency: BuiltValueNullFieldError.checkNotNull(convertPaymentCurrency, r'CompanyEntity', 'convertPaymentCurrency'),
convertExpenseCurrency: BuiltValueNullFieldError.checkNotNull(convertExpenseCurrency, r'CompanyEntity', 'convertExpenseCurrency'), convertExpenseCurrency: BuiltValueNullFieldError.checkNotNull(convertExpenseCurrency, r'CompanyEntity', 'convertExpenseCurrency'),
notifyVendorWhenPaid: BuiltValueNullFieldError.checkNotNull(notifyVendorWhenPaid, r'CompanyEntity', 'notifyVendorWhenPaid'), notifyVendorWhenPaid: BuiltValueNullFieldError.checkNotNull(notifyVendorWhenPaid, r'CompanyEntity', 'notifyVendorWhenPaid'),
enableEInvoice: BuiltValueNullFieldError.checkNotNull(enableEInvoice, r'CompanyEntity', 'enableEInvoice'),
groups: groups.build(), groups: groups.build(),
activities: activities.build(), activities: activities.build(),
taxRates: taxRates.build(), taxRates: taxRates.build(),

View File

@ -988,6 +988,10 @@ abstract class SettingsEntity
@BuiltValueField(wireName: 'show_task_item_description') @BuiltValueField(wireName: 'show_task_item_description')
bool get showTaskItemDescription; bool get showTaskItemDescription;
@nullable
@BuiltValueField(wireName: 'enable_e_invoice')
bool get enableEInvoice;
@nullable @nullable
@BuiltValueField(wireName: 'e_invoice_type') @BuiltValueField(wireName: 'e_invoice_type')
String get eInvoiceType; String get eInvoiceType;

View File

@ -1513,6 +1513,13 @@ class _$SettingsEntitySerializer
..add( ..add(
serializers.serialize(value, specifiedType: const FullType(bool))); 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; value = object.eInvoiceType;
if (value != null) { if (value != null) {
result result
@ -2407,6 +2414,10 @@ class _$SettingsEntitySerializer
result.showTaskItemDescription = serializers.deserialize(value, result.showTaskItemDescription = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'enable_e_invoice':
result.enableEInvoice = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'e_invoice_type': case 'e_invoice_type':
result.eInvoiceType = serializers.deserialize(value, result.eInvoiceType = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
@ -2924,6 +2935,8 @@ class _$SettingsEntity extends SettingsEntity {
@override @override
final bool showTaskItemDescription; final bool showTaskItemDescription;
@override @override
final bool enableEInvoice;
@override
final String eInvoiceType; final String eInvoiceType;
@override @override
final String defaultExpensePaymentTypeId; final String defaultExpensePaymentTypeId;
@ -3147,6 +3160,7 @@ class _$SettingsEntity extends SettingsEntity {
this.shareInvoiceQuoteColumns, this.shareInvoiceQuoteColumns,
this.allowBillableTaskItems, this.allowBillableTaskItems,
this.showTaskItemDescription, this.showTaskItemDescription,
this.enableEInvoice,
this.eInvoiceType, this.eInvoiceType,
this.defaultExpensePaymentTypeId}) this.defaultExpensePaymentTypeId})
: super._(); : super._();
@ -3383,6 +3397,7 @@ class _$SettingsEntity extends SettingsEntity {
shareInvoiceQuoteColumns == other.shareInvoiceQuoteColumns && shareInvoiceQuoteColumns == other.shareInvoiceQuoteColumns &&
allowBillableTaskItems == other.allowBillableTaskItems && allowBillableTaskItems == other.allowBillableTaskItems &&
showTaskItemDescription == other.showTaskItemDescription && showTaskItemDescription == other.showTaskItemDescription &&
enableEInvoice == other.enableEInvoice &&
eInvoiceType == other.eInvoiceType && eInvoiceType == other.eInvoiceType &&
defaultExpensePaymentTypeId == other.defaultExpensePaymentTypeId; defaultExpensePaymentTypeId == other.defaultExpensePaymentTypeId;
} }
@ -3607,6 +3622,7 @@ class _$SettingsEntity extends SettingsEntity {
_$hash = $jc(_$hash, shareInvoiceQuoteColumns.hashCode); _$hash = $jc(_$hash, shareInvoiceQuoteColumns.hashCode);
_$hash = $jc(_$hash, allowBillableTaskItems.hashCode); _$hash = $jc(_$hash, allowBillableTaskItems.hashCode);
_$hash = $jc(_$hash, showTaskItemDescription.hashCode); _$hash = $jc(_$hash, showTaskItemDescription.hashCode);
_$hash = $jc(_$hash, enableEInvoice.hashCode);
_$hash = $jc(_$hash, eInvoiceType.hashCode); _$hash = $jc(_$hash, eInvoiceType.hashCode);
_$hash = $jc(_$hash, defaultExpensePaymentTypeId.hashCode); _$hash = $jc(_$hash, defaultExpensePaymentTypeId.hashCode);
_$hash = $jf(_$hash); _$hash = $jf(_$hash);
@ -3836,6 +3852,7 @@ class _$SettingsEntity extends SettingsEntity {
..add('shareInvoiceQuoteColumns', shareInvoiceQuoteColumns) ..add('shareInvoiceQuoteColumns', shareInvoiceQuoteColumns)
..add('allowBillableTaskItems', allowBillableTaskItems) ..add('allowBillableTaskItems', allowBillableTaskItems)
..add('showTaskItemDescription', showTaskItemDescription) ..add('showTaskItemDescription', showTaskItemDescription)
..add('enableEInvoice', enableEInvoice)
..add('eInvoiceType', eInvoiceType) ..add('eInvoiceType', eInvoiceType)
..add('defaultExpensePaymentTypeId', defaultExpensePaymentTypeId)) ..add('defaultExpensePaymentTypeId', defaultExpensePaymentTypeId))
.toString(); .toString();
@ -4902,6 +4919,11 @@ class SettingsEntityBuilder
set showTaskItemDescription(bool showTaskItemDescription) => set showTaskItemDescription(bool showTaskItemDescription) =>
_$this._showTaskItemDescription = showTaskItemDescription; _$this._showTaskItemDescription = showTaskItemDescription;
bool _enableEInvoice;
bool get enableEInvoice => _$this._enableEInvoice;
set enableEInvoice(bool enableEInvoice) =>
_$this._enableEInvoice = enableEInvoice;
String _eInvoiceType; String _eInvoiceType;
String get eInvoiceType => _$this._eInvoiceType; String get eInvoiceType => _$this._eInvoiceType;
set eInvoiceType(String eInvoiceType) => _$this._eInvoiceType = eInvoiceType; set eInvoiceType(String eInvoiceType) => _$this._eInvoiceType = eInvoiceType;
@ -5131,6 +5153,7 @@ class SettingsEntityBuilder
_shareInvoiceQuoteColumns = $v.shareInvoiceQuoteColumns; _shareInvoiceQuoteColumns = $v.shareInvoiceQuoteColumns;
_allowBillableTaskItems = $v.allowBillableTaskItems; _allowBillableTaskItems = $v.allowBillableTaskItems;
_showTaskItemDescription = $v.showTaskItemDescription; _showTaskItemDescription = $v.showTaskItemDescription;
_enableEInvoice = $v.enableEInvoice;
_eInvoiceType = $v.eInvoiceType; _eInvoiceType = $v.eInvoiceType;
_defaultExpensePaymentTypeId = $v.defaultExpensePaymentTypeId; _defaultExpensePaymentTypeId = $v.defaultExpensePaymentTypeId;
_$v = null; _$v = null;
@ -5373,6 +5396,7 @@ class SettingsEntityBuilder
shareInvoiceQuoteColumns: shareInvoiceQuoteColumns, shareInvoiceQuoteColumns: shareInvoiceQuoteColumns,
allowBillableTaskItems: allowBillableTaskItems, allowBillableTaskItems: allowBillableTaskItems,
showTaskItemDescription: showTaskItemDescription, showTaskItemDescription: showTaskItemDescription,
enableEInvoice: enableEInvoice,
eInvoiceType: eInvoiceType, eInvoiceType: eInvoiceType,
defaultExpensePaymentTypeId: defaultExpensePaymentTypeId); defaultExpensePaymentTypeId: defaultExpensePaymentTypeId);
} catch (_) { } catch (_) {

View File

@ -455,11 +455,7 @@ class _EmailSettingsState extends State<EmailSettings> {
maxLines: 6, maxLines: 6,
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
), ),
], SizedBox(height: 16),
),
FormCard(
isLast: true,
children: <Widget>[
BoolDropdownButton( BoolDropdownButton(
label: localization.showEmailFooter, label: localization.showEmailFooter,
value: state.settingsUIState.isFiltered value: state.settingsUIState.isFiltered
@ -469,6 +465,11 @@ class _EmailSettingsState extends State<EmailSettings> {
onChanged: (value) => viewModel.onSettingsChanged( onChanged: (value) => viewModel.onSettingsChanged(
settings.rebuild((b) => b..showEmailFooter = value)), settings.rebuild((b) => b..showEmailFooter = value)),
), ),
],
),
FormCard(
isLast: true,
children: <Widget>[
BoolDropdownButton( BoolDropdownButton(
label: localization.attachPdf, label: localization.attachPdf,
value: settings.pdfEmailAttachment, value: settings.pdfEmailAttachment,
@ -490,6 +491,31 @@ class _EmailSettingsState extends State<EmailSettings> {
onChanged: (value) => viewModel.onSettingsChanged( onChanged: (value) => viewModel.onSettingsChanged(
settings.rebuild((b) => b..ublEmailAttachment = value)), 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<String>(
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<String>(
child: Text(type),
value: type,
))
.toList()),
)
], ],
), ),
], ],

View File

@ -18,6 +18,8 @@ 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
'enable_e_invoice': 'Enable E-Invoice',
'e_invoice_type': 'E-Invoice Type',
'reduced_tax': 'Reduced Tax', 'reduced_tax': 'Reduced Tax',
'override_tax': 'Override Tax', 'override_tax': 'Override Tax',
'zero_rated': 'Zero Rated', 'zero_rated': 'Zero Rated',
@ -99393,6 +99395,14 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['reverse_tax'] ?? _localizedValues[localeCode]['reverse_tax'] ??
_localizedValues['en']['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 // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {