Show payment total placeholder
This commit is contained in:
parent
6fcb6a45c7
commit
de7a29217e
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
|
@ -183,6 +185,30 @@ class _PaymentEditState extends State<PaymentEdit> {
|
||||||
paymentable: invoicePaymentables[index],
|
paymentable: invoicePaymentables[index],
|
||||||
index: index,
|
index: index,
|
||||||
entityType: EntityType.invoice,
|
entityType: EntityType.invoice,
|
||||||
|
limit: payment.amount == 0
|
||||||
|
? null
|
||||||
|
: payment.amount - paymentTotal,
|
||||||
|
),
|
||||||
|
DatePicker(
|
||||||
|
validator: (String val) => val.trim().isEmpty
|
||||||
|
? AppLocalization.of(context).pleaseSelectADate
|
||||||
|
: null,
|
||||||
|
autoValidate: autoValidate,
|
||||||
|
labelText: localization.paymentDate,
|
||||||
|
selectedDate: payment.date,
|
||||||
|
onSelected: (date) {
|
||||||
|
viewModel.onChanged(payment.rebuild((b) => b..date = date));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
EntityDropdown(
|
||||||
|
key: ValueKey('__payment_type_${payment.typeId}__'),
|
||||||
|
entityType: EntityType.paymentType,
|
||||||
|
entityList: memoizedPaymentTypeList(
|
||||||
|
viewModel.staticState.paymentTypeMap),
|
||||||
|
labelText: localization.paymentType,
|
||||||
|
entityId: payment.typeId,
|
||||||
|
onSelected: (paymentType) => viewModel.onChanged(
|
||||||
|
payment.rebuild((b) => b..typeId = paymentType.id)),
|
||||||
),
|
),
|
||||||
if (payment.isForInvoice != true)
|
if (payment.isForInvoice != true)
|
||||||
if (state.company.isModuleEnabled(EntityType.credit))
|
if (state.company.isModuleEnabled(EntityType.credit))
|
||||||
|
|
@ -196,27 +222,7 @@ class _PaymentEditState extends State<PaymentEdit> {
|
||||||
paymentable: creditPaymentables[index],
|
paymentable: creditPaymentables[index],
|
||||||
index: index,
|
index: index,
|
||||||
entityType: EntityType.credit,
|
entityType: EntityType.credit,
|
||||||
),
|
limit: 0,
|
||||||
EntityDropdown(
|
|
||||||
key: ValueKey('__payment_type_${payment.typeId}__'),
|
|
||||||
entityType: EntityType.paymentType,
|
|
||||||
entityList: memoizedPaymentTypeList(
|
|
||||||
viewModel.staticState.paymentTypeMap),
|
|
||||||
labelText: localization.paymentType,
|
|
||||||
entityId: payment.typeId,
|
|
||||||
onSelected: (paymentType) => viewModel.onChanged(
|
|
||||||
payment.rebuild((b) => b..typeId = paymentType.id)),
|
|
||||||
),
|
|
||||||
DatePicker(
|
|
||||||
validator: (String val) => val.trim().isEmpty
|
|
||||||
? AppLocalization.of(context).pleaseSelectADate
|
|
||||||
: null,
|
|
||||||
autoValidate: autoValidate,
|
|
||||||
labelText: localization.paymentDate,
|
|
||||||
selectedDate: payment.date,
|
|
||||||
onSelected: (date) {
|
|
||||||
viewModel.onChanged(payment.rebuild((b) => b..date = date));
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
DecoratedFormField(
|
DecoratedFormField(
|
||||||
controller: _transactionReferenceController,
|
controller: _transactionReferenceController,
|
||||||
|
|
@ -255,12 +261,14 @@ class PaymentableEditor extends StatefulWidget {
|
||||||
@required this.paymentable,
|
@required this.paymentable,
|
||||||
@required this.index,
|
@required this.index,
|
||||||
@required this.entityType,
|
@required this.entityType,
|
||||||
|
@required this.limit,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final PaymentEditVM viewModel;
|
final PaymentEditVM viewModel;
|
||||||
final PaymentableEntity paymentable;
|
final PaymentableEntity paymentable;
|
||||||
final int index;
|
final int index;
|
||||||
final EntityType entityType;
|
final EntityType entityType;
|
||||||
|
final double limit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PaymentableEditorState createState() => _PaymentableEditorState();
|
_PaymentableEditorState createState() => _PaymentableEditorState();
|
||||||
|
|
@ -376,7 +384,10 @@ class _PaymentableEditorState extends State<PaymentableEditor> {
|
||||||
),
|
),
|
||||||
onSelected: (selected) {
|
onSelected: (selected) {
|
||||||
final invoice = selected as InvoiceEntity;
|
final invoice = selected as InvoiceEntity;
|
||||||
_amountController.text = formatNumber(invoice.balance, context,
|
final amount = widget.limit != null
|
||||||
|
? min(widget.limit, invoice.balance)
|
||||||
|
: invoice.balance;
|
||||||
|
_amountController.text = formatNumber(amount, context,
|
||||||
formatNumberType: FormatNumberType.input);
|
formatNumberType: FormatNumberType.input);
|
||||||
_invoiceId = invoice.id;
|
_invoiceId = invoice.id;
|
||||||
_onChanged(invoice.clientId);
|
_onChanged(invoice.clientId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue