mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:47:34 -05: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}");
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            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,6 +28,8 @@ return new class extends Migration
 | 
			
		||||
                
 | 
			
		||||
                $line_items = $invoice->line_items;
 | 
			
		||||
 | 
			
		||||
                if(is_array($line_items))
 | 
			
		||||
                {
 | 
			
		||||
                    foreach ($line_items as $key => $item)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
@ -41,7 +43,7 @@ return new class extends Migration
 | 
			
		||||
 | 
			
		||||
                    $invoice->line_items = $line_items;
 | 
			
		||||
                    $invoice->saveQuietly();
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user