mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:54:30 -04:00
Fixes for check data
This commit is contained in:
parent
b0edf7d8d2
commit
15747cafa4
@ -890,6 +890,40 @@ class CheckData extends Command
|
|||||||
|
|
||||||
$this->logMessage("Fixing country for # {$client->id}");
|
$this->logMessage("Fixing country for # {$client->id}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Client::query()->whereNull("settings->currency_id")->cursor()->each(function ($client){
|
||||||
|
$settings = $client->settings;
|
||||||
|
$settings->currency_id = (string)$client->company->settings->currency_id;
|
||||||
|
$client->settings = $settings;
|
||||||
|
$client->saveQuietly();
|
||||||
|
|
||||||
|
$this->logMessage("Fixing currency_id for # {$client->id}");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Payment::withTrashed()->where('exchange_rate', 0)->cursor()->each(function ($payment){
|
||||||
|
$payment->exchange_rate = 1;
|
||||||
|
$payment->saveQuietly();
|
||||||
|
|
||||||
|
$this->logMessage("Fixing exchange rate for # {$payment->id}");
|
||||||
|
});
|
||||||
|
|
||||||
|
Payment::withTrashed()
|
||||||
|
->whereHas("client", function ($query) {
|
||||||
|
$query->whereColumn("settings->currency_id", "!=", "payments.currency_id");
|
||||||
|
})
|
||||||
|
->cursor()
|
||||||
|
->each(function ($p) {
|
||||||
|
$p->currency_id = $p->client->settings->currency_id;
|
||||||
|
$p->saveQuietly();
|
||||||
|
|
||||||
|
|
||||||
|
$this->logMessage("Fixing currency for # {$p->id}");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,20 +28,22 @@ return new class extends Migration
|
|||||||
|
|
||||||
$line_items = $invoice->line_items;
|
$line_items = $invoice->line_items;
|
||||||
|
|
||||||
foreach ($line_items as $key => $item)
|
if(is_array($line_items))
|
||||||
{
|
{
|
||||||
|
foreach ($line_items as $key => $item)
|
||||||
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 = (float)$product->cost;
|
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 = (float)$product->cost;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$invoice->line_items = $line_items;
|
||||||
|
$invoice->saveQuietly();
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice->line_items = $line_items;
|
|
||||||
$invoice->saveQuietly();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user