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(),
logoUrl: '',
appUrl: '',
convertProductExchangeRate: false,
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,
enableInclusiveTaxes: false,
enableInvoiceItemTaxes: false,
enableInvoiceTaxes: true,
enableMilitaryTime: false,
enableSecondTaxRate: false,
financialYearStart: 1,
languageId: kLanguageEnglish,
showCurrencyCode: false,
showInvoiceItemTaxes: false,
startOfWeek: 1,
timezoneId: '1',
// TODO set to default EST timezone
customPaymentTerms: BuiltList<PaymentTermEntity>(),
countryId: kCountryUnitedStates,
taxRates: BuiltList<TaxRateEntity>(),
taskStatuses: BuiltList<TaskStatusEntity>(),
taskStatusMap: BuiltMap<String, TaskStatusEntity>(),
@ -58,26 +31,6 @@ abstract class CompanyEntity
users: BuiltList<UserEntity>(),
userMap: BuiltMap<String, UserEntity>(),
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')
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')
int get startOfWeek;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'financial_year_start')
int get financialYearStart;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'enabled_modules')
int get enabledModules;
// 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;
@BuiltValueField(wireName: 'currency_id')
String get companyCurrencyId;
// TODO remove this
@nullable
@ -289,115 +98,19 @@ abstract class CompanyEntity
@BuiltValueField(wireName: 'custom_fields')
BuiltMap<String, String> get customFields;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'custom_payment_terms')
BuiltList<PaymentTermEntity> get customPaymentTerms;
SettingsEntity get settings;
@BuiltValueField(wireName: 'country_id')
String get countryId;
// TODO remove this
@nullable
@BuiltValueField(wireName: 'invoice_fields')
String get invoiceFields;
// 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: 'enabled_modules')
int get enabledModules;
//@BuiltValueField(wireName: 'custom_messages')
//@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) {
if (customFields.containsKey(field)) {
return customFields[field].split('|').first;
@ -629,16 +342,241 @@ abstract class SettingsEntity
implements Built<SettingsEntity, SettingsEntityBuilder> {
factory 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._();
@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 =>
_$settingsEntitySerializer;

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -139,7 +139,7 @@ class _InvoiceEditState extends State<InvoiceEdit>
child: Padding(
padding: const EdgeInsets.all(14.0),
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(
//color: Theme.of(context).selectedRowColor,
color: Colors.white,

View File

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

View File

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

View File

@ -65,7 +65,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
_selected.forEach((entity) {
if (entity.entityType == EntityType.product) {
final product = entity as ProductEntity;
if (state.selectedCompany.fillProducts ?? true) {
if (state.selectedCompany.settings.fillProducts ?? true) {
items.add(
convertProductToInvoiceItem(product: product, context: context));
} 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(
company.getCustomFieldLabel(CustomFieldType.surcharge1),
invoice.customValue1));
}
if (invoice.customValue2 != 0 && company.enableCustomInvoiceTaxes2) {
if (invoice.customValue2 != 0 &&
company.settings.enableCustomInvoiceTaxes2) {
widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge2),
invoice.customValue2));
}
invoice
.calculateTaxes(company.enableInclusiveTaxes)
.calculateTaxes(company.settings.enableInclusiveTaxes)
.forEach((taxName, taxAmount) {
widgets.add(surchargeRow(taxName, taxAmount));
});
if (invoice.customValue1 != 0 && !company.enableCustomInvoiceTaxes1) {
if (invoice.customValue1 != 0 &&
!company.settings.enableCustomInvoiceTaxes1) {
widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge1),
invoice.customValue1));
}
if (invoice.customValue2 != 0 && !company.enableCustomInvoiceTaxes2) {
if (invoice.customValue2 != 0 &&
!company.settings.enableCustomInvoiceTaxes2) {
widgets.add(surchargeRow(
company.getCustomFieldLabel(CustomFieldType.surcharge2),
invoice.customValue2));

View File

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

View File

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

View File

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

View File

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