This commit is contained in:
Hillel Coren 2018-08-31 10:00:47 -07:00
parent 7b72d526a9
commit 2d1b3997b1
7 changed files with 143 additions and 54 deletions

View File

@ -58,7 +58,8 @@ abstract class PaymentEntity extends Object with BaseEntity implements Built<Pay
privateNotes: '', privateNotes: '',
exchangeRate: 0.0, exchangeRate: 0.0,
exchangeCurrencyId: 0, exchangeCurrencyId: 0,
refunded: 0.0,
paymentStatusId: 0,
updatedAt: 0, updatedAt: 0,
archivedAt: 0, archivedAt: 0,
isDeleted: false, isDeleted: false,
@ -73,6 +74,11 @@ abstract class PaymentEntity extends Object with BaseEntity implements Built<Pay
double get amount; double get amount;
double get refunded;
@BuiltValueField(wireName: 'payment_status_id')
int get paymentStatusId;
@BuiltValueField(wireName: 'transaction_reference') @BuiltValueField(wireName: 'transaction_reference')
String get transactionReference; String get transactionReference;

View File

@ -127,6 +127,12 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
'amount', 'amount',
serializers.serialize(object.amount, serializers.serialize(object.amount,
specifiedType: const FullType(double)), 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', 'transaction_reference',
serializers.serialize(object.transactionReference, serializers.serialize(object.transactionReference,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
@ -207,6 +213,14 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
result.amount = serializers.deserialize(value, result.amount = serializers.deserialize(value,
specifiedType: const FullType(double)) as double; specifiedType: const FullType(double)) as double;
break; 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': case 'transaction_reference':
result.transactionReference = serializers.deserialize(value, result.transactionReference = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
@ -455,6 +469,10 @@ class _$PaymentEntity extends PaymentEntity {
@override @override
final double amount; final double amount;
@override @override
final double refunded;
@override
final int paymentStatusId;
@override
final String transactionReference; final String transactionReference;
@override @override
final String paymentDate; final String paymentDate;
@ -488,6 +506,8 @@ class _$PaymentEntity extends PaymentEntity {
_$PaymentEntity._( _$PaymentEntity._(
{this.amount, {this.amount,
this.refunded,
this.paymentStatusId,
this.transactionReference, this.transactionReference,
this.paymentDate, this.paymentDate,
this.paymentTypeId, this.paymentTypeId,
@ -505,6 +525,10 @@ class _$PaymentEntity extends PaymentEntity {
: super._() { : super._() {
if (amount == null) if (amount == null)
throw new BuiltValueNullFieldError('PaymentEntity', 'amount'); throw new BuiltValueNullFieldError('PaymentEntity', 'amount');
if (refunded == null)
throw new BuiltValueNullFieldError('PaymentEntity', 'refunded');
if (paymentStatusId == null)
throw new BuiltValueNullFieldError('PaymentEntity', 'paymentStatusId');
if (transactionReference == null) if (transactionReference == null)
throw new BuiltValueNullFieldError( throw new BuiltValueNullFieldError(
'PaymentEntity', 'transactionReference'); 'PaymentEntity', 'transactionReference');
@ -536,6 +560,8 @@ class _$PaymentEntity extends PaymentEntity {
if (identical(other, this)) return true; if (identical(other, this)) return true;
if (other is! PaymentEntity) return false; if (other is! PaymentEntity) return false;
return amount == other.amount && return amount == other.amount &&
refunded == other.refunded &&
paymentStatusId == other.paymentStatusId &&
transactionReference == other.transactionReference && transactionReference == other.transactionReference &&
paymentDate == other.paymentDate && paymentDate == other.paymentDate &&
paymentTypeId == other.paymentTypeId && paymentTypeId == other.paymentTypeId &&
@ -569,8 +595,14 @@ class _$PaymentEntity extends PaymentEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
0, $jc(
amount $jc(
0,
amount
.hashCode),
refunded
.hashCode),
paymentStatusId
.hashCode), .hashCode),
transactionReference transactionReference
.hashCode), .hashCode),
@ -593,6 +625,8 @@ class _$PaymentEntity extends PaymentEntity {
String toString() { String toString() {
return (newBuiltValueToStringHelper('PaymentEntity') return (newBuiltValueToStringHelper('PaymentEntity')
..add('amount', amount) ..add('amount', amount)
..add('refunded', refunded)
..add('paymentStatusId', paymentStatusId)
..add('transactionReference', transactionReference) ..add('transactionReference', transactionReference)
..add('paymentDate', paymentDate) ..add('paymentDate', paymentDate)
..add('paymentTypeId', paymentTypeId) ..add('paymentTypeId', paymentTypeId)
@ -619,6 +653,15 @@ class PaymentEntityBuilder
double get amount => _$this._amount; double get amount => _$this._amount;
set amount(double amount) => _$this._amount = 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 _transactionReference;
String get transactionReference => _$this._transactionReference; String get transactionReference => _$this._transactionReference;
set transactionReference(String transactionReference) => set transactionReference(String transactionReference) =>
@ -683,6 +726,8 @@ class PaymentEntityBuilder
PaymentEntityBuilder get _$this { PaymentEntityBuilder get _$this {
if (_$v != null) { if (_$v != null) {
_amount = _$v.amount; _amount = _$v.amount;
_refunded = _$v.refunded;
_paymentStatusId = _$v.paymentStatusId;
_transactionReference = _$v.transactionReference; _transactionReference = _$v.transactionReference;
_paymentDate = _$v.paymentDate; _paymentDate = _$v.paymentDate;
_paymentTypeId = _$v.paymentTypeId; _paymentTypeId = _$v.paymentTypeId;
@ -718,6 +763,8 @@ class PaymentEntityBuilder
final _$result = _$v ?? final _$result = _$v ??
new _$PaymentEntity._( new _$PaymentEntity._(
amount: amount, amount: amount,
refunded: refunded,
paymentStatusId: paymentStatusId,
transactionReference: transactionReference, transactionReference: transactionReference,
paymentDate: paymentDate, paymentDate: paymentDate,
paymentTypeId: paymentTypeId, paymentTypeId: paymentTypeId,

View File

@ -128,11 +128,15 @@ class _$PaymentTypeEntitySerializer
Iterable serialize(Serializers serializers, PaymentTypeEntity object, Iterable serialize(Serializers serializers, PaymentTypeEntity object,
{FullType specifiedType = FullType.unspecified}) { {FullType specifiedType = FullType.unspecified}) {
final result = <Object>[ final result = <Object>[
'id',
serializers.serialize(object.id, specifiedType: const FullType(int)),
'name', 'name',
serializers.serialize(object.name, specifiedType: const FullType(String)), 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; return result;
} }
@ -148,14 +152,14 @@ class _$PaymentTypeEntitySerializer
iterator.moveNext(); iterator.moveNext();
final dynamic value = iterator.current; final dynamic value = iterator.current;
switch (key) { switch (key) {
case 'id':
result.id = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'name': case 'name':
result.name = serializers.deserialize(value, result.name = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; 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 { class _$PaymentTypeEntity extends PaymentTypeEntity {
@override
final int id;
@override @override
final String name; final String name;
@override
final int id;
factory _$PaymentTypeEntity([void updates(PaymentTypeEntityBuilder b)]) => factory _$PaymentTypeEntity([void updates(PaymentTypeEntityBuilder b)]) =>
(new PaymentTypeEntityBuilder()..update(updates)).build(); (new PaymentTypeEntityBuilder()..update(updates)).build();
_$PaymentTypeEntity._({this.id, this.name}) : super._() { _$PaymentTypeEntity._({this.name, this.id}) : super._() {
if (id == null)
throw new BuiltValueNullFieldError('PaymentTypeEntity', 'id');
if (name == null) if (name == null)
throw new BuiltValueNullFieldError('PaymentTypeEntity', 'name'); throw new BuiltValueNullFieldError('PaymentTypeEntity', 'name');
} }
@ -379,19 +381,19 @@ class _$PaymentTypeEntity extends PaymentTypeEntity {
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
if (identical(other, this)) return true; if (identical(other, this)) return true;
if (other is! PaymentTypeEntity) return false; if (other is! PaymentTypeEntity) return false;
return id == other.id && name == other.name; return name == other.name && id == other.id;
} }
@override @override
int get hashCode { int get hashCode {
return $jf($jc($jc(0, id.hashCode), name.hashCode)); return $jf($jc($jc(0, name.hashCode), id.hashCode));
} }
@override @override
String toString() { String toString() {
return (newBuiltValueToStringHelper('PaymentTypeEntity') return (newBuiltValueToStringHelper('PaymentTypeEntity')
..add('id', id) ..add('name', name)
..add('name', name)) ..add('id', id))
.toString(); .toString();
} }
} }
@ -400,20 +402,20 @@ class PaymentTypeEntityBuilder
implements Builder<PaymentTypeEntity, PaymentTypeEntityBuilder> { implements Builder<PaymentTypeEntity, PaymentTypeEntityBuilder> {
_$PaymentTypeEntity _$v; _$PaymentTypeEntity _$v;
int _id;
int get id => _$this._id;
set id(int id) => _$this._id = id;
String _name; String _name;
String get name => _$this._name; String get name => _$this._name;
set name(String name) => _$this._name = name; set name(String name) => _$this._name = name;
int _id;
int get id => _$this._id;
set id(int id) => _$this._id = id;
PaymentTypeEntityBuilder(); PaymentTypeEntityBuilder();
PaymentTypeEntityBuilder get _$this { PaymentTypeEntityBuilder get _$this {
if (_$v != null) { if (_$v != null) {
_id = _$v.id;
_name = _$v.name; _name = _$v.name;
_id = _$v.id;
_$v = null; _$v = null;
} }
return this; return this;
@ -432,7 +434,7 @@ class PaymentTypeEntityBuilder
@override @override
_$PaymentTypeEntity build() { _$PaymentTypeEntity build() {
final _$result = _$v ?? new _$PaymentTypeEntity._(id: id, name: name); final _$result = _$v ?? new _$PaymentTypeEntity._(name: name, id: id);
replace(_$result); replace(_$result);
return _$result; return _$result;
} }

View File

@ -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:memoize/memoize.dart';
import 'package:built_collection/built_collection.dart'; import 'package:built_collection/built_collection.dart';
import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/data/models/models.dart';
import 'package:invoiceninja_flutter/redux/ui/list_ui_state.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( var memoizedDropdownPaymentList = memo2(
(BuiltMap<int, PaymentEntity> paymentMap, BuiltList<int> paymentList) => (BuiltMap<int, PaymentEntity> paymentMap, BuiltList<int> paymentList) =>
dropdownPaymentsSelector(paymentMap, paymentList)); dropdownPaymentsSelector(paymentMap, paymentList));

View File

@ -76,7 +76,7 @@ class PaymentListVM {
isLoaded: state.paymentState.isLoaded, isLoaded: state.paymentState.isLoaded,
filter: state.paymentUIState.listUIState.filter, filter: state.paymentUIState.listUIState.filter,
onPaymentTap: (context, payment) { onPaymentTap: (context, payment) {
store.dispatch(EditPayment(payment: payment, context: context)); store.dispatch(ViewPayment(paymentId: payment.id, context: context));
}, },
onEntityAction: (context, payment, action) { onEntityAction: (context, payment, action) {
switch (action) { switch (action) {

View File

@ -1,8 +1,13 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.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/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/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 { class PaymentView extends StatefulWidget {
final PaymentViewVM viewModel; final PaymentViewVM viewModel;
@ -21,35 +26,51 @@ class _PaymentViewState extends State<PaymentView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final payment = viewModel.payment; final payment = viewModel.payment;
final localization = AppLocalization.of(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(payment.transactionReference), title: Text(payment.transactionReference),
actions: payment.isNew actions: payment.isNew
? [] ? []
: [ : [
IconButton( IconButton(
icon: Icon(Icons.edit), icon: Icon(Icons.edit),
onPressed: () { onPressed: () {
viewModel.onEditPressed(context); viewModel.onEditPressed(context);
}, },
), ),
ActionMenuButton( ActionMenuButton(
user: viewModel.company.user, user: viewModel.company.user,
isSaving: viewModel.isSaving, isSaving: viewModel.isSaving,
entity: payment, entity: payment,
onSelected: viewModel.onActionSelected, onSelected: viewModel.onActionSelected,
) )
], ],
), ),
body: FormCard(children: [ body: ListView(
// STARTER: widgets - do not remove comment children: <Widget>[
Text(payment.amount.toString(), style: Theme.of(context).textTheme.title), payment.refunded > 0
SizedBox(height: 12.0), ? TwoValueHeader(
label1: localization.amount,
Text(payment.transactionReference), value1: formatNumber(payment.amount, context,
Text(payment.privateNotes), 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(),
],
));
} }
} }

View File

@ -209,6 +209,7 @@ class AppLocalization {
'history': 'History', 'history': 'History',
'payment': 'Payment', 'payment': 'Payment',
'payments': 'Payments', 'payments': 'Payments',
'refunded': 'Refunded',
'payment_type': 'Payment Type', 'payment_type': 'Payment Type',
'transaction_reference': 'Transaction Reference', 'transaction_reference': 'Transaction Reference',
'enter_payment': 'Enter Payment', 'enter_payment': 'Enter Payment',
@ -7536,6 +7537,8 @@ class AppLocalization {
String get payments => _localizedValues[locale.languageCode]['payments']; String get payments => _localizedValues[locale.languageCode]['payments'];
String get refunded => _localizedValues[locale.languageCode]['refunded'];
String get paymentType => String get paymentType =>
_localizedValues[locale.languageCode]['payment_type']; _localizedValues[locale.languageCode]['payment_type'];