Simplify credits
This commit is contained in:
parent
22611711ba
commit
7f7fcb8768
|
|
@ -130,6 +130,7 @@ const String kPaymentTypeMasterCard = '6';
|
|||
const String kPaymentTypeAmEx = '7';
|
||||
const String kPaymentTypeDiners = '9';
|
||||
const String kPaymentTypeDiscover = '8';
|
||||
const String kPaymentTypeCredit = '32';
|
||||
|
||||
const String kPlanFree = '';
|
||||
const String kPlanPro = 'pro';
|
||||
|
|
|
|||
|
|
@ -868,7 +868,11 @@ abstract class InvoiceEntity extends Object
|
|||
}
|
||||
|
||||
if (isPayable && userCompany.canCreate(EntityType.payment)) {
|
||||
actions.add(EntityAction.newPayment);
|
||||
if (isCredit) {
|
||||
actions.add(EntityAction.applyCredit);
|
||||
} else {
|
||||
actions.add(EntityAction.newPayment);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isSent && !isRecurring) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ class EntityAction extends EnumClass {
|
|||
static const EntityAction cloneToRecurring = _$cloneToRecurring;
|
||||
static const EntityAction convertToInvoice = _$convertToInvoice;
|
||||
static const EntityAction approve = _$approve;
|
||||
static const EntityAction apply = _$apply;
|
||||
static const EntityAction applyCredit = _$applyCredit;
|
||||
static const EntityAction applyPayment = _$applyPayment;
|
||||
static const EntityAction download = _$download;
|
||||
static const EntityAction bulkDownload = _$bulkDownload;
|
||||
static const EntityAction emailInvoice = _$emailInvoice;
|
||||
|
|
@ -83,7 +84,7 @@ class EntityAction extends EnumClass {
|
|||
static const EntityAction clientPortal = _$clientPortal;
|
||||
static const EntityAction newPayment = _$newPayment;
|
||||
static const EntityAction settings = _$settings;
|
||||
static const EntityAction refund = _$refund;
|
||||
static const EntityAction refundPayment = _$refundPayment;
|
||||
static const EntityAction viewPdf = _$viewPdf;
|
||||
static const EntityAction viewStatement = _$viewStatement;
|
||||
static const EntityAction more = _$more;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ const EntityAction _$cloneToRecurring =
|
|||
const EntityAction _$convertToInvoice =
|
||||
const EntityAction._('convertToInvoice');
|
||||
const EntityAction _$approve = const EntityAction._('approve');
|
||||
const EntityAction _$apply = const EntityAction._('apply');
|
||||
const EntityAction _$applyCredit = const EntityAction._('applyCredit');
|
||||
const EntityAction _$applyPayment = const EntityAction._('applyPayment');
|
||||
const EntityAction _$download = const EntityAction._('download');
|
||||
const EntityAction _$bulkDownload = const EntityAction._('bulkDownload');
|
||||
const EntityAction _$emailInvoice = const EntityAction._('emailInvoice');
|
||||
|
|
@ -52,7 +53,7 @@ const EntityAction _$newVendor = const EntityAction._('newVendor');
|
|||
const EntityAction _$clientPortal = const EntityAction._('clientPortal');
|
||||
const EntityAction _$newPayment = const EntityAction._('newPayment');
|
||||
const EntityAction _$settings = const EntityAction._('settings');
|
||||
const EntityAction _$refund = const EntityAction._('refund');
|
||||
const EntityAction _$refundPayment = const EntityAction._('refundPayment');
|
||||
const EntityAction _$viewPdf = const EntityAction._('viewPdf');
|
||||
const EntityAction _$viewStatement = const EntityAction._('viewStatement');
|
||||
const EntityAction _$more = const EntityAction._('more');
|
||||
|
|
@ -100,8 +101,10 @@ EntityAction _$valueOf(String name) {
|
|||
return _$convertToInvoice;
|
||||
case 'approve':
|
||||
return _$approve;
|
||||
case 'apply':
|
||||
return _$apply;
|
||||
case 'applyCredit':
|
||||
return _$applyCredit;
|
||||
case 'applyPayment':
|
||||
return _$applyPayment;
|
||||
case 'download':
|
||||
return _$download;
|
||||
case 'bulkDownload':
|
||||
|
|
@ -152,8 +155,8 @@ EntityAction _$valueOf(String name) {
|
|||
return _$newPayment;
|
||||
case 'settings':
|
||||
return _$settings;
|
||||
case 'refund':
|
||||
return _$refund;
|
||||
case 'refundPayment':
|
||||
return _$refundPayment;
|
||||
case 'viewPdf':
|
||||
return _$viewPdf;
|
||||
case 'viewStatement':
|
||||
|
|
@ -205,7 +208,8 @@ final BuiltSet<EntityAction> _$values =
|
|||
_$cloneToRecurring,
|
||||
_$convertToInvoice,
|
||||
_$approve,
|
||||
_$apply,
|
||||
_$applyCredit,
|
||||
_$applyPayment,
|
||||
_$download,
|
||||
_$bulkDownload,
|
||||
_$emailInvoice,
|
||||
|
|
@ -231,7 +235,7 @@ final BuiltSet<EntityAction> _$values =
|
|||
_$clientPortal,
|
||||
_$newPayment,
|
||||
_$settings,
|
||||
_$refund,
|
||||
_$refundPayment,
|
||||
_$viewPdf,
|
||||
_$viewStatement,
|
||||
_$more,
|
||||
|
|
|
|||
|
|
@ -393,11 +393,11 @@ abstract class PaymentEntity extends Object
|
|||
}
|
||||
|
||||
if (applied < amount) {
|
||||
actions.add(EntityAction.apply);
|
||||
actions.add(EntityAction.applyPayment);
|
||||
}
|
||||
|
||||
if (completedAmount > 0) {
|
||||
actions.add(EntityAction.refund);
|
||||
actions.add(EntityAction.refundPayment);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
|
|
@ -530,10 +531,11 @@ Future handleCreditAction(
|
|||
..entityType = EntityType.recurringInvoice
|
||||
..designId = designId));
|
||||
break;
|
||||
case EntityAction.newPayment:
|
||||
case EntityAction.applyCredit:
|
||||
createEntity(
|
||||
context: context,
|
||||
entity: PaymentEntity(state: state).rebuild((b) => b
|
||||
..typeId = kPaymentTypeCredit
|
||||
..clientId = credit.clientId
|
||||
..credits.addAll(credits
|
||||
.map((credit) => PaymentableEntity.fromCredit(credit))
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ void handlePaymentAction(
|
|||
case EntityAction.edit:
|
||||
editEntity(context: context, entity: payment);
|
||||
break;
|
||||
case EntityAction.apply:
|
||||
case EntityAction.applyPayment:
|
||||
viewEntity(entity: payment);
|
||||
WidgetsBinding.instance.addPostFrameCallback((duration) {
|
||||
editEntity(
|
||||
|
|
@ -328,7 +328,7 @@ void handlePaymentAction(
|
|||
entity: payment.rebuild((b) => b..isApplying = true));
|
||||
});
|
||||
break;
|
||||
case EntityAction.refund:
|
||||
case EntityAction.refundPayment:
|
||||
viewEntity(entity: payment);
|
||||
WidgetsBinding.instance.addPostFrameCallback((duration) {
|
||||
if (payment.invoicePaymentables.length == 1) {
|
||||
|
|
|
|||
|
|
@ -167,9 +167,9 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
),
|
||||
BottomButtons(
|
||||
entity: payment,
|
||||
action1: EntityAction.apply,
|
||||
action1: EntityAction.applyPayment,
|
||||
action1Enabled: payment.applied < payment.amount,
|
||||
action2: EntityAction.refund,
|
||||
action2: EntityAction.refundPayment,
|
||||
action2Enabled: payment.refunded < payment.amount,
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -573,6 +573,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
'taxes': 'Taxes',
|
||||
'surcharge': 'Surcharge',
|
||||
'apply_payment': 'Apply Payment',
|
||||
'apply_credit': 'Apply Credit',
|
||||
'apply': 'Apply',
|
||||
'unapplied': 'Unapplied',
|
||||
'select_label': 'Select Label',
|
||||
|
|
@ -62802,6 +62803,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]['direct_debit'] ??
|
||||
_localizedValues['en']['direct_debit'];
|
||||
|
||||
String get applyCredit =>
|
||||
_localizedValues[localeCode]['apply_credit'] ??
|
||||
_localizedValues['en']['apply_credit'];
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
|
|
@ -70,14 +70,15 @@ IconData getEntityActionIcon(EntityAction entityAction) {
|
|||
return Icons.stop;
|
||||
case EntityAction.settings:
|
||||
return Icons.settings;
|
||||
case EntityAction.refund:
|
||||
case EntityAction.refundPayment:
|
||||
case EntityAction.cancel:
|
||||
return Icons.remove_circle_outline;
|
||||
case EntityAction.reverse:
|
||||
return Icons.undo;
|
||||
case EntityAction.copy:
|
||||
return Icons.content_copy;
|
||||
case EntityAction.apply:
|
||||
case EntityAction.applyPayment:
|
||||
case EntityAction.applyCredit:
|
||||
return Icons.payment;
|
||||
case EntityAction.disconnect:
|
||||
return MdiIcons.lanDisconnect;
|
||||
|
|
|
|||
Loading…
Reference in New Issue