Add client initiated payments

This commit is contained in:
Hillel Coren 2023-03-20 19:56:58 +02:00
parent 7adc9f2386
commit f09126fec4
4 changed files with 175 additions and 10 deletions

View File

@ -961,6 +961,22 @@ abstract class SettingsEntity
@BuiltValueField(wireName: 'accept_client_input_quote_approval')
bool get acceptPurchaseOrderNumber;
@nullable
@BuiltValueField(wireName: 'client_initiated_payments')
bool get clientInitiatedPayments;
@nullable
@BuiltValueField(wireName: 'client_initiated_payments_minimum')
double get clientInitiatedPaymentsMinimum;
@nullable
@BuiltValueField(wireName: 'client_initiated_payments_recurring')
bool get clientInitiatedPaymentsRecurring;
@nullable
@BuiltValueField(wireName: 'sync_invoice_quote_columns')
bool get syncInvoiceQuoteColumns;
bool get hasAddress => address1 != null && address1.isNotEmpty;
bool get hasLogo => companyLogo != null && companyLogo.isNotEmpty;

View File

@ -1471,6 +1471,34 @@ class _$SettingsEntitySerializer
..add(
serializers.serialize(value, specifiedType: const FullType(bool)));
}
value = object.clientInitiatedPayments;
if (value != null) {
result
..add('client_initiated_payments')
..add(
serializers.serialize(value, specifiedType: const FullType(bool)));
}
value = object.clientInitiatedPaymentsMinimum;
if (value != null) {
result
..add('client_initiated_payments_minimum')
..add(serializers.serialize(value,
specifiedType: const FullType(double)));
}
value = object.clientInitiatedPaymentsRecurring;
if (value != null) {
result
..add('client_initiated_payments_recurring')
..add(
serializers.serialize(value, specifiedType: const FullType(bool)));
}
value = object.syncInvoiceQuoteColumns;
if (value != null) {
result
..add('sync_invoice_quote_columns')
..add(
serializers.serialize(value, specifiedType: const FullType(bool)));
}
return result;
}
@ -2327,6 +2355,22 @@ class _$SettingsEntitySerializer
result.acceptPurchaseOrderNumber = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'client_initiated_payments':
result.clientInitiatedPayments = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'client_initiated_payments_minimum':
result.clientInitiatedPaymentsMinimum = serializers.deserialize(value,
specifiedType: const FullType(double)) as double;
break;
case 'client_initiated_payments_recurring':
result.clientInitiatedPaymentsRecurring = serializers
.deserialize(value, specifiedType: const FullType(bool)) as bool;
break;
case 'sync_invoice_quote_columns':
result.syncInvoiceQuoteColumns = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
}
}
@ -2823,6 +2867,14 @@ class _$SettingsEntity extends SettingsEntity {
final String customSendingEmail;
@override
final bool acceptPurchaseOrderNumber;
@override
final bool clientInitiatedPayments;
@override
final double clientInitiatedPaymentsMinimum;
@override
final bool clientInitiatedPaymentsRecurring;
@override
final bool syncInvoiceQuoteColumns;
factory _$SettingsEntity([void Function(SettingsEntityBuilder) updates]) =>
(new SettingsEntityBuilder()..update(updates))._build();
@ -3036,7 +3088,11 @@ class _$SettingsEntity extends SettingsEntity {
this.showPaidStamp,
this.showShippingAddress,
this.customSendingEmail,
this.acceptPurchaseOrderNumber})
this.acceptPurchaseOrderNumber,
this.clientInitiatedPayments,
this.clientInitiatedPaymentsMinimum,
this.clientInitiatedPaymentsRecurring,
this.syncInvoiceQuoteColumns})
: super._();
@override
@ -3263,7 +3319,13 @@ class _$SettingsEntity extends SettingsEntity {
showPaidStamp == other.showPaidStamp &&
showShippingAddress == other.showShippingAddress &&
customSendingEmail == other.customSendingEmail &&
acceptPurchaseOrderNumber == other.acceptPurchaseOrderNumber;
acceptPurchaseOrderNumber == other.acceptPurchaseOrderNumber &&
clientInitiatedPayments == other.clientInitiatedPayments &&
clientInitiatedPaymentsMinimum ==
other.clientInitiatedPaymentsMinimum &&
clientInitiatedPaymentsRecurring ==
other.clientInitiatedPaymentsRecurring &&
syncInvoiceQuoteColumns == other.syncInvoiceQuoteColumns;
}
int __hashCode;
@ -3480,6 +3542,10 @@ class _$SettingsEntity extends SettingsEntity {
_$hash = $jc(_$hash, showShippingAddress.hashCode);
_$hash = $jc(_$hash, customSendingEmail.hashCode);
_$hash = $jc(_$hash, acceptPurchaseOrderNumber.hashCode);
_$hash = $jc(_$hash, clientInitiatedPayments.hashCode);
_$hash = $jc(_$hash, clientInitiatedPaymentsMinimum.hashCode);
_$hash = $jc(_$hash, clientInitiatedPaymentsRecurring.hashCode);
_$hash = $jc(_$hash, syncInvoiceQuoteColumns.hashCode);
_$hash = $jf(_$hash);
return __hashCode ??= _$hash;
}
@ -3699,7 +3765,13 @@ class _$SettingsEntity extends SettingsEntity {
..add('showPaidStamp', showPaidStamp)
..add('showShippingAddress', showShippingAddress)
..add('customSendingEmail', customSendingEmail)
..add('acceptPurchaseOrderNumber', acceptPurchaseOrderNumber))
..add('acceptPurchaseOrderNumber', acceptPurchaseOrderNumber)
..add('clientInitiatedPayments', clientInitiatedPayments)
..add(
'clientInitiatedPaymentsMinimum', clientInitiatedPaymentsMinimum)
..add('clientInitiatedPaymentsRecurring',
clientInitiatedPaymentsRecurring)
..add('syncInvoiceQuoteColumns', syncInvoiceQuoteColumns))
.toString();
}
}
@ -4733,6 +4805,29 @@ class SettingsEntityBuilder
set acceptPurchaseOrderNumber(bool acceptPurchaseOrderNumber) =>
_$this._acceptPurchaseOrderNumber = acceptPurchaseOrderNumber;
bool _clientInitiatedPayments;
bool get clientInitiatedPayments => _$this._clientInitiatedPayments;
set clientInitiatedPayments(bool clientInitiatedPayments) =>
_$this._clientInitiatedPayments = clientInitiatedPayments;
double _clientInitiatedPaymentsMinimum;
double get clientInitiatedPaymentsMinimum =>
_$this._clientInitiatedPaymentsMinimum;
set clientInitiatedPaymentsMinimum(double clientInitiatedPaymentsMinimum) =>
_$this._clientInitiatedPaymentsMinimum = clientInitiatedPaymentsMinimum;
bool _clientInitiatedPaymentsRecurring;
bool get clientInitiatedPaymentsRecurring =>
_$this._clientInitiatedPaymentsRecurring;
set clientInitiatedPaymentsRecurring(bool clientInitiatedPaymentsRecurring) =>
_$this._clientInitiatedPaymentsRecurring =
clientInitiatedPaymentsRecurring;
bool _syncInvoiceQuoteColumns;
bool get syncInvoiceQuoteColumns => _$this._syncInvoiceQuoteColumns;
set syncInvoiceQuoteColumns(bool syncInvoiceQuoteColumns) =>
_$this._syncInvoiceQuoteColumns = syncInvoiceQuoteColumns;
SettingsEntityBuilder();
SettingsEntityBuilder get _$this {
@ -4947,6 +5042,10 @@ class SettingsEntityBuilder
_showShippingAddress = $v.showShippingAddress;
_customSendingEmail = $v.customSendingEmail;
_acceptPurchaseOrderNumber = $v.acceptPurchaseOrderNumber;
_clientInitiatedPayments = $v.clientInitiatedPayments;
_clientInitiatedPaymentsMinimum = $v.clientInitiatedPaymentsMinimum;
_clientInitiatedPaymentsRecurring = $v.clientInitiatedPaymentsRecurring;
_syncInvoiceQuoteColumns = $v.syncInvoiceQuoteColumns;
_$v = null;
}
return this;
@ -5180,7 +5279,12 @@ class SettingsEntityBuilder
showPaidStamp: showPaidStamp,
showShippingAddress: showShippingAddress,
customSendingEmail: customSendingEmail,
acceptPurchaseOrderNumber: acceptPurchaseOrderNumber);
acceptPurchaseOrderNumber: acceptPurchaseOrderNumber,
clientInitiatedPayments: clientInitiatedPayments,
clientInitiatedPaymentsMinimum: clientInitiatedPaymentsMinimum,
clientInitiatedPaymentsRecurring:
clientInitiatedPaymentsRecurring,
syncInvoiceQuoteColumns: syncInvoiceQuoteColumns);
} catch (_) {
String _$failedField;
try {

View File

@ -35,7 +35,8 @@ class _PaymentSettingsState extends State<PaymentSettings> {
static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_paymentSettings');
FocusScopeNode _focusNode;
final _minimumAmountController = TextEditingController();
final _minimumUnderPaymentAmountController = TextEditingController();
final _minimumPaymentAmountController = TextEditingController();
List<TextEditingController> _controllers = [];
@override
@ -47,16 +48,21 @@ class _PaymentSettingsState extends State<PaymentSettings> {
@override
void didChangeDependencies() {
_controllers = [
_minimumAmountController,
_minimumPaymentAmountController,
_minimumUnderPaymentAmountController,
];
_controllers
.forEach((dynamic controller) => controller.removeListener(_onChanged));
_minimumAmountController.text = formatNumber(
_minimumUnderPaymentAmountController.text = formatNumber(
widget.viewModel.settings.clientPortalUnderPaymentMinimum, context,
formatNumberType: FormatNumberType.inputMoney);
_minimumPaymentAmountController.text = formatNumber(
widget.viewModel.settings.clientInitiatedPaymentsMinimum, context,
formatNumberType: FormatNumberType.inputMoney);
_controllers
.forEach((dynamic controller) => controller.addListener(_onChanged));
@ -73,7 +79,9 @@ class _PaymentSettingsState extends State<PaymentSettings> {
final viewModel = widget.viewModel;
final settings = viewModel.settings.rebuild((b) => b
..clientPortalUnderPaymentMinimum =
parseDouble(_minimumAmountController.text));
parseDouble(_minimumUnderPaymentAmountController.text)
..clientInitiatedPaymentsMinimum =
parseDouble(_minimumPaymentAmountController.text));
if (settings != viewModel.settings) {
viewModel.onSettingsChanged(settings);
}
@ -232,7 +240,25 @@ class _PaymentSettingsState extends State<PaymentSettings> {
padding: const EdgeInsets.only(top: 16),
child: DecoratedFormField(
label: localization.minimumUnderPaymentAmount,
controller: _minimumAmountController,
controller: _minimumUnderPaymentAmountController,
isMoney: true,
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),
),
),
BoolDropdownButton(
label: localization.clientInitiatedPayments,
value: settings.clientInitiatedPayments,
helpLabel: localization.clientInitiatedPaymentsHelp,
onChanged: (value) => viewModel.onSettingsChanged(
settings.rebuild((b) => b..clientInitiatedPayments = value)),
),
if (settings.clientInitiatedPayments == true)
Padding(
padding: const EdgeInsets.only(top: 16),
child: DecoratedFormField(
label: localization.minimumPaymentAmount,
controller: _minimumPaymentAmountController,
isMoney: true,
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),

View File

@ -16,6 +16,11 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'minimum_payment_amount': 'Minimum Payment Amount',
'client_initiated_payments': 'Client Initiated Payments',
'client_initiated_payments_help':
'Support making a payment in the client portal without an invoice',
'share_invoice_quote_columns': 'Share invoice/quote columns',
'cc_email': 'CC Email',
'payment_balance': 'Payment Balance',
'view_report_permission':
@ -96858,12 +96863,26 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['payment_balance'] ??
_localizedValues['en']['payment_balance'];
String get clientInitiatedPayments =>
_localizedValues[localeCode]['client_initiated_payments'] ??
_localizedValues['en']['client_initiated_payments'];
String get clientInitiatedPaymentsHelp =>
_localizedValues[localeCode]['client_initiated_payments_help'] ??
_localizedValues['en']['client_initiated_payments_help'];
String get shareInvoiceQuoteColumns =>
_localizedValues[localeCode]['share_invoice_quote_columns'] ??
_localizedValues['en']['share_invoice_quote_columns'];
String get minimumPaymentAmount =>
_localizedValues[localeCode]['minimum_payment_amount'] ??
_localizedValues['en']['minimum_payment_amount'];
String get ccEmail =>
_localizedValues[localeCode]['cc_email'] ??
_localizedValues['en']['cc_email'];
// STARTER: lang field - do not remove comment
String lookup(String key) {