1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Refactor to use vendor currencies for purchase orders

This commit is contained in:
David Bomba 2022-12-14 11:50:55 +11:00
parent e595105f69
commit d61620bcf6
2 changed files with 35 additions and 1 deletions

View File

@ -991,7 +991,7 @@ class CheckData extends Command
if ($this->option('fix') == 'true')
{
Vendor::query()->whereNull('currency_id')->cursor()->each(function ($vendor){
Vendor::query()->whereNull('currency_id')->orWhere('currency_id', '')->cursor()->each(function ($vendor){
$vendor->currency_id = $vendor->company->settings->currency_id;
$vendor->save();

View File

@ -0,0 +1,34 @@
<?php
use App\Models\Vendor;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Vendor::query()->whereNull('currency_id')->orWhere('currency_id', '')->cursor()->each(function ($vendor){
$vendor->currency_id = $vendor->company->settings->currency_id;
$vendor->save();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};