mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for EWay
This commit is contained in:
parent
c45c4335cd
commit
88f730b9a1
@ -74,7 +74,7 @@ class CheckData extends Command
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=}';
|
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -102,7 +102,7 @@ class CheckData extends Command
|
|||||||
config(['database.default' => $database]);
|
config(['database.default' => $database]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->checkInvoiceBalances();
|
$this->checkInvoiceBalances();
|
||||||
$this->checkInvoiceBalancesNew();
|
$this->checkInvoiceBalancesNew();
|
||||||
//$this->checkInvoicePayments();
|
//$this->checkInvoicePayments();
|
||||||
|
|
||||||
@ -482,6 +482,7 @@ class CheckData extends Command
|
|||||||
payments.id = paymentables.payment_id
|
payments.id = paymentables.payment_id
|
||||||
WHERE paymentable_type = ?
|
WHERE paymentable_type = ?
|
||||||
AND paymentables.deleted_at is NULL
|
AND paymentables.deleted_at is NULL
|
||||||
|
AND payments.amount > 0
|
||||||
AND payments.is_deleted = 0
|
AND payments.is_deleted = 0
|
||||||
AND payments.client_id = ?;
|
AND payments.client_id = ?;
|
||||||
"), [App\Models\Credit::class, $client->id] );
|
"), [App\Models\Credit::class, $client->id] );
|
||||||
@ -853,18 +854,16 @@ ORDER BY clients.id;
|
|||||||
|
|
||||||
foreach (Client::where('is_deleted', 0)->where('clients.updated_at', '>', now()->subDays(2))->cursor() as $client) {
|
foreach (Client::where('is_deleted', 0)->where('clients.updated_at', '>', now()->subDays(2))->cursor() as $client) {
|
||||||
$invoice_balance = $client->invoices()->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
$invoice_balance = $client->invoices()->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||||
$credit_balance = $client->credits()->where('is_deleted', false)->sum('balance');
|
|
||||||
|
|
||||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||||
|
|
||||||
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
if ($ledger && number_format($ledger->balance, 4) != number_format($client->balance, 4)) {
|
||||||
$this->wrong_balances++;
|
$this->wrong_balances++;
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
|
||||||
|
|
||||||
if($this->option('client_balance')){
|
if($this->option('ledger_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
||||||
$client->balance = $invoice_balance;
|
$client->balance = $invoice_balance;
|
||||||
@ -879,7 +878,7 @@ ORDER BY clients.id;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logMessage("{$this->wrong_balances} clients with incorrect balances");
|
$this->logMessage("{$this->wrong_balances} clients with incorrect ledger balances");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkLogoFiles()
|
private function checkLogoFiles()
|
||||||
|
@ -160,7 +160,7 @@ class CreditCard
|
|||||||
'TotalAmount' => $this->convertAmountForEway(),
|
'TotalAmount' => $this->convertAmountForEway(),
|
||||||
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
||||||
'InvoiceNumber' => $invoice_numbers,
|
'InvoiceNumber' => $invoice_numbers,
|
||||||
'Description' => $description,
|
'InvoiceDescription' => $description,
|
||||||
'InvoiceReference' => $description,
|
'InvoiceReference' => $description,
|
||||||
],
|
],
|
||||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
||||||
@ -252,7 +252,7 @@ class CreditCard
|
|||||||
'TotalAmount' => $this->convertAmountForEway($amount),
|
'TotalAmount' => $this->convertAmountForEway($amount),
|
||||||
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
||||||
'InvoiceNumber' => $invoice_numbers,
|
'InvoiceNumber' => $invoice_numbers,
|
||||||
'Description' => $description,
|
'InvoiceDescription' => $description,
|
||||||
'InvoiceReference' => $description,
|
'InvoiceReference' => $description,
|
||||||
],
|
],
|
||||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
||||||
|
@ -43,6 +43,14 @@ class Token
|
|||||||
|
|
||||||
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
||||||
|
|
||||||
|
|
||||||
|
$invoice_numbers = '';
|
||||||
|
|
||||||
|
if($this->eway_driver->payment_hash->data)
|
||||||
|
$invoice_numbers = collect($this->eway_driver->payment_hash->data->invoices)->pluck('invoice_number')->implode(',');
|
||||||
|
|
||||||
|
$description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->eway_driver->client->present()->name()}";
|
||||||
|
|
||||||
$this->eway_driver->payment_hash = $payment_hash;
|
$this->eway_driver->payment_hash = $payment_hash;
|
||||||
|
|
||||||
$transaction = [
|
$transaction = [
|
||||||
@ -51,6 +59,10 @@ class Token
|
|||||||
],
|
],
|
||||||
'Payment' => [
|
'Payment' => [
|
||||||
'TotalAmount' => $this->eway_driver->convertAmount($amount),
|
'TotalAmount' => $this->eway_driver->convertAmount($amount),
|
||||||
|
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
||||||
|
'InvoiceNumber' => $invoice_numbers,
|
||||||
|
'InvoiceDescription' => $description,
|
||||||
|
'InvoiceReference' => $description,
|
||||||
],
|
],
|
||||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
||||||
];
|
];
|
||||||
|
@ -133,9 +133,14 @@ class CreditService
|
|||||||
->attach($this->credit->id, ['amount' => $adjustment]);
|
->attach($this->credit->id, ['amount' => $adjustment]);
|
||||||
|
|
||||||
//reduce client paid_to_date by $this->credit->balance amount
|
//reduce client paid_to_date by $this->credit->balance amount
|
||||||
$this->credit
|
// $this->credit
|
||||||
->client
|
// ->client
|
||||||
->service()
|
// ->service()
|
||||||
|
// ->updatePaidToDate($adjustment)
|
||||||
|
// ->save();
|
||||||
|
|
||||||
|
$client = $this->credit->client->fresh();
|
||||||
|
$client->service()
|
||||||
->updatePaidToDate($adjustment)
|
->updatePaidToDate($adjustment)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user