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

minor fixes

This commit is contained in:
David Bomba 2022-07-17 15:26:35 +10:00
parent 9e7375a127
commit 00eb180afc
3 changed files with 35 additions and 6 deletions

View File

@ -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("

View File

@ -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;
}

View File

@ -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)