This commit is contained in:
Hillel Coren 2019-09-23 10:22:40 +03:00
parent a1cf8e30a4
commit 9780b7db3c
21 changed files with 1487 additions and 1489 deletions

View File

@ -18,38 +18,11 @@ abstract class CompanyEntity
settings: SettingsEntity(), settings: SettingsEntity(),
logoUrl: '', logoUrl: '',
appUrl: '', appUrl: '',
convertProductExchangeRate: false,
companyCurrencyId: '1', companyCurrencyId: '1',
dateFormatId: '1',
datetimeFormatId: '1',
defaultInvoiceDesignId: '1',
defaultInvoiceFooter: '',
defaultInvoiceTerms: '',
defaultPaymentTerms: 0,
defaultPaymentTypeId: '',
defaultQuoteDesignId: '1',
defaultQuoteTerms: '',
defaultTaskRate: 0.0,
defaultTaxName1: '',
defaultTaxRate1: 0.0,
defaultTaxName2: '',
defaultTaxRate2: 0.0,
enableCustomInvoiceTaxes1: false,
enableCustomInvoiceTaxes2: false,
enabledModules: 0, enabledModules: 0,
enableInclusiveTaxes: false,
enableInvoiceItemTaxes: false,
enableInvoiceTaxes: true,
enableMilitaryTime: false,
enableSecondTaxRate: false,
financialYearStart: 1, financialYearStart: 1,
languageId: kLanguageEnglish,
showCurrencyCode: false,
showInvoiceItemTaxes: false,
startOfWeek: 1, startOfWeek: 1,
timezoneId: '1', countryId: kCountryUnitedStates,
// TODO set to default EST timezone
customPaymentTerms: BuiltList<PaymentTermEntity>(),
taxRates: BuiltList<TaxRateEntity>(), taxRates: BuiltList<TaxRateEntity>(),
taskStatuses: BuiltList<TaskStatusEntity>(), taskStatuses: BuiltList<TaskStatusEntity>(),
taskStatusMap: BuiltMap<String, TaskStatusEntity>(), taskStatusMap: BuiltMap<String, TaskStatusEntity>(),
@ -58,26 +31,6 @@ abstract class CompanyEntity
users: BuiltList<UserEntity>(), users: BuiltList<UserEntity>(),
userMap: BuiltMap<String, UserEntity>(), userMap: BuiltMap<String, UserEntity>(),
customFields: BuiltMap<String, String>(), customFields: BuiltMap<String, String>(),
invoiceFields: '',
countryId: kCountryUnitedStates,
emailFooter: '',
emailSubjectInvoice: '',
emailSubjectQuote: '',
emailSubjectPayment: '',
emailBodyInvoice: '',
emailBodyQuote: '',
emailBodyPayment: '',
emailSubjectReminder1: '',
emailSubjectReminder2: '',
emailSubjectReminder3: '',
emailBodyReminder1: '',
emailBodyReminder2: '',
emailBodyReminder3: '',
fillProducts: true,
enablePortalPassword: false,
hasCustomDesign1: false,
hasCustomDesign2: false,
hasCustomDesign3: false,
); );
} }
@ -101,160 +54,16 @@ abstract class CompanyEntity
@BuiltValueField(wireName: 'default_url') @BuiltValueField(wireName: 'default_url')
String get appUrl; String get appUrl;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'currency_id')
String get companyCurrencyId;
SettingsEntity get settings;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'timezone_id')
String get timezoneId;
@BuiltValueField(wireName: 'country_id')
String get countryId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'date_format_id')
String get dateFormatId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'datetime_format_id')
String get datetimeFormatId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_terms')
String get defaultInvoiceTerms;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_taxes')
bool get enableInvoiceTaxes;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_item_taxes')
bool get enableInvoiceItemTaxes;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_design_id')
String get defaultInvoiceDesignId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'quote_design_id')
String get defaultQuoteDesignId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'language_id')
String get languageId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_footer')
String get defaultInvoiceFooter;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'show_item_taxes')
bool get showInvoiceItemTaxes;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'military_time')
bool get enableMilitaryTime;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_name1')
String get defaultTaxName1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_rate1')
double get defaultTaxRate1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_name2')
String get defaultTaxName2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_rate2')
double get defaultTaxRate2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'quote_terms')
String get defaultQuoteTerms;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'show_currency_code')
bool get showCurrencyCode;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'enable_second_tax_rate')
bool get enableSecondTaxRate;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'start_of_week') @BuiltValueField(wireName: 'start_of_week')
int get startOfWeek; int get startOfWeek;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'financial_year_start') @BuiltValueField(wireName: 'financial_year_start')
int get financialYearStart; int get financialYearStart;
// TODO remove this // TODO remove this
@nullable @nullable
@BuiltValueField(wireName: 'enabled_modules') @BuiltValueField(wireName: 'currency_id')
int get enabledModules; String get companyCurrencyId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'payment_terms')
int get defaultPaymentTerms;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'payment_type_id')
String get defaultPaymentTypeId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'task_rate')
double get defaultTaskRate;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'inclusive_taxes')
bool get enableInclusiveTaxes;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'convert_products')
bool get convertProductExchangeRate;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'custom_invoice_taxes1')
bool get enableCustomInvoiceTaxes1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'custom_invoice_taxes2')
bool get enableCustomInvoiceTaxes2;
// TODO remove this // TODO remove this
@nullable @nullable
@ -289,115 +98,19 @@ abstract class CompanyEntity
@BuiltValueField(wireName: 'custom_fields') @BuiltValueField(wireName: 'custom_fields')
BuiltMap<String, String> get customFields; BuiltMap<String, String> get customFields;
// TODO remove this SettingsEntity get settings;
@nullable
@BuiltValueField(wireName: 'custom_payment_terms') @BuiltValueField(wireName: 'country_id')
BuiltList<PaymentTermEntity> get customPaymentTerms; String get countryId;
// TODO remove this // TODO remove this
@nullable @nullable
@BuiltValueField(wireName: 'invoice_fields') @BuiltValueField(wireName: 'enabled_modules')
String get invoiceFields; int get enabledModules;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_footer')
String get emailFooter;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_subject_invoice')
String get emailSubjectInvoice;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_subject_quote')
String get emailSubjectQuote;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_subject_payment')
String get emailSubjectPayment;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_template_invoice')
String get emailBodyInvoice;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_template_quote')
String get emailBodyQuote;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_template_payment')
String get emailBodyPayment;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_subject_reminder1')
String get emailSubjectReminder1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_subject_reminder2')
String get emailSubjectReminder2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_subject_reminder3')
String get emailSubjectReminder3;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_template_reminder1')
String get emailBodyReminder1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_template_reminder2')
String get emailBodyReminder2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'email_template_reminder3')
String get emailBodyReminder3;
@nullable
@BuiltValueField(wireName: 'fill_products')
bool get fillProducts;
@nullable
@BuiltValueField(wireName: 'enable_portal_password')
bool get enablePortalPassword;
@nullable
@BuiltValueField(wireName: 'has_custom_design1')
bool get hasCustomDesign1;
@nullable
@BuiltValueField(wireName: 'has_custom_design2')
bool get hasCustomDesign2;
@nullable
@BuiltValueField(wireName: 'has_custom_design3')
bool get hasCustomDesign3;
//@BuiltValueField(wireName: 'custom_messages') //@BuiltValueField(wireName: 'custom_messages')
//@BuiltValueField(wireName: 'invoice_labels') //@BuiltValueField(wireName: 'invoice_labels')
bool hasInvoiceField(String field,
[EntityType entityType = EntityType.product]) {
if (invoiceFields.isNotEmpty) {
return invoiceFields.contains('$entityType.$field');
} else if (field == 'discount') {
return false;
} else {
return true;
}
}
String getCustomFieldLabel(String field) { String getCustomFieldLabel(String field) {
if (customFields.containsKey(field)) { if (customFields.containsKey(field)) {
return customFields[field].split('|').first; return customFields[field].split('|').first;
@ -629,16 +342,241 @@ abstract class SettingsEntity
implements Built<SettingsEntity, SettingsEntityBuilder> { implements Built<SettingsEntity, SettingsEntityBuilder> {
factory SettingsEntity() { factory SettingsEntity() {
return _$SettingsEntity._( return _$SettingsEntity._(
//timezoneId: '', // TODO set to default EST timezone
timezoneId: '',
convertProductExchangeRate: false,
dateFormatId: '1',
datetimeFormatId: '1',
defaultInvoiceDesignId: '1',
defaultInvoiceFooter: '',
defaultInvoiceTerms: '',
defaultPaymentTerms: 0,
defaultPaymentTypeId: '',
defaultQuoteDesignId: '1',
defaultQuoteTerms: '',
defaultTaskRate: 0,
defaultTaxName1: '',
defaultTaxRate1: 0,
defaultTaxName2: '',
defaultTaxRate2: 0,
enableCustomInvoiceTaxes1: false,
enableCustomInvoiceTaxes2: false,
enableInclusiveTaxes: false,
enableInvoiceItemTaxes: false,
enableInvoiceTaxes: true,
enableMilitaryTime: false,
enableSecondTaxRate: false,
languageId: kLanguageEnglish,
showCurrencyCode: false,
showInvoiceItemTaxes: false,
customPaymentTerms: BuiltList<PaymentTermEntity>(),
invoiceFields: '',
emailFooter: '',
emailSubjectInvoice: '',
emailSubjectQuote: '',
emailSubjectPayment: '',
emailBodyInvoice: '',
emailBodyQuote: '',
emailBodyPayment: '',
emailSubjectReminder1: '',
emailSubjectReminder2: '',
emailSubjectReminder3: '',
emailBodyReminder1: '',
emailBodyReminder2: '',
emailBodyReminder3: '',
fillProducts: true,
enablePortalPassword: false,
hasCustomDesign1: false,
hasCustomDesign2: false,
hasCustomDesign3: false,
); );
} }
SettingsEntity._(); SettingsEntity._();
@BuiltValueField(wireName: 'timezone_id') @BuiltValueField(wireName: 'timezone_id')
int get timezoneIdInt; String get timezoneId;
String get timezoneId => timezoneId.toString(); @BuiltValueField(wireName: 'date_format_id')
String get dateFormatId;
@BuiltValueField(wireName: 'datetime_format_id')
String get datetimeFormatId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_terms')
String get defaultInvoiceTerms;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_taxes')
bool get enableInvoiceTaxes;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_item_taxes')
bool get enableInvoiceItemTaxes;
@BuiltValueField(wireName: 'invoice_design_id')
String get defaultInvoiceDesignId;
@BuiltValueField(wireName: 'quote_design_id')
String get defaultQuoteDesignId;
@BuiltValueField(wireName: 'language_id')
String get languageId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_footer')
String get defaultInvoiceFooter;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'show_item_taxes')
bool get showInvoiceItemTaxes;
@BuiltValueField(wireName: 'military_time')
bool get enableMilitaryTime;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_name1')
String get defaultTaxName1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_rate1')
double get defaultTaxRate1;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_name2')
String get defaultTaxName2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'tax_rate2')
double get defaultTaxRate2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'quote_terms')
String get defaultQuoteTerms;
@BuiltValueField(wireName: 'show_currency_code')
bool get showCurrencyCode;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'enable_second_tax_rate')
bool get enableSecondTaxRate;
@BuiltValueField(wireName: 'payment_terms')
int get defaultPaymentTerms;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'payment_type_id')
String get defaultPaymentTypeId;
@BuiltValueField(wireName: 'default_task_rate')
double get defaultTaskRate;
@BuiltValueField(wireName: 'inclusive_taxes')
bool get enableInclusiveTaxes;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'convert_products')
bool get convertProductExchangeRate;
@BuiltValueField(wireName: 'custom_invoice_taxes1')
bool get enableCustomInvoiceTaxes1;
@BuiltValueField(wireName: 'custom_invoice_taxes2')
bool get enableCustomInvoiceTaxes2;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'custom_payment_terms')
BuiltList<PaymentTermEntity> get customPaymentTerms;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_fields')
String get invoiceFields;
@BuiltValueField(wireName: 'email_footer')
String get emailFooter;
@BuiltValueField(wireName: 'email_subject_invoice')
String get emailSubjectInvoice;
@BuiltValueField(wireName: 'email_subject_quote')
String get emailSubjectQuote;
@BuiltValueField(wireName: 'email_subject_payment')
String get emailSubjectPayment;
@BuiltValueField(wireName: 'email_template_invoice')
String get emailBodyInvoice;
@BuiltValueField(wireName: 'email_template_quote')
String get emailBodyQuote;
@BuiltValueField(wireName: 'email_template_payment')
String get emailBodyPayment;
@BuiltValueField(wireName: 'email_subject_reminder1')
String get emailSubjectReminder1;
@BuiltValueField(wireName: 'email_subject_reminder2')
String get emailSubjectReminder2;
@BuiltValueField(wireName: 'email_subject_reminder3')
String get emailSubjectReminder3;
@BuiltValueField(wireName: 'email_template_reminder1')
String get emailBodyReminder1;
@BuiltValueField(wireName: 'email_template_reminder2')
String get emailBodyReminder2;
@BuiltValueField(wireName: 'email_template_reminder3')
String get emailBodyReminder3;
@nullable
@BuiltValueField(wireName: 'fill_products')
bool get fillProducts;
@nullable
@BuiltValueField(wireName: 'enable_portal_password')
bool get enablePortalPassword;
@nullable
@BuiltValueField(wireName: 'has_custom_design1')
bool get hasCustomDesign1;
@nullable
@BuiltValueField(wireName: 'has_custom_design2')
bool get hasCustomDesign2;
@nullable
@BuiltValueField(wireName: 'has_custom_design3')
bool get hasCustomDesign3;
bool hasInvoiceField(String field,
[EntityType entityType = EntityType.product]) {
if (invoiceFields.isNotEmpty) {
return invoiceFields.contains('$entityType.$field');
} else if (field == 'discount') {
return false;
} else {
return true;
}
}
static Serializer<SettingsEntity> get serializer => static Serializer<SettingsEntity> get serializer =>
_$settingsEntitySerializer; _$settingsEntitySerializer;

