mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 15:14:35 -04:00
Patches for refund validation
This commit is contained in:
parent
98bad77942
commit
15f89fdf33
@ -57,9 +57,10 @@ class ValidRefundableRequest implements Rule
|
|||||||
$request_invoices = request()->has('invoices') ? $this->input['invoices'] : [];
|
$request_invoices = request()->has('invoices') ? $this->input['invoices'] : [];
|
||||||
|
|
||||||
if ($payment->invoices()->exists()) {
|
if ($payment->invoices()->exists()) {
|
||||||
foreach ($payment->invoices as $paymentable_invoice) {
|
$this->checkInvoice($payment->invoices, $request_invoices);
|
||||||
$this->checkInvoice($paymentable_invoice, $request_invoices);
|
// foreach ($payment->invoices as $paymentable_invoice) {
|
||||||
}
|
// $this->checkInvoice($paymentable_invoice, $request_invoices);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request_invoices as $request_invoice) {
|
foreach ($request_invoices as $request_invoice) {
|
||||||
@ -119,22 +120,25 @@ class ValidRefundableRequest implements Rule
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private function checkInvoice($paymentable, $request_invoices)
|
private function checkInvoice($paymentables, $request_invoices)
|
||||||
{
|
{
|
||||||
$record_found = false;
|
$record_found = false;
|
||||||
|
|
||||||
foreach ($request_invoices as $request_invoice) {
|
foreach($paymentables as $paymentable) {
|
||||||
if ($request_invoice['invoice_id'] == $paymentable->pivot->paymentable_id) {
|
foreach ($request_invoices as $request_invoice) {
|
||||||
$record_found = true;
|
|
||||||
|
|
||||||
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
|
if ($request_invoice['invoice_id'] == $paymentable->pivot->paymentable_id) {
|
||||||
|
$record_found = true;
|
||||||
|
|
||||||
if ($request_invoice['amount'] > $refundable_amount) {
|
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
|
||||||
$invoice = $paymentable;
|
|
||||||
|
|
||||||
$this->error_msg = ctrans('texts.max_refundable_invoice', ['invoice' => $invoice->hashed_id, 'amount' => $refundable_amount]);
|
if ($request_invoice['amount'] > $refundable_amount) {
|
||||||
|
$invoice = $paymentable;
|
||||||
|
|
||||||
return false;
|
$this->error_msg = ctrans('texts.max_refundable_invoice', ['invoice' => $invoice->hashed_id, 'amount' => $refundable_amount]);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user