Payments
This commit is contained in:
parent
7b72d526a9
commit
2d1b3997b1
|
|
@ -58,7 +58,8 @@ abstract class PaymentEntity extends Object with BaseEntity implements Built<Pay
|
|||
privateNotes: '',
|
||||
exchangeRate: 0.0,
|
||||
exchangeCurrencyId: 0,
|
||||
|
||||
refunded: 0.0,
|
||||
paymentStatusId: 0,
|
||||
updatedAt: 0,
|
||||
archivedAt: 0,
|
||||
isDeleted: false,
|
||||
|
|
@ -73,6 +74,11 @@ abstract class PaymentEntity extends Object with BaseEntity implements Built<Pay
|
|||
|
||||
double get amount;
|
||||
|
||||
double get refunded;
|
||||
|
||||
@BuiltValueField(wireName: 'payment_status_id')
|
||||
int get paymentStatusId;
|
||||
|
||||
@BuiltValueField(wireName: 'transaction_reference')
|
||||
String get transactionReference;
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
|
|||
'amount',
|
||||
serializers.serialize(object.amount,
|
||||
specifiedType: const FullType(double)),
|
||||
'refunded',
|
||||
serializers.serialize(object.refunded,
|
||||
specifiedType: const FullType(double)),
|
||||
'payment_status_id',
|
||||
serializers.serialize(object.paymentStatusId,
|
||||
specifiedType: const FullType(int)),
|
||||
'transaction_reference',
|
||||
serializers.serialize(object.transactionReference,
|
||||
specifiedType: const FullType(String)),
|
||||
|
|
@ -207,6 +213,14 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
|
|||
result.amount = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double)) as double;
|
||||
break;
|
||||
case 'refunded':
|
||||
result.refunded = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double)) as double;
|
||||
break;
|
||||
case 'payment_status_id':
|
||||
result.paymentStatusId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case 'transaction_reference':
|
||||
result.transactionReference = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
|
|
@ -455,6 +469,10 @@ class _$PaymentEntity extends PaymentEntity {
|
|||
@override
|
||||
final double amount;
|
||||
@override
|
||||
final double refunded;
|
||||
@override
|
||||
final int paymentStatusId;
|
||||
@override
|
||||
final String transactionReference;
|
||||
@override
|
||||
final String paymentDate;
|
||||
|
|
@ -488,6 +506,8 @@ class _$PaymentEntity extends PaymentEntity {
|
|||
|
||||
_$PaymentEntity._(
|
||||
{this.amount,
|
||||
this.refunded,
|
||||
this.paymentStatusId,
|
||||
this.transactionReference,
|
||||
this.paymentDate,
|
||||
this.paymentTypeId,
|
||||
|
|
@ -505,6 +525,10 @@ class _$PaymentEntity extends PaymentEntity {
|
|||
: super._() {
|
||||
if (amount == null)
|
||||
throw new BuiltValueNullFieldError('PaymentEntity', 'amount');
|
||||
if (refunded == null)
|
||||
throw new BuiltValueNullFieldError('PaymentEntity', 'refunded');
|
||||
if (paymentStatusId == null)
|
||||
throw new BuiltValueNullFieldError('PaymentEntity', 'paymentStatusId');
|
||||
if (transactionReference == null)
|
||||
throw new BuiltValueNullFieldError(
|
||||
'PaymentEntity', 'transactionReference');
|
||||
|
|
@ -536,6 +560,8 @@ class _$PaymentEntity extends PaymentEntity {
|
|||
if (identical(other, this)) return true;
|
||||
if (other is! PaymentEntity) return false;
|
||||
return amount == other.amount &&
|
||||
refunded == other.refunded &&
|
||||
paymentStatusId == other.paymentStatusId &&
|
||||
transactionReference == other.transactionReference &&
|
||||
paymentDate == other.paymentDate &&
|
||||
paymentTypeId == other.paymentTypeId &&
|
||||
|
|
@ -566,12 +592,18 @@ class _$PaymentEntity extends PaymentEntity {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
0,
|
||||
amount
|
||||
.hashCode),
|
||||
refunded
|
||||
.hashCode),
|
||||
paymentStatusId
|
||||
.hashCode),
|
||||
transactionReference
|
||||
.hashCode),
|
||||
paymentDate.hashCode),
|
||||
|
|
@ -593,6 +625,8 @@ class _$PaymentEntity extends PaymentEntity {
|
|||
String toString() {
|
||||
return (newBuiltValueToStringHelper('PaymentEntity')
|
||||
..add('amount', amount)
|
||||
..add('refunded', refunded)
|
||||
..add('paymentStatusId', paymentStatusId)
|
||||
..add('transactionReference', transactionReference)
|
||||
..add('paymentDate', paymentDate)
|
||||
..add('paymentTypeId', paymentTypeId)
|
||||
|
|
@ -619,6 +653,15 @@ class PaymentEntityBuilder
|
|||
double get amount => _$this._amount;
|
||||
set amount(double amount) => _$this._amount = amount;
|
||||
|
||||
double _refunded;
|
||||
double get refunded => _$this._refunded;
|
||||
set refunded(double refunded) => _$this._refunded = refunded;
|
||||
|
||||
int _paymentStatusId;
|
||||
int get paymentStatusId => _$this._paymentStatusId;
|
||||
set paymentStatusId(int paymentStatusId) =>
|
||||
_$this._paymentStatusId = paymentStatusId;
|
||||
|
||||
String _transactionReference;
|
||||
String get transactionReference => _$this._transactionReference;
|
||||
set transactionReference(String transactionReference) =>
|
||||
|
|
@ -683,6 +726,8 @@ class PaymentEntityBuilder
|
|||
PaymentEntityBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_amount = _$v.amount;
|
||||
_refunded = _$v.refunded;
|
||||
_paymentStatusId = _$v.paymentStatusId;
|
||||
_transactionReference = _$v.transactionReference;
|
||||
_paymentDate = _$v.paymentDate;
|
||||
_paymentTypeId = _$v.paymentTypeId;
|
||||
|
|
@ -718,6 +763,8 @@ class PaymentEntityBuilder
|
|||
final _$result = _$v ??
|
||||
new _$PaymentEntity._(
|
||||
amount: amount,
|
||||
refunded: refunded,
|
||||
paymentStatusId: paymentStatusId,
|
||||
transactionReference: transactionReference,
|
||||
paymentDate: paymentDate,
|
||||
paymentTypeId: paymentTypeId,
|
||||
|
|
|
|||
|
|
@ -128,11 +128,15 @@ class _$PaymentTypeEntitySerializer
|
|||
Iterable serialize(Serializers serializers, PaymentTypeEntity object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(int)),
|
||||
'name',
|
||||
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
||||
];
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add('id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(int)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -148,14 +152,14 @@ class _$PaymentTypeEntitySerializer
|
|||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case 'name':
|
||||
result.name = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -352,17 +356,15 @@ class PaymentTypeItemResponseBuilder
|
|||
}
|
||||
|
||||
class _$PaymentTypeEntity extends PaymentTypeEntity {
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
final int id;
|
||||
|
||||
factory _$PaymentTypeEntity([void updates(PaymentTypeEntityBuilder b)]) =>
|
||||
(new PaymentTypeEntityBuilder()..update(updates)).build();
|
||||
|
||||
_$PaymentTypeEntity._({this.id, this.name}) : super._() {
|
||||
if (id == null)
|
||||
throw new BuiltValueNullFieldError('PaymentTypeEntity', 'id');
|
||||
_$PaymentTypeEntity._({this.name, this.id}) : super._() {
|
||||
if (name == null)
|
||||
throw new BuiltValueNullFieldError('PaymentTypeEntity', 'name');
|
||||
}
|
||||
|
|
@ -379,19 +381,19 @@ class _$PaymentTypeEntity extends PaymentTypeEntity {
|
|||
bool operator ==(dynamic other) {
|
||||
if (identical(other, this)) return true;
|
||||
if (other is! PaymentTypeEntity) return false;
|
||||
return id == other.id && name == other.name;
|
||||
return name == other.name && id == other.id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return $jf($jc($jc(0, id.hashCode), name.hashCode));
|
||||
return $jf($jc($jc(0, name.hashCode), id.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('PaymentTypeEntity')
|
||||
..add('id', id)
|
||||
..add('name', name))
|
||||
..add('name', name)
|
||||
..add('id', id))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -400,20 +402,20 @@ class PaymentTypeEntityBuilder
|
|||
implements Builder<PaymentTypeEntity, PaymentTypeEntityBuilder> {
|
||||
_$PaymentTypeEntity _$v;
|
||||
|
||||
int _id;
|
||||
int get id => _$this._id;
|
||||
set id(int id) => _$this._id = id;
|
||||
|
||||
String _name;
|
||||
String get name => _$this._name;
|
||||
set name(String name) => _$this._name = name;
|
||||
|
||||
int _id;
|
||||
int get id => _$this._id;
|
||||
set id(int id) => _$this._id = id;
|
||||
|
||||
PaymentTypeEntityBuilder();
|
||||
|
||||
PaymentTypeEntityBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_id = _$v.id;
|
||||
_name = _$v.name;
|
||||
_id = _$v.id;
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
|
|
@ -432,7 +434,7 @@ class PaymentTypeEntityBuilder
|
|||
|
||||
@override
|
||||
_$PaymentTypeEntity build() {
|
||||
final _$result = _$v ?? new _$PaymentTypeEntity._(id: id, name: name);
|
||||
final _$result = _$v ?? new _$PaymentTypeEntity._(name: name, id: id);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:memoize/memoize.dart';
|
||||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart';
|
||||
|
||||
ClientEntity paymentClientSelector(int paymentId, BuildContext context) {
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final payment = state.paymentState.map[paymentId];
|
||||
final invoice = state.invoiceState.map[payment.invoiceId];
|
||||
return state.clientState.map[invoice.clientId];
|
||||
}
|
||||
|
||||
var memoizedDropdownPaymentList = memo2(
|
||||
(BuiltMap<int, PaymentEntity> paymentMap, BuiltList<int> paymentList) =>
|
||||
dropdownPaymentsSelector(paymentMap, paymentList));
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class PaymentListVM {
|
|||
isLoaded: state.paymentState.isLoaded,
|
||||
filter: state.paymentUIState.listUIState.filter,
|
||||
onPaymentTap: (context, payment) {
|
||||
store.dispatch(EditPayment(payment: payment, context: context));
|
||||
store.dispatch(ViewPayment(paymentId: payment.id, context: context));
|
||||
},
|
||||
onEntityAction: (context, payment, action) {
|
||||
switch (action) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/redux/payment/payment_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/actions_menu_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/icon_message.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/one_value_header.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/two_value_header.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment/view/payment_view_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
class PaymentView extends StatefulWidget {
|
||||
final PaymentViewVM viewModel;
|
||||
|
|
@ -21,6 +26,7 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
Widget build(BuildContext context) {
|
||||
final viewModel = widget.viewModel;
|
||||
final payment = viewModel.payment;
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
|
@ -42,14 +48,29 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
)
|
||||
],
|
||||
),
|
||||
body: FormCard(children: [
|
||||
// STARTER: widgets - do not remove comment
|
||||
Text(payment.amount.toString(), style: Theme.of(context).textTheme.title),
|
||||
SizedBox(height: 12.0),
|
||||
|
||||
Text(payment.transactionReference),
|
||||
Text(payment.privateNotes),
|
||||
]),
|
||||
);
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
payment.refunded > 0
|
||||
? TwoValueHeader(
|
||||
label1: localization.amount,
|
||||
value1: formatNumber(payment.amount, context,
|
||||
clientId:
|
||||
paymentClientSelector(payment.id, context).id),
|
||||
label2: localization.refunded,
|
||||
value2: formatNumber(payment.refunded, context,
|
||||
clientId:
|
||||
paymentClientSelector(payment.id, context).id),
|
||||
)
|
||||
: OneValueHeader(
|
||||
label: localization.amount,
|
||||
value: formatNumber(payment.amount, context,
|
||||
clientId:
|
||||
paymentClientSelector(payment.id, context).id),
|
||||
),
|
||||
payment.privateNotes != null && payment.privateNotes.isNotEmpty
|
||||
? IconMessage(payment.privateNotes)
|
||||
: Container(),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ class AppLocalization {
|
|||
'history': 'History',
|
||||
'payment': 'Payment',
|
||||
'payments': 'Payments',
|
||||
'refunded': 'Refunded',
|
||||
'payment_type': 'Payment Type',
|
||||
'transaction_reference': 'Transaction Reference',
|
||||
'enter_payment': 'Enter Payment',
|
||||
|
|
@ -7536,6 +7537,8 @@ class AppLocalization {
|
|||
|
||||
String get payments => _localizedValues[locale.languageCode]['payments'];
|
||||
|
||||
String get refunded => _localizedValues[locale.languageCode]['refunded'];
|
||||
|
||||
String get paymentType =>
|
||||
_localizedValues[locale.languageCode]['payment_type'];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue