SHow unapplied payments

This commit is contained in:
Hillel Coren 2020-08-09 18:46:20 +03:00
parent 9217d0da3f
commit 414be68cad
5 changed files with 18 additions and 4 deletions

View File

@ -390,6 +390,7 @@ const String kPermissionCreateAll = 'create_all';
const String kPermissionViewAll = 'view_all';
const String kPermissionEditAll = 'edit_all';
const String kPaymentStatusUnapplied = '-1';
const String kPaymentStatusPending = '1';
const String kPaymentStatusCancelled = '2';
const String kPaymentStatusFailed = '3';
@ -398,6 +399,7 @@ const String kPaymentStatusPartiallyRefunded = '5';
const String kPaymentStatusRefunded = '6';
const kPaymentStatuses = {
kPaymentStatusUnapplied: 'unapplied',
kPaymentStatusPending: 'pending',
kPaymentStatusCancelled: 'cancelled',
kPaymentStatusFailed: 'failed',
@ -502,6 +504,7 @@ class PaymentStatusColors {
kPaymentStatusCompleted: kColorGreen,
kPaymentStatusPartiallyRefunded: Colors.purple,
kPaymentStatusRefunded: convertHexStringToColor('#8D3E3F'),
kPaymentStatusUnapplied: convertHexStringToColor('#444444'),
};
}

View File

@ -189,6 +189,14 @@ abstract class PaymentEntity extends Object
BuiltList<PaymentableEntity> get credits;
String get calculatedStatusId {
if (applied < amount) {
return kPaymentStatusUnapplied;
}
return statusId;
}
int compareTo(
{PaymentEntity payment,
String sortField,

View File

@ -24,8 +24,8 @@ class EntityStatusChip extends StatelessWidget {
switch (entity.entityType) {
case EntityType.payment:
final payment = entity as PaymentEntity;
label = kPaymentStatuses[payment.statusId];
color = PaymentStatusColors.colors[payment.statusId];
label = kPaymentStatuses[payment.calculatedStatusId];
color = PaymentStatusColors.colors[payment.calculatedStatusId];
break;
case EntityType.invoice:
final invoice = entity as InvoiceEntity;

View File

@ -205,10 +205,10 @@ class PaymentListItem extends StatelessWidget {
),
Text(
localization
.lookup('payment_status_${payment.statusId}'),
.lookup('payment_status_${payment.calculatedStatusId}'),
style: TextStyle(
color:
PaymentStatusColors.colors[payment.statusId],
PaymentStatusColors.colors[payment.calculatedStatusId],
)),
],
),

View File

@ -15,6 +15,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'unapplied': 'Unapplied',
'select_label': 'Select Label',
'custom_labels': 'Custom Labels',
'record_type': 'Record Type',
@ -39025,6 +39026,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get selectLabel => _localizedValues[localeCode]['select_label'] ?? '';
String get unapplied => _localizedValues[localeCode]['unapplied'] ?? '';
String lookup(String key) {
final lookupKey = toSnakeCase(key);