From baf6d5c5fba931a257872de6a2a7c92afe11c6cb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 21 Sep 2020 20:04:36 +0300 Subject: [PATCH] Recurring invoices --- lib/data/models/invoice_model.dart | 5 ++- lib/data/models/invoice_model.g.dart | 36 +++++++++++++++---- .../invoice/view/invoice_view_overview.dart | 11 ++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/lib/data/models/invoice_model.dart b/lib/data/models/invoice_model.dart index b4a75a2e8..d1c3236d5 100644 --- a/lib/data/models/invoice_model.dart +++ b/lib/data/models/invoice_model.dart @@ -129,6 +129,7 @@ abstract class InvoiceEntity extends Object partialDueDate: '', hasTasks: false, autoBill: CompanyGatewayEntity.TOKEN_BILLING_ALWAYS, + autoBillEnabled: false, customValue1: '', customValue2: '', customValue3: '', @@ -288,10 +289,12 @@ abstract class InvoiceEntity extends Object @BuiltValueField(wireName: 'has_tasks') bool get hasTasks; - @nullable @BuiltValueField(wireName: 'auto_bill') String get autoBill; + @BuiltValueField(wireName: 'auto_bill_enabled') + bool get autoBillEnabled; + @BuiltValueField(wireName: 'custom_value1') String get customValue1; diff --git a/lib/data/models/invoice_model.g.dart b/lib/data/models/invoice_model.g.dart index 90b0fe900..999b13770 100644 --- a/lib/data/models/invoice_model.g.dart +++ b/lib/data/models/invoice_model.g.dart @@ -201,6 +201,12 @@ class _$InvoiceEntitySerializer implements StructuredSerializer { 'has_tasks', serializers.serialize(object.hasTasks, specifiedType: const FullType(bool)), + 'auto_bill', + serializers.serialize(object.autoBill, + specifiedType: const FullType(String)), + 'auto_bill_enabled', + serializers.serialize(object.autoBillEnabled, + specifiedType: const FullType(bool)), 'custom_value1', serializers.serialize(object.customValue1, specifiedType: const FullType(String)), @@ -261,12 +267,6 @@ class _$InvoiceEntitySerializer implements StructuredSerializer { 'id', serializers.serialize(object.id, specifiedType: const FullType(String)), ]; - if (object.autoBill != null) { - result - ..add('auto_bill') - ..add(serializers.serialize(object.autoBill, - specifiedType: const FullType(String))); - } if (object.customTaxes1 != null) { result ..add('custom_taxes1') @@ -511,6 +511,10 @@ class _$InvoiceEntitySerializer implements StructuredSerializer { result.autoBill = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; + case 'auto_bill_enabled': + result.autoBillEnabled = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; case 'custom_value1': result.customValue1 = serializers.deserialize(value, specifiedType: const FullType(String)) as String; @@ -1338,6 +1342,8 @@ class _$InvoiceEntity extends InvoiceEntity { @override final String autoBill; @override + final bool autoBillEnabled; + @override final String customValue1; @override final String customValue2; @@ -1447,6 +1453,7 @@ class _$InvoiceEntity extends InvoiceEntity { this.partialDueDate, this.hasTasks, this.autoBill, + this.autoBillEnabled, this.customValue1, this.customValue2, this.customValue3, @@ -1565,6 +1572,12 @@ class _$InvoiceEntity extends InvoiceEntity { if (hasTasks == null) { throw new BuiltValueNullFieldError('InvoiceEntity', 'hasTasks'); } + if (autoBill == null) { + throw new BuiltValueNullFieldError('InvoiceEntity', 'autoBill'); + } + if (autoBillEnabled == null) { + throw new BuiltValueNullFieldError('InvoiceEntity', 'autoBillEnabled'); + } if (customValue1 == null) { throw new BuiltValueNullFieldError('InvoiceEntity', 'customValue1'); } @@ -1662,6 +1675,7 @@ class _$InvoiceEntity extends InvoiceEntity { partialDueDate == other.partialDueDate && hasTasks == other.hasTasks && autoBill == other.autoBill && + autoBillEnabled == other.autoBillEnabled && customValue1 == other.customValue1 && customValue2 == other.customValue2 && customValue3 == other.customValue3 && @@ -1724,7 +1738,7 @@ class _$InvoiceEntity extends InvoiceEntity { $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, amount.hashCode), balance.hashCode), clientId.hashCode), statusId.hashCode), number.hashCode), discount.hashCode), poNumber.hashCode), date.hashCode), dueDate.hashCode), publicNotes.hashCode), privateNotes.hashCode), terms.hashCode), footer.hashCode), designId.hashCode), usesInclusiveTaxes.hashCode), taxName1.hashCode), taxRate1.hashCode), taxName2.hashCode), taxRate2.hashCode), taxName3.hashCode), taxRate3.hashCode), isAmountDiscount.hashCode), partial.hashCode), taxAmount.hashCode), partialDueDate.hashCode), hasTasks.hashCode), autoBill.hashCode), customValue1.hashCode), customValue2.hashCode), customValue3.hashCode), customValue4.hashCode), customSurcharge1.hashCode), customSurcharge2.hashCode), customSurcharge3.hashCode), customSurcharge4.hashCode), customTaxes1.hashCode), customTaxes2.hashCode), customTaxes3.hashCode), customTaxes4.hashCode), hasExpenses.hashCode), exchangeRate.hashCode), reminder1Sent.hashCode), reminder2Sent.hashCode), reminder3Sent.hashCode), reminderLastSent.hashCode), frequencyId.hashCode), lastSentDate.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(0, amount.hashCode), balance.hashCode), clientId.hashCode), statusId.hashCode), number.hashCode), discount.hashCode), poNumber.hashCode), date.hashCode), dueDate.hashCode), publicNotes.hashCode), privateNotes.hashCode), terms.hashCode), footer.hashCode), designId.hashCode), usesInclusiveTaxes.hashCode), taxName1.hashCode), taxRate1.hashCode), taxName2.hashCode), taxRate2.hashCode), taxName3.hashCode), taxRate3.hashCode), isAmountDiscount.hashCode), partial.hashCode), taxAmount.hashCode), partialDueDate.hashCode), hasTasks.hashCode), autoBill.hashCode), autoBillEnabled.hashCode), customValue1.hashCode), customValue2.hashCode), customValue3.hashCode), customValue4.hashCode), customSurcharge1.hashCode), customSurcharge2.hashCode), customSurcharge3.hashCode), customSurcharge4.hashCode), customTaxes1.hashCode), customTaxes2.hashCode), customTaxes3.hashCode), customTaxes4.hashCode), hasExpenses.hashCode), exchangeRate.hashCode), reminder1Sent.hashCode), reminder2Sent.hashCode), reminder3Sent.hashCode), reminderLastSent.hashCode), frequencyId.hashCode), lastSentDate.hashCode), nextSendDate.hashCode), remainingCycles.hashCode), dueDateDays.hashCode), @@ -1776,6 +1790,7 @@ class _$InvoiceEntity extends InvoiceEntity { ..add('partialDueDate', partialDueDate) ..add('hasTasks', hasTasks) ..add('autoBill', autoBill) + ..add('autoBillEnabled', autoBillEnabled) ..add('customValue1', customValue1) ..add('customValue2', customValue2) ..add('customValue3', customValue3) @@ -1934,6 +1949,11 @@ class InvoiceEntityBuilder String get autoBill => _$this._autoBill; set autoBill(String autoBill) => _$this._autoBill = autoBill; + bool _autoBillEnabled; + bool get autoBillEnabled => _$this._autoBillEnabled; + set autoBillEnabled(bool autoBillEnabled) => + _$this._autoBillEnabled = autoBillEnabled; + String _customValue1; String get customValue1 => _$this._customValue1; set customValue1(String customValue1) => _$this._customValue1 = customValue1; @@ -2140,6 +2160,7 @@ class InvoiceEntityBuilder _partialDueDate = _$v.partialDueDate; _hasTasks = _$v.hasTasks; _autoBill = _$v.autoBill; + _autoBillEnabled = _$v.autoBillEnabled; _customValue1 = _$v.customValue1; _customValue2 = _$v.customValue2; _customValue3 = _$v.customValue3; @@ -2230,6 +2251,7 @@ class InvoiceEntityBuilder partialDueDate: partialDueDate, hasTasks: hasTasks, autoBill: autoBill, + autoBillEnabled: autoBillEnabled, customValue1: customValue1, customValue2: customValue2, customValue3: customValue3, diff --git a/lib/ui/invoice/view/invoice_view_overview.dart b/lib/ui/invoice/view/invoice_view_overview.dart index 719038c4d..81eb3f5dc 100644 --- a/lib/ui/invoice/view/invoice_view_overview.dart +++ b/lib/ui/invoice/view/invoice_view_overview.dart @@ -1,5 +1,6 @@ import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/constants.dart'; +import 'package:invoiceninja_flutter/data/models/company_gateway_model.dart'; import 'package:invoiceninja_flutter/data/models/entities.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/data/models/quote_model.dart'; @@ -121,6 +122,16 @@ class InvoiceOverview extends StatelessWidget { RecurringInvoiceFields.remainingCycles: invoice.remainingCycles == -1 ? localization.endless : '${invoice.remainingCycles}', + RecurringInvoiceFields.autoBill: localization.lookup(invoice.autoBill) + + ([ + CompanyGatewayEntity.TOKEN_BILLING_OPT_IN, + CompanyGatewayEntity.TOKEN_BILLING_OPT_OUT + ].contains(invoice.autoBill) + ? (' - ' + + (invoice.autoBillEnabled + ? localization.yes + : localization.no)) + : ''), InvoiceFields.dueDate: invoice.dueDateDays == 'terms' ? localization.paymentTerm : invoice.dueDateDays == '1'