mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for check data
This commit is contained in:
parent
5cede990a7
commit
5ad82c124d
@ -648,25 +648,19 @@ ORDER BY clients.id;
|
|||||||
private function clientBalanceQuery()
|
private function clientBalanceQuery()
|
||||||
{
|
{
|
||||||
$results = \DB::select( \DB::raw("
|
$results = \DB::select( \DB::raw("
|
||||||
SELECT
|
SELECT
|
||||||
SUM(invoices.balance) as invoice_balance,
|
SUM(invoices.balance) as invoice_balance,
|
||||||
SUM(credits.balance) as credit_balance,
|
clients.id as client_id,
|
||||||
clients.id as client_id,
|
clients.balance as client_balance
|
||||||
clients.balance as client_balance
|
FROM clients
|
||||||
FROM invoices
|
LEFT JOIN
|
||||||
INNER JOIN
|
invoices ON
|
||||||
clients ON
|
clients.id=invoices.client_id
|
||||||
clients.id=invoices.client_id
|
WHERE invoices.is_deleted = false
|
||||||
INNER JOIN
|
AND invoices.status_id > 1
|
||||||
credits ON
|
GROUP BY clients.id
|
||||||
credits.client_id = clients.id
|
HAVING invoice_balance != clients.balance
|
||||||
WHERE invoices.is_deleted = false
|
ORDER BY clients.id;
|
||||||
AND invoices.status_id > 1
|
|
||||||
AND credits.is_deleted = false
|
|
||||||
AND credits.status_id > 1
|
|
||||||
GROUP BY clients.id
|
|
||||||
HAVING invoice_balance != clients.balance
|
|
||||||
ORDER BY clients.id;
|
|
||||||
") );
|
") );
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
@ -686,7 +680,12 @@ ORDER BY clients.id;
|
|||||||
{
|
{
|
||||||
$client = (array)$client;
|
$client = (array)$client;
|
||||||
|
|
||||||
$invoice_balance = $client['invoice_balance'] - $client['credit_balance'];
|
// $credit_balance = Credit::withTrashed()->where('is_deleted', 0)
|
||||||
|
// ->where('client_id', $client['client_id'])
|
||||||
|
// ->where('status_id', '>', 1)->sum('balance');
|
||||||
|
|
||||||
|
// $invoice_balance = $client['invoice_balance'] - $credit_balance;
|
||||||
|
$invoice_balance = $client['invoice_balance'];
|
||||||
|
|
||||||
$ledger = CompanyLedger::where('client_id', $client['client_id'])->orderBy('id', 'DESC')->first();
|
$ledger = CompanyLedger::where('client_id', $client['client_id'])->orderBy('id', 'DESC')->first();
|
||||||
|
|
||||||
@ -701,8 +700,8 @@ ORDER BY clients.id;
|
|||||||
if($this->option('client_balance')){
|
if($this->option('client_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client_object->id} " . $client_object->present()->name.' - '.$client_object->number." Fixing {$client_object->balance} to {$invoice_balance}");
|
$this->logMessage("# {$client_object->id} " . $client_object->present()->name.' - '.$client_object->number." Fixing {$client_object->balance} to {$invoice_balance}");
|
||||||
$client->balance = $invoice_balance;
|
$client_object->balance = $invoice_balance;
|
||||||
$client->save();
|
$client_object->save();
|
||||||
|
|
||||||
$ledger->adjustment = $invoice_balance;
|
$ledger->adjustment = $invoice_balance;
|
||||||
$ledger->balance = $invoice_balance;
|
$ledger->balance = $invoice_balance;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user