File diff suppressed because it is too large Load Diff

View File

@ -110,10 +110,10 @@ abstract class InvoiceEntity extends Object
endDate: '', endDate: '',
lastSentDate: '', lastSentDate: '',
recurringInvoiceId: '', recurringInvoiceId: '',
taxName1: company?.defaultTaxName1 ?? '', taxName1: company?.settings?.defaultTaxName1 ?? '',
taxRate1: company?.defaultTaxRate1 ?? 0.0, taxRate1: company?.settings?.defaultTaxRate1 ?? 0.0,
taxName2: company?.defaultTaxName2 ?? '', taxName2: company?.settings?.defaultTaxName2 ?? '',
taxRate2: company?.defaultTaxRate2 ?? 0.0, taxRate2: company?.settings?.defaultTaxRate2 ?? 0.0,
isAmountDiscount: false, isAmountDiscount: false,
invoiceFooter: '', invoiceFooter: '',
partial: 0.0, partial: 0.0,
@ -137,8 +137,8 @@ abstract class InvoiceEntity extends Object
isDeleted: false, isDeleted: false,
designId: company != null designId: company != null
? (isQuote ? (isQuote
? company.defaultQuoteDesignId ? company.settings.defaultQuoteDesignId
: company.defaultInvoiceDesignId) : company.settings.defaultInvoiceDesignId)
: 1, : 1,
); );
} }

