mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 16:00:56 -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;
|
$total_invoice_payments = 0;
|
||||||
|
|
||||||
foreach ($client->invoices as $invoice) {
|
foreach ($client->invoices as $invoice) {
|
||||||
info(print_r($invoice->payments,1));
|
$total_amount = $invoice->payments->sum('pivot.amount');
|
||||||
$total_amount = $invoice->payments->sum('pivot.amount'); // the problem with this is that this also will sum the credits
|
|
||||||
$total_refund = $invoice->payments->sum('pivot.refunded');
|
$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)
|
foreach($client->payments as $payment)
|
||||||
|
@ -202,7 +202,7 @@ class BaseController extends Controller
|
|||||||
$updated_at = date('Y-m-d H:i:s', $updated_at);
|
$updated_at = date('Y-m-d H:i:s', $updated_at);
|
||||||
|
|
||||||
$query->with(
|
$query->with(
|
||||||
[ 'user.company_users',
|
[
|
||||||
'company' => function ($query) use ($updated_at) {
|
'company' => function ($query) use ($updated_at) {
|
||||||
$query->whereNotNull('updated_at')->with('documents');
|
$query->whereNotNull('updated_at')->with('documents');
|
||||||
},
|
},
|
||||||
|
@ -73,6 +73,9 @@ class PaymentAmountsBalanceRule implements Rule
|
|||||||
return true;
|
return true;
|
||||||
} // if no invoices are present, then this is an unapplied payment, let this pass validation!
|
} // 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;
|
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 (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'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
info("client paid to date {$client->paid_to_date}");
|
$_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}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class CompanyUserTransformer extends EntityTransformer
|
|||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
// 'account',
|
// 'account',
|
||||||
// 'company',
|
// 'company',
|
||||||
// 'user',
|
'user',
|
||||||
// 'token'
|
// 'token'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user