Fixes for migration

This commit is contained in:
David Bomba 2024-01-10 12:28:12 +11:00
parent 40e078b4e1
commit 974b342333
4 changed files with 13 additions and 8 deletions

View File

@ -1 +1 @@
5.8.5
5.8.6

View File

@ -17,8 +17,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION', '5.8.5'),
'app_tag' => env('APP_TAG', '5.8.5'),
'app_version' => env('APP_VERSION', '5.8.6'),
'app_tag' => env('APP_TAG', '5.8.6'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),

View File

@ -31,10 +31,12 @@ return new class extends Migration
foreach ($line_items as $key => $item)
{
if($item?->product_cost == 0 && $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'))
$line_items[$key]->product_cost = $product->cost;
}
}
$invoice->line_items = $line_items;

View File

@ -95,19 +95,22 @@ class ProductTest extends TestCase
->cursor()
->each(function (Invoice $invoice) {
$line_items = $invoice->line_items;
foreach ($line_items as $key => $item) {
if(property_exists($item, 'product_cost') && $item->product_cost == 0 && $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')) {
$line_items[$key]->product_cost = $product->cost;
}
}
}
$invoice->line_items = $line_items;
$invoice->saveQuietly();
});