Add convert currency defaults

This commit is contained in:
Hillel Coren 2022-12-08 16:29:09 +02:00
parent 826e0c1936
commit 503d145b5e
5 changed files with 82 additions and 2 deletions

View File

@ -118,6 +118,8 @@ abstract class CompanyEntity extends Object
stockNotificationThreshold: 0, stockNotificationThreshold: 0,
stockNotification: true, stockNotification: true,
invoiceTaskLock: false, invoiceTaskLock: false,
convertPaymentCurrency: false,
convertExpenseCurrency: false,
groups: BuiltList<GroupEntity>(), groups: BuiltList<GroupEntity>(),
taxRates: BuiltList<TaxRateEntity>(), taxRates: BuiltList<TaxRateEntity>(),
taskStatuses: BuiltList<TaskStatusEntity>(), taskStatuses: BuiltList<TaskStatusEntity>(),
@ -296,6 +298,12 @@ abstract class CompanyEntity extends Object
@BuiltValueField(wireName: 'invoice_task_lock') @BuiltValueField(wireName: 'invoice_task_lock')
bool get invoiceTaskLock; bool get invoiceTaskLock;
@BuiltValueField(wireName: 'convert_payment_currency')
bool get convertPaymentCurrency;
@BuiltValueField(wireName: 'convert_expense_currency')
bool get convertExpenseCurrency;
BuiltList<GroupEntity> get groups; BuiltList<GroupEntity> get groups;
BuiltList<ActivityEntity> get activities; BuiltList<ActivityEntity> get activities;
@ -706,6 +714,8 @@ abstract class CompanyEntity extends Object
..invoiceTaskLock = false ..invoiceTaskLock = false
..matomoUrl = '' ..matomoUrl = ''
..matomoId = '' ..matomoId = ''
..convertPaymentCurrency = false
..convertExpenseCurrency = false
..systemLogs.replace(BuiltList<SystemLogEntity>()) ..systemLogs.replace(BuiltList<SystemLogEntity>())
..subscriptions.replace(BuiltList<SubscriptionEntity>()) ..subscriptions.replace(BuiltList<SubscriptionEntity>())
..recurringExpenses.replace(BuiltList<ExpenseEntity>()) ..recurringExpenses.replace(BuiltList<ExpenseEntity>())

View File

