1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fix for casting line items

This commit is contained in:
David Bomba 2020-11-22 16:34:05 +11:00
parent e82d8e0d8d
commit 6eaf78a1d5
3 changed files with 676 additions and 668 deletions

View File

@ -157,8 +157,6 @@ class PaymentRepository extends BaseRepository
if(!$is_existing_payment)
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
$payment->applied += ($invoice_totals - $credit_totals); //wont work because - check tests
// $payment->applied += $invoice_totals; //wont work because - check tests

View File

@ -42,19 +42,29 @@ trait CleanLineItems
private function cleanLineItem($item)
{
$invoice_item = (object) get_class_vars(InvoiceItem::class);
unset($invoice_item->casts);
foreach ($invoice_item as $key => $value) {
//if the key has not been set, we set it to a default value
if (! array_key_exists($key, $item) || ! isset($item[$key])) {
$item[$key] = $value;
$item[$key] = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $value);
}
else{
//always cast the value!
$item[$key] = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $item[$key]);
}
if (array_key_exists('id', $item)) {
unset($item['id']);
}
if (array_key_exists('id', $item))
unset($item['id']);
return $item;
}
}

1324
package-lock.json generated

File diff suppressed because it is too large Load Diff