Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Apr 5, 2022
2 parents 564d2ea + 2530b90 commit 9447968
Show file tree
Hide file tree
Showing 13 changed files with 21,021 additions and 26,316 deletions.
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Constants {
}

// TODO remove version once #46609 is fixed
const String kClientVersion = '5.0.77';
const String kClientVersion = '5.0.78';
const String kMinServerVersion = '5.0.4';

const String kAppName = 'Invoice Ninja';
Expand Down
7 changes: 0 additions & 7 deletions lib/data/models/payment_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ abstract class PaymentEntity extends Object
clientContactId: '',
currencyId: '',
invitationId: '',
isForInvoice: false,
isApplying: false,
);
}
Expand Down Expand Up @@ -195,12 +194,6 @@ abstract class PaymentEntity extends Object
@BuiltValueField(wireName: 'currency_id')
String get currencyId;

@nullable
bool get isForInvoice;

@nullable
bool get isForCredit;

@nullable
bool get isApplying;

Expand Down
56 changes: 6 additions & 50 deletions lib/data/models/payment_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/redux/credit/credit_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ Future handleCreditAction(
createEntity(
context: context,
entity: PaymentEntity(state: state).rebuild((b) => b
..isForCredit = true
..typeId = kPaymentTypeCredit
..clientId = credit.clientId
..credits.addAll(credits
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/credit/credit_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ List<String> dropdownCreditSelector(
invoice: creditB,
clientMap: clientMap,
sortAscending: true,
sortField: ClientFields.name,
sortField: CreditFields.number,
userMap: userMap);
});

Expand Down
1 change: 0 additions & 1 deletion lib/redux/invoice/invoice_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
createEntity(
context: context,
entity: PaymentEntity(state: state).rebuild((b) => b
..isForInvoice = true
..clientId = invoice.clientId
..invoices.addAll(invoices
.where((invoice) => !(invoice as InvoiceEntity).isPaid)
Expand Down
69 changes: 35 additions & 34 deletions lib/ui/payment/edit/payment_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ class _PaymentEditState extends State<PaymentEdit> {
final localization = AppLocalization.of(context);

final invoicePaymentables = payment.invoices.toList();
if ((payment.isForInvoice != true || invoicePaymentables.isEmpty) &&
invoicePaymentables
.where((paymentable) => paymentable.isEmpty)
.isEmpty) {
if (invoicePaymentables
.where((paymentable) => paymentable.isEmpty)
.isEmpty) {
invoicePaymentables.add(PaymentableEntity());
}

Expand All @@ -177,18 +176,27 @@ class _PaymentEditState extends State<PaymentEdit> {
creditTotal += credit.amount;
});

String amountPlaceholder;
if (paymentTotal != 0) {
amountPlaceholder = '${localization.amount} ';
if (creditTotal == 0) {
amountPlaceholder +=
formatNumber(paymentTotal, context, clientId: payment.clientId);
} else {
amountPlaceholder += formatNumber(paymentTotal - creditTotal, context,
clientId: payment.clientId) +
' + ${localization.credit} ' +
formatNumber(creditTotal, context, clientId: payment.clientId);
}
String amountPlaceholder = localization.amount;

if (payment.invoices.length > 1) {
amountPlaceholder += ' • ' +
localization.total +
' ' +
formatNumber(paymentTotal, context, clientId: payment.clientId);
}

if (payment.credits.length > 1) {
amountPlaceholder += ' • ' +
localization.credit +
' ' +
formatNumber(creditTotal, context, clientId: payment.clientId);
}

double limit;
if (payment.amount != 0) {
limit = payment.amount - paymentTotal;
} else if (creditTotal != 0) {
limit = creditTotal - paymentTotal;
}

final body = Form(
Expand Down Expand Up @@ -222,17 +230,14 @@ class _PaymentEditState extends State<PaymentEdit> {
state.userState.map,
state.staticState),
),
if (payment.isForInvoice != true && payment.isForCredit != true)
DecoratedFormField(
controller: _amountController,
autocorrect: false,
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),
label: paymentTotal == 0
? localization.amount
: amountPlaceholder,
onSavePressed: viewModel.onSavePressed,
),
DecoratedFormField(
controller: _amountController,
autocorrect: false,
keyboardType: TextInputType.numberWithOptions(
decimal: true, signed: true),
label: amountPlaceholder,
onSavePressed: viewModel.onSavePressed,
),
] else
DecoratedFormField(
controller: _numberController,
Expand All @@ -251,9 +256,7 @@ class _PaymentEditState extends State<PaymentEdit> {
paymentable: invoicePaymentables[index],
index: index,
entityType: EntityType.invoice,
limit: payment.amount == 0
? null
: payment.amount - paymentTotal,
limit: limit,
),
if (payment.isApplying != true)
DatePicker(
Expand All @@ -278,8 +281,7 @@ class _PaymentEditState extends State<PaymentEdit> {
.rebuild((b) => b..typeId = paymentType?.id ?? '')),
),
if (payment.isNew || payment.isApplying == true)
if (payment.isForInvoice != true &&
state.company.isModuleEnabled(EntityType.credit))
if (state.company.isModuleEnabled(EntityType.credit))
for (var index = 0;
index < creditPaymentables.length;
index++)
Expand Down Expand Up @@ -727,7 +729,7 @@ class _PaymentableEditorState extends State<PaymentableEditor> {
autocorrect: false,
keyboardType:
TextInputType.numberWithOptions(decimal: true, signed: true),
label: payment.isForInvoice == true
label: widget.entityType == EntityType.invoice
? localization.amount
: localization.applied,
onSavePressed: viewModel.onSavePressed,
Expand All @@ -736,7 +738,6 @@ class _PaymentableEditorState extends State<PaymentableEditor> {
],
if ((widget.entityType == EntityType.invoice &&
payment.invoices.isNotEmpty &&
payment.isForInvoice != true &&
_invoiceId != null) ||
(widget.entityType == EntityType.credit &&
payment.credits.isNotEmpty &&
Expand Down
4 changes: 1 addition & 3 deletions lib/ui/payment/edit/payment_edit_vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ class PaymentEditVM {
showDialog<ErrorDialog>(
context: navigatorKey.currentContext,
builder: (BuildContext context) {
return ErrorDialog(payment.isForCredit
? localization.creditIsMoreThanInvoice
: localization.negativePaymentError);
return ErrorDialog(localization.negativePaymentError);
});
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/settings/templates_and_reminders.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ class _TemplatesAndRemindersState extends State<TemplatesAndReminders>
_defaultBody = html2md.convert(_defaultBody);
}
});

_onChanged();
}

void _onTextChanged() {
Expand Down Expand Up @@ -353,6 +351,7 @@ class _TemplatesAndRemindersState extends State<TemplatesAndReminders>
showBlank: false,
onChanged: (dynamic value) => setState(() {
_loadTemplate(value);
_onChanged();
viewModel.onTemplateChanged(value);
}),
items: EmailTemplate.values.where((value) {
Expand Down
Loading

0 comments on commit 9447968

Please sign in to comment.