Payments
This commit is contained in:
parent
9daad15b17
commit
76cdc106f2
|
|
@ -81,7 +81,7 @@ abstract class PaymentEntity extends Object
|
|||
customValue2: '',
|
||||
customValue3: '',
|
||||
customValue4: '',
|
||||
paymentables: BuiltList<PaymentableEntity>(),
|
||||
paymentables: BuiltList(<PaymentableEntity>[PaymentableEntity()]),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/payment_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/static/static_selectors.dart';
|
||||
|
|
@ -132,27 +133,6 @@ class _PaymentEditState extends State<PaymentEdit> {
|
|||
entityList: memoizedDropdownClientList(
|
||||
viewModel.clientMap, viewModel.clientList),
|
||||
),
|
||||
EntityDropdown(
|
||||
key: Key('__invoice_${payment.clientId}__'),
|
||||
entityType: EntityType.invoice,
|
||||
labelText: AppLocalization.of(context).invoice,
|
||||
entityId: payment.invoiceId,
|
||||
entityList: memoizedDropdownInvoiceList(
|
||||
viewModel.invoiceMap,
|
||||
viewModel.clientMap,
|
||||
viewModel.invoiceList,
|
||||
payment.clientId),
|
||||
onSelected: (selected) {
|
||||
final invoice = selected as InvoiceEntity;
|
||||
_amountController.text = formatNumber(
|
||||
invoice.balance, context,
|
||||
formatNumberType: FormatNumberType.input);
|
||||
viewModel.onChanged(payment.rebuild((b) => b
|
||||
..invoiceId = invoice.id
|
||||
..clientId = invoice.clientId
|
||||
..amount = invoice.balance));
|
||||
},
|
||||
),
|
||||
DecoratedFormField(
|
||||
controller: _amountController,
|
||||
autocorrect: false,
|
||||
|
|
@ -161,6 +141,12 @@ class _PaymentEditState extends State<PaymentEdit> {
|
|||
label: localization.amount,
|
||||
),
|
||||
],
|
||||
for (final paymentable in payment.paymentables)
|
||||
PaymentableEditor(
|
||||
viewModel: viewModel,
|
||||
paymentable: paymentable,
|
||||
onChanged: () {},
|
||||
),
|
||||
EntityDropdown(
|
||||
key: ValueKey('__payment_type_${payment.typeId}__'),
|
||||
entityType: EntityType.paymentType,
|
||||
|
|
@ -168,8 +154,8 @@ class _PaymentEditState extends State<PaymentEdit> {
|
|||
viewModel.staticState.paymentTypeMap),
|
||||
labelText: localization.paymentType,
|
||||
entityId: payment.typeId,
|
||||
onSelected: (paymentType) => viewModel.onChanged(payment
|
||||
.rebuild((b) => b..typeId = paymentType.id)),
|
||||
onSelected: (paymentType) => viewModel.onChanged(
|
||||
payment.rebuild((b) => b..typeId = paymentType.id)),
|
||||
),
|
||||
DatePicker(
|
||||
validator: (String val) => val.trim().isEmpty
|
||||
|
|
@ -179,8 +165,7 @@ class _PaymentEditState extends State<PaymentEdit> {
|
|||
labelText: localization.paymentDate,
|
||||
selectedDate: payment.date,
|
||||
onSelected: (date) {
|
||||
viewModel.onChanged(
|
||||
payment.rebuild((b) => b..date = date));
|
||||
viewModel.onChanged(payment.rebuild((b) => b..date = date));
|
||||
},
|
||||
),
|
||||
DecoratedFormField(
|
||||
|
|
@ -212,3 +197,61 @@ class _PaymentEditState extends State<PaymentEdit> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PaymentableEditor extends StatelessWidget {
|
||||
const PaymentableEditor({
|
||||
@required this.viewModel,
|
||||
@required this.paymentable,
|
||||
@required this.onChanged,
|
||||
});
|
||||
|
||||
final PaymentEditVM viewModel;
|
||||
final PaymentableEntity paymentable;
|
||||
final Function onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final payment = viewModel.payment;
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: EntityDropdown(
|
||||
key: Key('__invoice_${payment.clientId}__'),
|
||||
entityType: EntityType.invoice,
|
||||
labelText: AppLocalization.of(context).invoice,
|
||||
entityId: payment.invoiceId,
|
||||
entityList: memoizedDropdownInvoiceList(viewModel.invoiceMap,
|
||||
viewModel.clientMap, viewModel.invoiceList, payment.clientId),
|
||||
onSelected: (selected) {
|
||||
final invoice = selected as InvoiceEntity;
|
||||
/*
|
||||
_amountController.text = formatNumber(
|
||||
invoice.balance, context,
|
||||
formatNumberType: FormatNumberType.input);
|
||||
*/
|
||||
viewModel.onChanged(payment.rebuild((b) => b
|
||||
..invoiceId = invoice.id
|
||||
..clientId = invoice.clientId
|
||||
..amount = invoice.balance));
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.applied,
|
||||
),
|
||||
),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(localization.remove),
|
||||
onPressed: () {
|
||||
// TODO
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ abstract class LocaleCodeAware {
|
|||
mixin LocalizationsProvider on LocaleCodeAware {
|
||||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
'applied': 'Applied',
|
||||
'include_recent_errors': 'Include recent errors from the logs',
|
||||
'your_message_has_been_received': 'We have received your message and will try to respond promptly.',
|
||||
'message': 'Message',
|
||||
|
|
@ -15926,7 +15927,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
String get includeRecentErrors =>
|
||||
_localizedValues[localeCode]['include_recent_errors'];
|
||||
|
||||
|
||||
String get applied =>
|
||||
_localizedValues[localeCode]['applied'];
|
||||
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue