Show/hide qty and discount

This commit is contained in:
unknown 2018-07-08 00:14:41 +03:00
parent 311e9d14af
commit ba3665b086
3 changed files with 63 additions and 28 deletions

View File

@ -47,6 +47,7 @@ abstract class CompanyEntity implements Built<CompanyEntity, CompanyEntityBuilde
timezoneId: 1, timezoneId: 1,
taxRates: BuiltList<TaxRateEntity>(), taxRates: BuiltList<TaxRateEntity>(),
customFields: BuiltMap<String, String>(), customFields: BuiltMap<String, String>(),
invoiceFields: '',
); );
} }
CompanyEntity._(); CompanyEntity._();
@ -158,8 +159,21 @@ abstract class CompanyEntity implements Built<CompanyEntity, CompanyEntityBuilde
@BuiltValueField(wireName: 'custom_fields') @BuiltValueField(wireName: 'custom_fields')
BuiltMap<String, String> get customFields; BuiltMap<String, String> get customFields;
@BuiltValueField(wireName: 'invoice_fields')
String get invoiceFields;
//@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] return customFields[field]

View File

@ -140,6 +140,9 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
serializers.serialize(object.customFields, serializers.serialize(object.customFields,
specifiedType: const FullType(BuiltMap, specifiedType: const FullType(BuiltMap,
const [const FullType(String), const FullType(String)])), const [const FullType(String), const FullType(String)])),
'invoice_fields',
serializers.serialize(object.invoiceFields,
specifiedType: const FullType(String)),
]; ];
return result; return result;
@ -309,6 +312,10 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
const FullType(String) const FullType(String)
])) as BuiltMap); ])) as BuiltMap);
break; break;
case 'invoice_fields':
result.invoiceFields = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
} }
} }
@ -463,6 +470,8 @@ class _$CompanyEntity extends CompanyEntity {
final BuiltList<TaxRateEntity> taxRates; final BuiltList<TaxRateEntity> taxRates;
@override @override
final BuiltMap<String, String> customFields; final BuiltMap<String, String> customFields;
@override
final String invoiceFields;
factory _$CompanyEntity([void updates(CompanyEntityBuilder b)]) => factory _$CompanyEntity([void updates(CompanyEntityBuilder b)]) =>
(new CompanyEntityBuilder()..update(updates)).build(); (new CompanyEntityBuilder()..update(updates)).build();
@ -504,7 +513,8 @@ class _$CompanyEntity extends CompanyEntity {
this.enableCustomInvoiceTaxes1, this.enableCustomInvoiceTaxes1,
this.enableCustomInvoiceTaxes2, this.enableCustomInvoiceTaxes2,
this.taxRates, this.taxRates,
this.customFields}) this.customFields,
this.invoiceFields})
: super._() { : super._() {
if (name == null) if (name == null)
throw new BuiltValueNullFieldError('CompanyEntity', 'name'); throw new BuiltValueNullFieldError('CompanyEntity', 'name');
@ -593,6 +603,8 @@ class _$CompanyEntity extends CompanyEntity {
throw new BuiltValueNullFieldError('CompanyEntity', 'taxRates'); throw new BuiltValueNullFieldError('CompanyEntity', 'taxRates');
if (customFields == null) if (customFields == null)
throw new BuiltValueNullFieldError('CompanyEntity', 'customFields'); throw new BuiltValueNullFieldError('CompanyEntity', 'customFields');
if (invoiceFields == null)
throw new BuiltValueNullFieldError('CompanyEntity', 'invoiceFields');
} }
@override @override
@ -642,7 +654,8 @@ class _$CompanyEntity extends CompanyEntity {
enableCustomInvoiceTaxes1 == other.enableCustomInvoiceTaxes1 && enableCustomInvoiceTaxes1 == other.enableCustomInvoiceTaxes1 &&
enableCustomInvoiceTaxes2 == other.enableCustomInvoiceTaxes2 && enableCustomInvoiceTaxes2 == other.enableCustomInvoiceTaxes2 &&
taxRates == other.taxRates && taxRates == other.taxRates &&
customFields == other.customFields; customFields == other.customFields &&
invoiceFields == other.invoiceFields;
} }
@override @override
@ -665,26 +678,26 @@ 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(0, name.hashCode), token.hashCode), plan.hashCode), logoUrl.hashCode), currencyId.hashCode), timezoneId.hashCode), countryId.hashCode), dateFormatId.hashCode), datetimeFormatId.hashCode), defaultInvoiceTerms.hashCode), enableInvoiceTaxes.hashCode), enableInvoiceItemTaxes.hashCode), defaultInvoiceDesignId.hashCode), defaultQuoteDesignId.hashCode), languageId.hashCode), defaultInvoiceFooter.hashCode), showInvoiceItemTaxes.hashCode), enableMilitaryTime.hashCode), $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, name.hashCode), token.hashCode), plan.hashCode), logoUrl.hashCode), currencyId.hashCode), timezoneId.hashCode), countryId.hashCode), dateFormatId.hashCode), datetimeFormatId.hashCode), defaultInvoiceTerms.hashCode), enableInvoiceTaxes.hashCode), enableInvoiceItemTaxes.hashCode), defaultInvoiceDesignId.hashCode), defaultQuoteDesignId.hashCode), languageId.hashCode), defaultInvoiceFooter.hashCode), showInvoiceItemTaxes.hashCode), enableMilitaryTime.hashCode), defaultTaxName1.hashCode),
defaultTaxName1.hashCode), defaultTaxRate1.hashCode),
defaultTaxRate1.hashCode), defaultTaxName2.hashCode),
defaultTaxName2.hashCode), defaultTaxRate2.hashCode),
defaultTaxRate2.hashCode), defaultQuoteTerms.hashCode),
defaultQuoteTerms.hashCode), showCurrencyCode.hashCode),
showCurrencyCode.hashCode), enableSecondTaxRate.hashCode),
enableSecondTaxRate.hashCode), startOfWeek.hashCode),
startOfWeek.hashCode), financialYearStart.hashCode),
financialYearStart.hashCode), enabledModules.hashCode),
enabledModules.hashCode), defaultPaymentTerms.hashCode),
defaultPaymentTerms.hashCode), defaultPaymentTypeId.hashCode),
defaultPaymentTypeId.hashCode), defaultTaskRate.hashCode),
defaultTaskRate.hashCode), enableInclusiveTaxes.hashCode),
enableInclusiveTaxes.hashCode), convertProductExchangeRate.hashCode),
convertProductExchangeRate.hashCode), enableCustomInvoiceTaxes1.hashCode),
enableCustomInvoiceTaxes1.hashCode), enableCustomInvoiceTaxes2.hashCode),
enableCustomInvoiceTaxes2.hashCode), taxRates.hashCode),
taxRates.hashCode), customFields.hashCode),
customFields.hashCode)); invoiceFields.hashCode));
} }
@override @override
@ -726,7 +739,8 @@ class _$CompanyEntity extends CompanyEntity {
..add('enableCustomInvoiceTaxes1', enableCustomInvoiceTaxes1) ..add('enableCustomInvoiceTaxes1', enableCustomInvoiceTaxes1)
..add('enableCustomInvoiceTaxes2', enableCustomInvoiceTaxes2) ..add('enableCustomInvoiceTaxes2', enableCustomInvoiceTaxes2)
..add('taxRates', taxRates) ..add('taxRates', taxRates)
..add('customFields', customFields)) ..add('customFields', customFields)
..add('invoiceFields', invoiceFields))
.toString(); .toString();
} }
} }
@ -912,6 +926,11 @@ class CompanyEntityBuilder
set customFields(MapBuilder<String, String> customFields) => set customFields(MapBuilder<String, String> customFields) =>
_$this._customFields = customFields; _$this._customFields = customFields;
String _invoiceFields;
String get invoiceFields => _$this._invoiceFields;
set invoiceFields(String invoiceFields) =>
_$this._invoiceFields = invoiceFields;
CompanyEntityBuilder(); CompanyEntityBuilder();
CompanyEntityBuilder get _$this { CompanyEntityBuilder get _$this {
@ -953,6 +972,7 @@ class CompanyEntityBuilder
_enableCustomInvoiceTaxes2 = _$v.enableCustomInvoiceTaxes2; _enableCustomInvoiceTaxes2 = _$v.enableCustomInvoiceTaxes2;
_taxRates = _$v.taxRates?.toBuilder(); _taxRates = _$v.taxRates?.toBuilder();
_customFields = _$v.customFields?.toBuilder(); _customFields = _$v.customFields?.toBuilder();
_invoiceFields = _$v.invoiceFields;
_$v = null; _$v = null;
} }
return this; return this;
@ -1011,7 +1031,8 @@ class CompanyEntityBuilder
enableCustomInvoiceTaxes1: enableCustomInvoiceTaxes1, enableCustomInvoiceTaxes1: enableCustomInvoiceTaxes1,
enableCustomInvoiceTaxes2: enableCustomInvoiceTaxes2, enableCustomInvoiceTaxes2: enableCustomInvoiceTaxes2,
taxRates: taxRates.build(), taxRates: taxRates.build(),
customFields: customFields.build()); customFields: customFields.build(),
invoiceFields: invoiceFields);
} catch (_) { } catch (_) {
String _$failedField; String _$failedField;
try { try {

View File

@ -253,20 +253,20 @@ class ItemEditDetailsState extends State<ItemEditDetails> {
labelText: localization.unitCost, labelText: localization.unitCost,
), ),
), ),
TextFormField( company.hasInvoiceField('quantity') ? TextFormField(
controller: _qtyController, controller: _qtyController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
labelText: localization.quantity, labelText: localization.quantity,
), ),
), ) : Container(),
TextFormField( company.hasInvoiceField('discount') ? TextFormField(
controller: _discountController, controller: _discountController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
labelText: localization.discount, labelText: localization.discount,
), ),
), ) : Container(),
company.enableInvoiceTaxes company.enableInvoiceTaxes
? TaxRateDropdown( ? TaxRateDropdown(
taxRates: company.taxRates, taxRates: company.taxRates,