View File

@ -60,9 +60,9 @@ abstract class PaymentEntity extends Object
amount: 0.0, amount: 0.0,
transactionReference: '', transactionReference: '',
paymentDate: convertDateTimeToSqlDate(), paymentDate: convertDateTimeToSqlDate(),
paymentTypeId: paymentTypeId: company != null &&
company != null && (company.defaultPaymentTypeId ?? '').isNotEmpty (company.settings.defaultPaymentTypeId ?? '').isNotEmpty
? company.defaultPaymentTypeId ? company.settings.defaultPaymentTypeId
: '', : '',
invoiceId: '', invoiceId: '',
clientId: '', clientId: '',

View File

@ -271,6 +271,9 @@ Serializers _$serializers = (new Serializers().toBuilder()
..addBuilderFactory( ..addBuilderFactory(
const FullType(BuiltList, const [const FullType(PaymentEntity)]), const FullType(BuiltList, const [const FullType(PaymentEntity)]),
() => new ListBuilder<PaymentEntity>()) () => new ListBuilder<PaymentEntity>())
..addBuilderFactory(
const FullType(BuiltList, const [const FullType(PaymentTermEntity)]),
() => new ListBuilder<PaymentTermEntity>())
..addBuilderFactory( ..addBuilderFactory(
const FullType(BuiltList, const [const FullType(PaymentTypeEntity)]), const FullType(BuiltList, const [const FullType(PaymentTypeEntity)]),
() => new ListBuilder<PaymentTypeEntity>()) () => new ListBuilder<PaymentTypeEntity>())
@ -301,10 +304,8 @@ Serializers _$serializers = (new Serializers().toBuilder()
BuiltList, const [const FullType(ExpenseCategoryEntity)]), BuiltList, const [const FullType(ExpenseCategoryEntity)]),
() => new ListBuilder<ExpenseCategoryEntity>()) () => new ListBuilder<ExpenseCategoryEntity>())
..addBuilderFactory( ..addBuilderFactory(
const FullType(BuiltMap, const [ const FullType(BuiltMap,
const FullType(String), const [const FullType(String), const FullType(ExpenseCategoryEntity)]),
const FullType(ExpenseCategoryEntity)
]),
() => new MapBuilder<String, ExpenseCategoryEntity>()) () => new MapBuilder<String, ExpenseCategoryEntity>())
..addBuilderFactory( ..addBuilderFactory(
const FullType(BuiltList, const [const FullType(UserEntity)]), const FullType(BuiltList, const [const FullType(UserEntity)]),
@ -317,9 +318,6 @@ Serializers _$serializers = (new Serializers().toBuilder()
const FullType( const FullType(
BuiltMap, const [const FullType(String), const FullType(String)]), BuiltMap, const [const FullType(String), const FullType(String)]),
() => new MapBuilder<String, String>()) () => new MapBuilder<String, String>())
..addBuilderFactory(
const FullType(BuiltList, const [const FullType(PaymentTermEntity)]),
() => new ListBuilder<PaymentTermEntity>())
..addBuilderFactory( ..addBuilderFactory(
const FullType(BuiltList, const [const FullType(TimezoneEntity)]), const FullType(BuiltList, const [const FullType(TimezoneEntity)]),
() => new ListBuilder<TimezoneEntity>()) () => new ListBuilder<TimezoneEntity>())
@ -334,7 +332,8 @@ Serializers _$serializers = (new Serializers().toBuilder()
const FullType(BuiltList, const [const FullType(VendorEntity)]), const FullType(BuiltList, const [const FullType(VendorEntity)]),
() => new ListBuilder<VendorEntity>()) () => new ListBuilder<VendorEntity>())
..addBuilderFactory( ..addBuilderFactory(
const FullType(BuiltMap, const [const FullType(String), const FullType(ClientEntity)]), const FullType(BuiltMap,
const [const FullType(String), const FullType(ClientEntity)]),
() => new MapBuilder<String, ClientEntity>()) () => new MapBuilder<String, ClientEntity>())
..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>()) ..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>())
..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(CurrencyEntity)]), () => new MapBuilder<String, CurrencyEntity>()) ..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(CurrencyEntity)]), () => new MapBuilder<String, CurrencyEntity>())

