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',
};
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';

View File

@ -124,7 +124,6 @@ abstract class CompanyEntity extends Object
convertExpenseCurrency: false,
notifyVendorWhenPaid: false,
calculateTaxes: false,
enableEInvoice: false,
taxData: TaxDataEntity(),
groups: BuiltList<GroupEntity>(),
taxRates: BuiltList<TaxRateEntity>(),
@ -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<GroupEntity> get groups;
BuiltList<ActivityEntity> 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<SystemLogEntity>())
..subscriptions.replace(BuiltList<SubscriptionEntity>())

View File

@ -182,9 +182,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
'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<CompanyEntity> {
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<GroupEntity> groups;
@override
final BuiltList<ActivityEntity> 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<GroupEntity> _groups;
ListBuilder<GroupEntity> get groups =>
_$this._groups ??= new ListBuilder<GroupEntity>();
@ -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(),

View File

@ -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;

View File

@ -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 (_) {

View File

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