mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-08-30 23:20:34 -04:00
Minor fixes
This commit is contained in:
parent
3f5b338846
commit
c8cf4aca42
@ -23,9 +23,10 @@ return new class extends Migration
|
|||||||
Invoice::withTrashed()
|
Invoice::withTrashed()
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function (Invoice $invoice) {
|
->each(function (Invoice $invoice) {
|
||||||
|
|
||||||
|
|
||||||
|
$hit = false;
|
||||||
|
|
||||||
$line_items = $invoice->line_items;
|
$line_items = $invoice->line_items;
|
||||||
|
|
||||||
if(is_array($line_items))
|
if(is_array($line_items))
|
||||||
@ -35,14 +36,18 @@ return new class extends Migration
|
|||||||
|
|
||||||
if($product = Product::where('company_id', $invoice->company_id)->where('product_key', $item->product_key)->where('cost', '>', 0)->first())
|
if($product = Product::where('company_id', $invoice->company_id)->where('product_key', $item->product_key)->where('cost', '>', 0)->first())
|
||||||
{
|
{
|
||||||
if((property_exists($item, 'product_cost') && $item->product_cost == 0) || !property_exists($item, 'product_cost'))
|
if((property_exists($item, 'product_cost') && $item->product_cost == 0) || !property_exists($item, 'product_cost')){
|
||||||
|
$hit = true;
|
||||||
$line_items[$key]->product_cost = (float)$product->cost;
|
$line_items[$key]->product_cost = (float)$product->cost;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice->line_items = $line_items;
|
if($hit){
|
||||||
$invoice->saveQuietly();
|
$invoice->line_items = $line_items;
|
||||||
|
$invoice->saveQuietly();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user