View File

@ -126,7 +126,7 @@ List<CompanyEntity> companiesSelector(AppState state) {
String localeSelector(AppState state) { String localeSelector(AppState state) {
final locale = state.staticState final locale = state.staticState
?.languageMap[state.selectedCompany?.languageId]?.locale ?? ?.languageMap[state.selectedCompany?.settings?.languageId]?.locale ??
'en'; 'en';
// https://github.com/flutter/flutter/issues/32090 // https://github.com/flutter/flutter/issues/32090

View File

@ -148,8 +148,8 @@ double taskRateSelector(
return project.taskRate; return project.taskRate;
} else if (client != null && client.taskRate > 0) { } else if (client != null && client.taskRate > 0) {
return client.taskRate; return client.taskRate;
} else if (company != null && company.defaultTaskRate > 0) { } else if (company != null && company.settings.defaultTaskRate > 0) {
return company.defaultTaskRate; return company.settings.defaultTaskRate;
} }
return 0; return 0;

View File

@ -75,24 +75,24 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView> {
switch (template) { switch (template) {
case EmailTemplate.initial: case EmailTemplate.initial:
if (viewModel.invoice.isQuote) { if (viewModel.invoice.isQuote) {
emailSubject = company.emailSubjectQuote; emailSubject = company.settings.emailSubjectQuote;
emailBody = company.emailBodyQuote; emailBody = company.settings.emailBodyQuote;
} else { } else {
emailSubject = company.emailSubjectInvoice; emailSubject = company.settings.emailSubjectInvoice;
emailBody = company.emailBodyInvoice; emailBody = company.settings.emailBodyInvoice;
} }
break; break;
case EmailTemplate.reminder1: case EmailTemplate.reminder1:
emailSubject = company.emailSubjectReminder1; emailSubject = company.settings.emailSubjectReminder1;
emailBody = company.emailBodyReminder1; emailBody = company.settings.emailBodyReminder1;
break; break;
case EmailTemplate.reminder2: case EmailTemplate.reminder2:
emailSubject = company.emailSubjectReminder2; emailSubject = company.settings.emailSubjectReminder2;
emailBody = company.emailBodyReminder2; emailBody = company.settings.emailBodyReminder2;
break; break;
case EmailTemplate.reminder3: case EmailTemplate.reminder3:
emailSubject = company.emailSubjectReminder3; emailSubject = company.settings.emailSubjectReminder3;
emailBody = company.emailBodyReminder3; emailBody = company.settings.emailBodyReminder3;
break; break;
} }

View File

@ -314,7 +314,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
? localization.emailIsInvalid ? localization.emailIsInvalid
: null, : null,
), ),
company.enablePortalPassword ?? false company.settings.enablePortalPassword ?? false
? TextFormField( ? TextFormField(
autocorrect: false, autocorrect: false,
controller: _passwordController, controller: _passwordController,

View File

@ -107,7 +107,7 @@ class ClientEditSettingsState extends State<ClientEditSettings> {
initialValue: null, initialValue: null,
itemBuilder: (BuildContext context) => (<int>[] itemBuilder: (BuildContext context) => (<int>[]
..addAll(kPaymentTerms) ..addAll(kPaymentTerms)
..addAll(viewModel.company.customPaymentTerms ..addAll(viewModel.company.settings.customPaymentTerms
.map((paymentTerm) => paymentTerm.numDays)) .map((paymentTerm) => paymentTerm.numDays))
..sort((a, b) => a.abs() - b.abs())) ..sort((a, b) => a.abs() - b.abs()))
.map((int numDays) => .map((int numDays) =>

View File

@ -35,7 +35,8 @@ class ClientOverview extends StatelessWidget {
final statics = state.staticState; final statics = state.staticState;
final fields = <String, String>{}; final fields = <String, String>{};
if (client.hasLanguage && client.languageId != company.languageId) { if (client.hasLanguage &&
client.languageId != company.settings.languageId) {
fields[ClientFields.language] = fields[ClientFields.language] =
statics.languageMap[client.languageId]?.name; statics.languageMap[client.languageId]?.name;
} }

View File

@ -118,7 +118,7 @@ class ExpenseEditSettingsState extends State<ExpenseEditSettings> {
initialTaxName: expense.taxName1, initialTaxName: expense.taxName1,
initialTaxRate: expense.taxRate1, initialTaxRate: expense.taxRate1,
), ),
company.enableSecondTaxRate company.settings.enableSecondTaxRate
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) => onSelected: (taxRate) =>

View File

@ -139,7 +139,7 @@ class _InvoiceEditState extends State<InvoiceEdit>
child: Padding( child: Padding(
padding: const EdgeInsets.all(14.0), padding: const EdgeInsets.all(14.0),
child: Text( child: Text(
'${localization.total}: ${formatNumber(invoice.calculateTotal(viewModel.company.enableInclusiveTaxes), context, clientId: viewModel.invoice.clientId)}', '${localization.total}: ${formatNumber(invoice.calculateTotal(viewModel.company.settings.enableInclusiveTaxes), context, clientId: viewModel.invoice.clientId)}',
style: TextStyle( style: TextStyle(
//color: Theme.of(context).selectedRowColor, //color: Theme.of(context).selectedRowColor,
color: Colors.white, color: Colors.white,

View File

@ -117,13 +117,13 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
final company = viewModel.company; final company = viewModel.company;
var designs = new List<String>.from(kInvoiceDesigns); var designs = new List<String>.from(kInvoiceDesigns);
if (!(company.hasCustomDesign1 ?? true)) { if (!(company.settings.hasCustomDesign1 ?? true)) {
designs.remove(kDesignCustom1); designs.remove(kDesignCustom1);
} }
if (!(company.hasCustomDesign2 ?? true)) { if (!(company.settings.hasCustomDesign2 ?? true)) {
designs.remove(kDesignCustom2); designs.remove(kDesignCustom2);
} }
if (!(company.hasCustomDesign3 ?? true)) { if (!(company.settings.hasCustomDesign3 ?? true)) {
designs.remove(kDesignCustom3); designs.remove(kDesignCustom3);
} }
if (!company.isProPlan) { if (!company.isProPlan) {
@ -277,7 +277,7 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
TextInputType.numberWithOptions(decimal: true), TextInputType.numberWithOptions(decimal: true),
) )
: Container(), : Container(),
company.enableInvoiceTaxes company.settings.enableInvoiceTaxes
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) => onSelected: (taxRate) =>
@ -287,7 +287,8 @@ class InvoiceEditDetailsState extends State<InvoiceEditDetails> {
initialTaxRate: invoice.taxRate1, initialTaxRate: invoice.taxRate1,
) )
: Container(), : Container(),
company.enableInvoiceTaxes && company.enableSecondTaxRate company.settings.enableInvoiceTaxes &&
company.settings.enableSecondTaxRate
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) => viewModel onSelected: (taxRate) => viewModel

View File

@ -242,7 +242,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
controller: _costController, controller: _costController,
keyboardType: TextInputType.numberWithOptions(decimal: true), keyboardType: TextInputType.numberWithOptions(decimal: true),
), ),
company.hasInvoiceField('quantity') company.settings.hasInvoiceField('quantity')
? DecoratedFormField( ? DecoratedFormField(
label: localization.quantity, label: localization.quantity,
controller: _qtyController, controller: _qtyController,
@ -250,7 +250,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
TextInputType.numberWithOptions(decimal: true), TextInputType.numberWithOptions(decimal: true),
) )
: Container(), : Container(),
company.hasInvoiceField('discount') company.settings.hasInvoiceField('discount')
? DecoratedFormField( ? DecoratedFormField(
label: localization.discount, label: localization.discount,
controller: _discountController, controller: _discountController,
@ -258,7 +258,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
TextInputType.numberWithOptions(decimal: true), TextInputType.numberWithOptions(decimal: true),
) )
: Container(), : Container(),
company.enableInvoiceItemTaxes company.settings.enableInvoiceItemTaxes
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) { onSelected: (taxRate) {
@ -270,7 +270,8 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
initialTaxRate: invoiceItem.taxRate1, initialTaxRate: invoiceItem.taxRate1,
) )
: Container(), : Container(),
company.enableInvoiceItemTaxes && company.enableSecondTaxRate company.settings.enableInvoiceItemTaxes &&
company.settings.enableSecondTaxRate
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) { onSelected: (taxRate) {

View File

@ -65,7 +65,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
_selected.forEach((entity) { _selected.forEach((entity) {
if (entity.entityType == EntityType.product) { if (entity.entityType == EntityType.product) {
final product = entity as ProductEntity; final product = entity as ProductEntity;
if (state.selectedCompany.fillProducts ?? true) { if (state.selectedCompany.settings.fillProducts ?? true) {
items.add( items.add(
convertProductToInvoiceItem(product: product, context: context)); convertProductToInvoiceItem(product: product, context: context));
} else { } else {

View File

@ -208,31 +208,35 @@ class InvoiceOverview extends StatelessWidget {
); );
} }
if (invoice.customValue1 != 0 && company.enableCustomInvoiceTaxes1) { if (invoice.customValue1 != 0 &&
company.settings.enableCustomInvoiceTaxes1) {
widgets.add(surchargeRow( widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge1), company.getCustomFieldLabel(CustomFieldType.surcharge1),
invoice.customValue1)); invoice.customValue1));
} }
if (invoice.customValue2 != 0 && company.enableCustomInvoiceTaxes2) { if (invoice.customValue2 != 0 &&
company.settings.enableCustomInvoiceTaxes2) {
widgets.add(surchargeRow( widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge2), company.getCustomFieldLabel(CustomFieldType.surcharge2),
invoice.customValue2)); invoice.customValue2));
} }
invoice invoice
.calculateTaxes(company.enableInclusiveTaxes) .calculateTaxes(company.settings.enableInclusiveTaxes)
.forEach((taxName, taxAmount) { .forEach((taxName, taxAmount) {
widgets.add(surchargeRow(taxName, taxAmount)); widgets.add(surchargeRow(taxName, taxAmount));
}); });
if (invoice.customValue1 != 0 && !company.enableCustomInvoiceTaxes1) { if (invoice.customValue1 != 0 &&
!company.settings.enableCustomInvoiceTaxes1) {
widgets.add(surchargeRow( widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge1), company.getCustomFieldLabel(CustomFieldType.surcharge1),
invoice.customValue1)); invoice.customValue1));
} }
if (invoice.customValue2 != 0 && !company.enableCustomInvoiceTaxes2) { if (invoice.customValue2 != 0 &&
!company.settings.enableCustomInvoiceTaxes2) {
widgets.add(surchargeRow( widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge2), company.getCustomFieldLabel(CustomFieldType.surcharge2),
invoice.customValue2)); invoice.customValue2));

View File

@ -182,7 +182,7 @@ class _ProductEditState extends State<ProductEdit> {
keyboardType: keyboardType:
TextInputType.numberWithOptions(decimal: true), TextInputType.numberWithOptions(decimal: true),
), ),
company.enableInvoiceItemTaxes company.settings.enableInvoiceItemTaxes
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) => onSelected: (taxRate) =>
@ -194,7 +194,8 @@ class _ProductEditState extends State<ProductEdit> {
initialTaxRate: product.taxRate1, initialTaxRate: product.taxRate1,
) )
: Container(), : Container(),
company.enableInvoiceItemTaxes && company.enableSecondTaxRate company.settings.enableInvoiceItemTaxes &&
company.settings.enableSecondTaxRate
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,
onSelected: (taxRate) => onSelected: (taxRate) =>

View File

@ -303,7 +303,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
? localization.emailIsInvalid ? localization.emailIsInvalid
: null, : null,
), ),
company.enablePortalPassword ?? false company.settings.enablePortalPassword ?? false
? TextFormField( ? TextFormField(
autocorrect: false, autocorrect: false,
controller: _passwordController, controller: _passwordController,

View File

@ -134,7 +134,7 @@ String formatNumber(
if (formatNumberType == FormatNumberType.percent) { if (formatNumberType == FormatNumberType.percent) {
return '$formatted%'; return '$formatted%';
} else if (company.showCurrencyCode || currency.symbol.isEmpty) { } else if (company.settings.showCurrencyCode || currency.symbol.isEmpty) {
return '$formatted ${currency.code}'; return '$formatted ${currency.code}';
} else if (swapCurrencySymbol) { } else if (swapCurrencySymbol) {
return '$formatted ${currency.symbol.trim()}'; return '$formatted ${currency.symbol.trim()}';
@ -247,15 +247,15 @@ String formatDate(String value, BuildContext context,
String format; String format;
if (!showDate) { if (!showDate) {
format = showSeconds format = showSeconds
? company.enableMilitaryTime ? 'H:mm:ss' : 'h:mm:ss a' ? company.settings.enableMilitaryTime ? 'H:mm:ss' : 'h:mm:ss a'
: company.enableMilitaryTime ? 'H:mm' : 'h:mm a'; : company.settings.enableMilitaryTime ? 'H:mm' : 'h:mm a';
} else { } else {
final dateFormats = state.staticState.datetimeFormatMap; final dateFormats = state.staticState.datetimeFormatMap;
final dateFormatId = (company.datetimeFormatId ?? '').isNotEmpty final dateFormatId = (company.settings.datetimeFormatId ?? '').isNotEmpty
? company.datetimeFormatId ? company.settings.datetimeFormatId
: kDefaultDateTimeFormat; : kDefaultDateTimeFormat;
format = dateFormats[dateFormatId].format; format = dateFormats[dateFormatId].format;
if (company.enableMilitaryTime) { if (company.settings.enableMilitaryTime) {
format = showSeconds format = showSeconds
? format.replaceFirst('h:mm:ss a', 'H:mm:ss') ? format.replaceFirst('h:mm:ss a', 'H:mm:ss')
: format.replaceFirst('h:mm a', 'H:mm'); : format.replaceFirst('h:mm a', 'H:mm');
@ -266,7 +266,8 @@ String formatDate(String value, BuildContext context,
} else { } else {
final dateFormats = state.staticState.dateFormatMap; final dateFormats = state.staticState.dateFormatMap;
final formatter = DateFormat( final formatter = DateFormat(
dateFormats[company.dateFormatId].format, localeSelector(state)); dateFormats[company.settings.dateFormatId].format,
localeSelector(state));
return formatter.format(DateTime.tryParse(value)); return formatter.format(DateTime.tryParse(value));
} }
} }

View File

@ -23,8 +23,8 @@ String processTemplate(
const String sampleLink = 'https://example.com/...'; const String sampleLink = 'https://example.com/...';
template = template template = template
.replaceAll('\$footer', company.emailFooter) .replaceAll('\$footer', company.settings.emailFooter)
.replaceAll('\$emailSignature', company.emailFooter) .replaceAll('\$emailSignature', company.settings.emailFooter)
.replaceAll('\$client', client.displayName) .replaceAll('\$client', client.displayName)
.replaceAll('\$idNumber', client.idNumber) .replaceAll('\$idNumber', client.idNumber)
.replaceAll('\$vatNumber', client.vatNumber) .replaceAll('\$vatNumber', client.vatNumber)