From 8ddc14c4d0795a0eda11d9693b81868acb6034e7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 21 Oct 2020 15:12:54 +1100 Subject: [PATCH] Working on check data script --- app/Http/ValidationRules/PaymentAmountsBalanceRule.php | 6 +++--- app/Repositories/PaymentRepository.php | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/Http/ValidationRules/PaymentAmountsBalanceRule.php b/app/Http/ValidationRules/PaymentAmountsBalanceRule.php index 8c2de136a5..cc9ff5251b 100644 --- a/app/Http/ValidationRules/PaymentAmountsBalanceRule.php +++ b/app/Http/ValidationRules/PaymentAmountsBalanceRule.php @@ -73,9 +73,9 @@ class PaymentAmountsBalanceRule implements Rule return true; } // if no invoices are present, then this is an unapplied payment, let this pass validation! -info("payment amounts = {$payment_amounts}"); -info("invoice amounts = {$invoice_amounts}"); - //return true; +// info("payment amounts = {$payment_amounts}"); +// info("invoice amounts = {$invoice_amounts}"); + return $payment_amounts >= $invoice_amounts; } } diff --git a/app/Repositories/PaymentRepository.php b/app/Repositories/PaymentRepository.php index 60adc5200b..f837f0a317 100644 --- a/app/Repositories/PaymentRepository.php +++ b/app/Repositories/PaymentRepository.php @@ -79,8 +79,6 @@ class PaymentRepository extends BaseRepository $is_existing_payment = false; $client = Client::find($data['client_id']); -info("client paid to date {$client->paid_to_date}"); - /*We only update the paid to date ONCE per payment*/ if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) { if ($data['amount'] == '') { @@ -89,23 +87,16 @@ info("client paid to date {$client->paid_to_date}"); $client->service()->updatePaidToDate($data['amount'])->save(); -info("client paid to date {$client->paid_to_date}"); } if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) { - $_credit_totals = array_sum(array_column($data['credits'], 'amount')); $data['amount'] -= $_credit_totals; - info("credit totals = {$_credit_totals}"); - $client->service()->updatePaidToDate($_credit_totals)->save(); - -info("client paid to date {$client->paid_to_date}"); - } }