mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01:00
minor fixes
This commit is contained in:
parent
9e7375a127
commit
00eb180afc
@ -105,9 +105,9 @@ class CheckData extends Command
|
||||
config(['database.default' => $database]);
|
||||
}
|
||||
|
||||
$this->checkInvoiceBalances();
|
||||
$this->checkInvoiceBalances();
|
||||
$this->checkClientBalanceEdgeCases();
|
||||
$this->checkPaidToDatesNew();
|
||||
|
||||
$this->checkContacts();
|
||||
$this->checkVendorContacts();
|
||||
$this->checkEntityInvitations();
|
||||
@ -655,6 +655,39 @@ class CheckData extends Command
|
||||
$this->logMessage("{$this->wrong_paid_to_dates} clients with incorrect client balances");
|
||||
}
|
||||
|
||||
private function checkClientBalanceEdgeCases()
|
||||
{
|
||||
Client::query()
|
||||
->where('is_deleted',false)
|
||||
->where('balance', '!=', 0)
|
||||
->cursor()
|
||||
->each(function ($client){
|
||||
|
||||
$count = Invoice::withTrashed()
|
||||
->where('client_id', $client->id)
|
||||
->where('is_deleted',false)
|
||||
->whereIn('status_id', [2,3])
|
||||
->count();
|
||||
|
||||
if($count == 0){
|
||||
$this->logMessage("# {$client->id} # {$client->name} {$client->balance} is invalid should be 0");
|
||||
|
||||
if($this->option('client_balance')){
|
||||
|
||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to 0");
|
||||
|
||||
$client->balance = 0;
|
||||
$client->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private function invoiceBalanceQuery()
|
||||
{
|
||||
$results = \DB::select( \DB::raw("
|
||||
|
@ -62,9 +62,6 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['discount'] = 'sometimes|numeric';
|
||||
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||
|
||||
// if($this->input('status_id') != Invoice::STATUS_DRAFT)
|
||||
// $rules['balance'] = new InvoiceBalanceSanity($this->invoice, $this->all());
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,6 @@ class BaseRepository
|
||||
$model->client->service()->updateBalance(($state['finished_amount'] - $state['starting_amount']))->save();
|
||||
$model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount']), "Update adjustment for invoice {$model->number}");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (! $model->design_id)
|
||||
|
Loading…
Reference in New Issue
Block a user