mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for credit payments
This commit is contained in:
parent
a0b269ce99
commit
3d59717776
@ -322,11 +322,10 @@ class CheckData extends Command
|
||||
$total_invoice_payments = 0;
|
||||
|
||||
foreach ($client->invoices as $invoice) {
|
||||
info(print_r($invoice->payments,1));
|
||||
$total_amount = $invoice->payments->sum('pivot.amount'); // the problem with this is that this also will sum the credits
|
||||
$total_amount = $invoice->payments->sum('pivot.amount');
|
||||
$total_refund = $invoice->payments->sum('pivot.refunded');
|
||||
|
||||
$total_invoice_payments += ($total_amount - $total_refund);
|
||||
$total_invoice_payments += ($total_amount - $total_refund);
|
||||
}
|
||||
|
||||
foreach($client->payments as $payment)
|
||||
|
@ -202,7 +202,7 @@ class BaseController extends Controller
|
||||
$updated_at = date('Y-m-d H:i:s', $updated_at);
|
||||
|
||||
$query->with(
|
||||
[ 'user.company_users',
|
||||
[
|
||||
'company' => function ($query) use ($updated_at) {
|
||||
$query->whereNotNull('updated_at')->with('documents');
|
||||
},
|
||||
|
@ -73,6 +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;
|
||||
return $payment_amounts >= $invoice_amounts;
|
||||
}
|
||||
}
|
||||
|
@ -93,12 +93,18 @@ info("client paid to date {$client->paid_to_date}");
|
||||
}
|
||||
|
||||
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
||||
if ($data['amount'] == '') {
|
||||
$data['amount'] -= array_sum(array_column($data['credits'], 'amount'));
|
||||
}
|
||||
|
||||
|
||||
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
||||
|
||||
info("client paid to date {$client->paid_to_date}");
|
||||
$data['amount'] -= $_credit_totals;
|
||||
|
||||
info("credit totals = {$_credit_totals}");
|
||||
|
||||
$client->service()->updatePaidToDate($_credit_totals)->save();
|
||||
|
||||
|
||||
info("client paid to date {$client->paid_to_date}");
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class CompanyUserTransformer extends EntityTransformer
|
||||
protected $defaultIncludes = [
|
||||
// 'account',
|
||||
// 'company',
|
||||
// 'user',
|
||||
'user',
|
||||
// 'token'
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user