@ -167,6 +167,12 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
'invoice_task_lock', 'invoice_task_lock',
serializers.serialize(object.invoiceTaskLock, serializers.serialize(object.invoiceTaskLock,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'convert_payment_currency',
serializers.serialize(object.convertPaymentCurrency,
specifiedType: const FullType(bool)),
'convert_expense_currency',
serializers.serialize(object.convertExpenseCurrency,
specifiedType: const FullType(bool)),
'groups', 'groups',
serializers.serialize(object.groups, serializers.serialize(object.groups,
specifiedType: specifiedType:
@ -594,6 +600,14 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
result.invoiceTaskLock = serializers.deserialize(value, result.invoiceTaskLock = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'convert_payment_currency':
result.convertPaymentCurrency = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'convert_expense_currency':
result.convertExpenseCurrency = 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(
@ -1661,6 +1675,10 @@ class _$CompanyEntity extends CompanyEntity {
@override @override
final bool invoiceTaskLock; final bool invoiceTaskLock;
@override @override
final bool convertPaymentCurrency;
@override
final bool convertExpenseCurrency;
@override
final BuiltList<GroupEntity> groups; final BuiltList<GroupEntity> groups;
@override @override
final BuiltList<ActivityEntity> activities; final BuiltList<ActivityEntity> activities;
@ -1829,6 +1847,8 @@ class _$CompanyEntity extends CompanyEntity {
this.stockNotificationThreshold, this.stockNotificationThreshold,
this.stockNotification, this.stockNotification,
this.invoiceTaskLock, this.invoiceTaskLock,
this.convertPaymentCurrency,
this.convertExpenseCurrency,
this.groups, this.groups,
this.activities, this.activities,
this.taxRates, this.taxRates,
@ -1976,6 +1996,10 @@ class _$CompanyEntity extends CompanyEntity {
stockNotification, 'CompanyEntity', 'stockNotification'); stockNotification, 'CompanyEntity', 'stockNotification');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
invoiceTaskLock, 'CompanyEntity', 'invoiceTaskLock'); invoiceTaskLock, 'CompanyEntity', 'invoiceTaskLock');
BuiltValueNullFieldError.checkNotNull(
convertPaymentCurrency, 'CompanyEntity', 'convertPaymentCurrency');
BuiltValueNullFieldError.checkNotNull(
convertExpenseCurrency, 'CompanyEntity', 'convertExpenseCurrency');
BuiltValueNullFieldError.checkNotNull(groups, 'CompanyEntity', 'groups'); BuiltValueNullFieldError.checkNotNull(groups, 'CompanyEntity', 'groups');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
activities, 'CompanyEntity', 'activities'); activities, 'CompanyEntity', 'activities');
@ -2133,6 +2157,8 @@ class _$CompanyEntity extends CompanyEntity {
stockNotificationThreshold == other.stockNotificationThreshold && stockNotificationThreshold == other.stockNotificationThreshold &&
stockNotification == other.stockNotification && stockNotification == other.stockNotification &&
invoiceTaskLock == other.invoiceTaskLock && invoiceTaskLock == other.invoiceTaskLock &&
convertPaymentCurrency == other.convertPaymentCurrency &&
convertExpenseCurrency == other.convertExpenseCurrency &&
groups == other.groups && groups == other.groups &&
activities == other.activities && activities == other.activities &&
taxRates == other.taxRates && taxRates == other.taxRates &&
@ -2216,7 +2242,7 @@ class _$CompanyEntity extends CompanyEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, enableCustomSurchargeTaxes1.hashCode), enableCustomSurchargeTaxes2.hashCode), enableCustomSurchargeTaxes3.hashCode), enableCustomSurchargeTaxes4.hashCode), sizeId.hashCode), industryId.hashCode), subdomain.hashCode), portalMode.hashCode), portalDomain.hashCode), updateProducts.hashCode), convertProductExchangeRate.hashCode), convertRateToClient.hashCode), fillProducts.hashCode), enableProductCost.hashCode), enableProductQuantity.hashCode), enableProductDiscount.hashCode), defaultTaskIsDateBased.hashCode), defaultQuantity.hashCode), showProductDetails.hashCode), clientCanRegister.hashCode), isLarge.hashCode), isDisabled.hashCode), enableShopApi.hashCode), companyKey.hashCode), firstDayOfWeek.hashCode), firstMonthOfYear.hashCode), numberOfInvoiceTaxRates.hashCode), numberOfItemTaxRates.hashCode), numberOfExpenseTaxRates.hashCode), expenseInclusiveTaxes.hashCode), sessionTimeout.hashCode), passwordTimeout.hashCode), oauthPasswordRequired.hashCode), markdownEnabled.hashCode), markdownEmailEnabled.hashCode), useCommaAsDecimalPlace.hashCode), reportIncludeDrafts.hashCode), reportIncludeDeleted.hashCode), useQuoteTermsOnConversion.hashCode), enableApplyingPayments.hashCode), trackInventory.hashCode), stockNotificationThreshold.hashCode), stockNotification.hashCode), invoiceTaskLock.hashCode), groups.hashCode), activities.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), companyGateways.hashCode), expenseCategories.hashCode), users.hashCode), clients.hashCode), products.hashCode), invoices.hashCode), recurringInvoices.hashCode), recurringExpenses.hashCode), payments.hashCode), quotes.hashCode), credits.hashCode), purchaseOrders.hashCode), bankAccounts.hashCode), transactions.hashCode), transactionRules.hashCode), tasks.hashCode), projects.hashCode), expenses.hashCode), vendors.hashCode), designs.hashCode), documents.hashCode), tokens.hashCode), webhooks.hashCode), subscriptions.hashCode), paymentTerms.hashCode), systemLogs.hashCode), clientRegistrationFields.hashCode), customFields.hashCode), slackWebhookUrl.hashCode), googleAnalyticsKey.hashCode), matomoUrl.hashCode), matomoId.hashCode), markExpensesInvoiceable.hashCode), markExpensesPaid.hashCode), invoiceExpenseDocuments.hashCode), invoiceTaskDocuments.hashCode), $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, enableCustomSurchargeTaxes1.hashCode), enableCustomSurchargeTaxes2.hashCode), enableCustomSurchargeTaxes3.hashCode), enableCustomSurchargeTaxes4.hashCode), sizeId.hashCode), industryId.hashCode), subdomain.hashCode), portalMode.hashCode), portalDomain.hashCode), updateProducts.hashCode), convertProductExchangeRate.hashCode), convertRateToClient.hashCode), fillProducts.hashCode), enableProductCost.hashCode), enableProductQuantity.hashCode), enableProductDiscount.hashCode), defaultTaskIsDateBased.hashCode), defaultQuantity.hashCode), showProductDetails.hashCode), clientCanRegister.hashCode), isLarge.hashCode), isDisabled.hashCode), enableShopApi.hashCode), companyKey.hashCode), firstDayOfWeek.hashCode), firstMonthOfYear.hashCode), numberOfInvoiceTaxRates.hashCode), numberOfItemTaxRates.hashCode), numberOfExpenseTaxRates.hashCode), expenseInclusiveTaxes.hashCode), sessionTimeout.hashCode), passwordTimeout.hashCode), oauthPasswordRequired.hashCode), markdownEnabled.hashCode), markdownEmailEnabled.hashCode), useCommaAsDecimalPlace.hashCode), reportIncludeDrafts.hashCode), reportIncludeDeleted.hashCode), useQuoteTermsOnConversion.hashCode), enableApplyingPayments.hashCode), trackInventory.hashCode), stockNotificationThreshold.hashCode), stockNotification.hashCode), invoiceTaskLock.hashCode), convertPaymentCurrency.hashCode), convertExpenseCurrency.hashCode), groups.hashCode), activities.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), companyGateways.hashCode), expenseCategories.hashCode), users.hashCode), clients.hashCode), products.hashCode), invoices.hashCode), recurringInvoices.hashCode), recurringExpenses.hashCode), payments.hashCode), quotes.hashCode), credits.hashCode), purchaseOrders.hashCode), bankAccounts.hashCode), transactions.hashCode), transactionRules.hashCode), tasks.hashCode), projects.hashCode), expenses.hashCode), vendors.hashCode), designs.hashCode), documents.hashCode), tokens.hashCode), webhooks.hashCode), subscriptions.hashCode), paymentTerms.hashCode), systemLogs.hashCode), clientRegistrationFields.hashCode), customFields.hashCode), slackWebhookUrl.hashCode), googleAnalyticsKey.hashCode), matomoUrl.hashCode), matomoId.hashCode), markExpensesInvoiceable.hashCode), markExpensesPaid.hashCode), invoiceExpenseDocuments.hashCode), invoiceTaskDocuments.hashCode),
invoiceTaskTimelog.hashCode), invoiceTaskTimelog.hashCode),
invoiceTaskDatelog.hashCode), invoiceTaskDatelog.hashCode),
invoiceTaskProject.hashCode), invoiceTaskProject.hashCode),
@ -2285,6 +2311,8 @@ class _$CompanyEntity extends CompanyEntity {
..add('stockNotificationThreshold', stockNotificationThreshold) ..add('stockNotificationThreshold', stockNotificationThreshold)
..add('stockNotification', stockNotification) ..add('stockNotification', stockNotification)
..add('invoiceTaskLock', invoiceTaskLock) ..add('invoiceTaskLock', invoiceTaskLock)
..add('convertPaymentCurrency', convertPaymentCurrency)
..add('convertExpenseCurrency', convertExpenseCurrency)
..add('groups', groups) ..add('groups', groups)
..add('activities', activities) ..add('activities', activities)
..add('taxRates', taxRates) ..add('taxRates', taxRates)
@ -2564,6 +2592,16 @@ class CompanyEntityBuilder
set invoiceTaskLock(bool invoiceTaskLock) => set invoiceTaskLock(bool invoiceTaskLock) =>
_$this._invoiceTaskLock = invoiceTaskLock; _$this._invoiceTaskLock = invoiceTaskLock;
bool _convertPaymentCurrency;
bool get convertPaymentCurrency => _$this._convertPaymentCurrency;
set convertPaymentCurrency(bool convertPaymentCurrency) =>
_$this._convertPaymentCurrency = convertPaymentCurrency;
bool _convertExpenseCurrency;
bool get convertExpenseCurrency => _$this._convertExpenseCurrency;
set convertExpenseCurrency(bool convertExpenseCurrency) =>
_$this._convertExpenseCurrency = convertExpenseCurrency;
ListBuilder<GroupEntity> _groups; ListBuilder<GroupEntity> _groups;
ListBuilder<GroupEntity> get groups => ListBuilder<GroupEntity> get groups =>
_$this._groups ??= new ListBuilder<GroupEntity>(); _$this._groups ??= new ListBuilder<GroupEntity>();
@ -2932,6 +2970,8 @@ class CompanyEntityBuilder
_stockNotificationThreshold = $v.stockNotificationThreshold; _stockNotificationThreshold = $v.stockNotificationThreshold;
_stockNotification = $v.stockNotification; _stockNotification = $v.stockNotification;
_invoiceTaskLock = $v.invoiceTaskLock; _invoiceTaskLock = $v.invoiceTaskLock;
_convertPaymentCurrency = $v.convertPaymentCurrency;
_convertExpenseCurrency = $v.convertExpenseCurrency;
_groups = $v.groups.toBuilder(); _groups = $v.groups.toBuilder();
_activities = $v.activities.toBuilder(); _activities = $v.activities.toBuilder();
_taxRates = $v.taxRates.toBuilder(); _taxRates = $v.taxRates.toBuilder();
@ -3072,6 +3112,8 @@ class CompanyEntityBuilder
stockNotificationThreshold: BuiltValueNullFieldError.checkNotNull(stockNotificationThreshold, 'CompanyEntity', 'stockNotificationThreshold'), stockNotificationThreshold: BuiltValueNullFieldError.checkNotNull(stockNotificationThreshold, 'CompanyEntity', 'stockNotificationThreshold'),
stockNotification: BuiltValueNullFieldError.checkNotNull(stockNotification, 'CompanyEntity', 'stockNotification'), stockNotification: BuiltValueNullFieldError.checkNotNull(stockNotification, 'CompanyEntity', 'stockNotification'),
invoiceTaskLock: BuiltValueNullFieldError.checkNotNull(invoiceTaskLock, 'CompanyEntity', 'invoiceTaskLock'), invoiceTaskLock: BuiltValueNullFieldError.checkNotNull(invoiceTaskLock, 'CompanyEntity', 'invoiceTaskLock'),
convertPaymentCurrency: BuiltValueNullFieldError.checkNotNull(convertPaymentCurrency, 'CompanyEntity', 'convertPaymentCurrency'),
convertExpenseCurrency: BuiltValueNullFieldError.checkNotNull(convertExpenseCurrency, 'CompanyEntity', 'convertExpenseCurrency'),
groups: groups.build(), groups: groups.build(),
activities: activities.build(), activities: activities.build(),
taxRates: taxRates.build(), taxRates: taxRates.build(),

View File

@ -70,6 +70,14 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..markExpensesPaid = value)), company.rebuild((b) => b..markExpensesPaid = value)),
), ),
SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.convertCurrencyHelp),
value: company.convertExpenseCurrency ?? false,
subtitle: Text(localization.convertExpenseCurrencyHelp),
onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..convertExpenseCurrency = value)),
),
SwitchListTile( SwitchListTile(
activeColor: Theme.of(context).colorScheme.secondary, activeColor: Theme.of(context).colorScheme.secondary,
title: Text(localization.addDocumentsToInvoice), title: Text(localization.addDocumentsToInvoice),

View File

@ -171,7 +171,7 @@ class _PaymentSettingsState extends State<PaymentSettings> {
), ),
SizedBox(height: 8), SizedBox(height: 8),
FormCard(children: [ FormCard(children: [
if (!state.uiState.settingsUIState.isFiltered) if (!state.uiState.settingsUIState.isFiltered) ...[
BoolDropdownButton( BoolDropdownButton(
label: localization.enableApplyingPaymentsLater, label: localization.enableApplyingPaymentsLater,
value: company.enableApplyingPayments, value: company.enableApplyingPayments,
@ -179,6 +179,14 @@ class _PaymentSettingsState extends State<PaymentSettings> {
onChanged: (value) => viewModel.onCompanyChanged( onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..enableApplyingPayments = value)), company.rebuild((b) => b..enableApplyingPayments = value)),
), ),
BoolDropdownButton(
label: localization.convertCurrency,
value: company.convertPaymentCurrency,
helpLabel: localization.convertPaymentCurrencyHelp,
onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild((b) => b..convertPaymentCurrency = value)),
),
],
BoolDropdownButton( BoolDropdownButton(
label: localization.allowOverPayment, label: localization.allowOverPayment,
value: settings.clientPortalAllowOverPayment, value: settings.clientPortalAllowOverPayment,

View File

@ -16,6 +16,10 @@ 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
'convert_payment_currency_help':
'Set an exchange rate when entering a manual payment',
'convert_expense_currency_help':
'Set an exchange rate when creating an expense',
'matomo_url': 'Matomo URL', 'matomo_url': 'Matomo URL',
'matomo_id': 'Matomo Id', 'matomo_id': 'Matomo Id',
'action_add_to_invoice': 'Add To Invoice', 'action_add_to_invoice': 'Add To Invoice',
@ -92367,6 +92371,14 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['matomo_id'] ?? _localizedValues[localeCode]['matomo_id'] ??
_localizedValues['en']['matomo_id']; _localizedValues['en']['matomo_id'];
String get convertPaymentCurrencyHelp =>
_localizedValues[localeCode]['convert_payment_currency_help'] ??
_localizedValues['en']['convert_payment_currency_help'];
String get convertExpenseCurrencyHelp =>
_localizedValues[localeCode]['convert_expense_currency_help'] ??
_localizedValues['en']['convert_expense_currency_help'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {