mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
working on checkdata script
This commit is contained in:
parent
bba660fe06
commit
b37c475414
@ -82,6 +82,7 @@ class CheckData extends Command
|
|||||||
|
|
||||||
$this->checkInvoiceBalances();
|
$this->checkInvoiceBalances();
|
||||||
$this->checkInvoicePayments();
|
$this->checkInvoicePayments();
|
||||||
|
$this->checkPaidToDates();
|
||||||
$this->checkClientBalances();
|
$this->checkClientBalances();
|
||||||
$this->checkContacts();
|
$this->checkContacts();
|
||||||
$this->checkCompanyData();
|
$this->checkCompanyData();
|
||||||
@ -317,9 +318,48 @@ class CheckData extends Command
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkPaidToDates()
|
||||||
|
{
|
||||||
|
|
||||||
|
$wrong_paid_to_dates = 0;
|
||||||
|
|
||||||
|
Client::withTrashed()->cursor()->each(function ($client) use($wrong_paid_to_dates){
|
||||||
|
|
||||||
|
$total_invoice_payments = 0;
|
||||||
|
|
||||||
|
$client->invoices->where('is_deleted', false)->each(function ($invoice) use($total_invoice_payments, $wrong_paid_to_dates){
|
||||||
|
|
||||||
|
$total_amount = $invoice->payments->sum('pivot.amount');
|
||||||
|
$total_refund = $invoice->payments->sum('pivot.refunded');
|
||||||
|
|
||||||
|
info("Pivot = " . $total_amount . " - " . $total_refund);
|
||||||
|
|
||||||
|
$total_invoice_payments += ($total_amount - $total_refund);
|
||||||
|
|
||||||
|
info($total_invoice_payments);
|
||||||
|
});
|
||||||
|
|
||||||
|
info($total_invoice_payments . " = ". $client->paid_to_date);
|
||||||
|
|
||||||
|
if($total_invoice_payments != $client->paid_to_date) {
|
||||||
|
$wrong_paid_to_dates++;
|
||||||
|
|
||||||
|
$this->logMessage($client->present()->name . " - " . $client->id . " - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}");
|
||||||
|
|
||||||
|
$this->isValid = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->logMessage("{$wrong_paid_to_dates} clients with incorrect paid to dates");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function checkInvoicePayments()
|
private function checkInvoicePayments()
|
||||||
{
|
{
|
||||||
$wrong_balances = 0;
|
$wrong_balances = 0;
|
||||||
|
$wrong_paid_to_dates = 0;
|
||||||
|
|
||||||
Client::cursor()->each(function ($client) use($wrong_balances){
|
Client::cursor()->each(function ($client) use($wrong_balances){
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user