Show if a payment is partially applied

This commit is contained in:
Hillel Coren 2021-02-16 12:53:29 +02:00
parent 3c3cac569a
commit 872f599600
5 changed files with 13 additions and 2 deletions

View File

@ -81,6 +81,7 @@ class PaymentStatusColors {
kPaymentStatusPartiallyRefunded: _colorTheme.colorPrimary,
kPaymentStatusRefunded: _colorTheme.colorLightGray,
kPaymentStatusUnapplied: _colorTheme.colorDarkGray,
kPaymentStatusPartiallyUnapplied: _colorTheme.colorDarkGray,
};
}
}

View File

@ -403,6 +403,7 @@ const String kPermissionCreateAll = 'create_all';
const String kPermissionViewAll = 'view_all';
const String kPermissionEditAll = 'edit_all';
const String kPaymentStatusPartiallyUnapplied = '-2';
const String kPaymentStatusUnapplied = '-1';
const String kPaymentStatusPending = '1';
const String kPaymentStatusCancelled = '2';
@ -412,6 +413,7 @@ const String kPaymentStatusPartiallyRefunded = '5';
const String kPaymentStatusRefunded = '6';
const kPaymentStatuses = {
kPaymentStatusPartiallyUnapplied: 'partially_unapplied',
kPaymentStatusUnapplied: 'unapplied',
kPaymentStatusPending: 'pending',
kPaymentStatusCancelled: 'cancelled',

View File

@ -215,7 +215,9 @@ abstract class PaymentEntity extends Object
String get calculatedStatusId {
if (applied < amount) {
return kPaymentStatusUnapplied;
return applied == 0
? kPaymentStatusUnapplied
: kPaymentStatusPartiallyUnapplied;
}
return statusId;

View File

@ -29,6 +29,7 @@ class EntityStatusChip extends StatelessWidget {
switch (entity.entityType) {
case EntityType.payment:
print('## PAYMENT');
final payment = entity as PaymentEntity;
label = kPaymentStatuses[payment.calculatedStatusId];
color = PaymentStatusColors(state.prefState.colorThemeModel)
@ -91,8 +92,9 @@ class EntityStatusChip extends StatelessWidget {
return SizedBox();
break;
}
print('## label: $label');
label = localization.lookup(label) ?? '';
if (label.isEmpty) {
label = localization.logged;
}

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
'partially_unapplied': 'Partially Unapplied',
'select_a_gmail_user': 'Please select a user authenticated with Gmail',
'list_long_press': 'List Long Press',
'show_actions': 'Show Actions',
@ -1400,6 +1401,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
'payment_status_5': 'Partially Refunded',
'payment_status_6': 'Refunded',
'payment_status_-1': 'Unapplied',
'payment_status_-2': 'Partially Unapplied',
'net': 'Net',
'client_portal': 'Client Portal',
'show_tasks': 'Show tasks',
@ -53956,6 +53958,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get selectAGmailUser =>
_localizedValues[localeCode]['select_a_gmail_user'] ?? '';
String get partiallyUnapplied =>
_localizedValues[localeCode]['partiallyUnapplied'] ?? '';
String lookup(String key) {
final lookupKey = toSnakeCase(key);