Minor fixes for credit - paid - to - dates

This commit is contained in:
David Bomba 2021-10-12 15:49:05 +11:00
parent a91c6b9a2f
commit 3b8ef9ccd9
5 changed files with 12 additions and 17 deletions

View File

@ -39,8 +39,6 @@ class StorePaymentRequest extends Request
{ {
$input = $this->all(); $input = $this->all();
// nlog(print_r($input,1));
$invoices_total = 0; $invoices_total = 0;
$credits_total = 0; $credits_total = 0;

View File

@ -89,11 +89,11 @@ class PaymentRepository extends BaseRepository {
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) { if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
$_credit_totals = array_sum(array_column($data['credits'], 'amount')); $_credit_totals = array_sum(array_column($data['credits'], 'amount'));
if ($data['amount'] == $_credit_totals) { // if ($data['amount'] == $_credit_totals) {
$data['amount'] = 0; // $data['amount'] = 0;
} else { // } else {
$client->service()->updatePaidToDate($_credit_totals)->save(); $client->service()->updatePaidToDate($_credit_totals)->save();
} // }
} }
} }
@ -170,11 +170,6 @@ class PaymentRepository extends BaseRepository {
event( new PaymentWasCreated( $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null) ) ); event( new PaymentWasCreated( $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null) ) );
} }
// nlog("payment amount = {$payment->amount}");
// nlog("payment applied = {$payment->applied}");
// nlog("invoice totals = {$invoice_totals}");
// nlog("credit totals = {$credit_totals}");
$payment->applied += ($invoice_totals - $credit_totals); //wont work because - check tests $payment->applied += ($invoice_totals - $credit_totals); //wont work because - check tests
// $payment->applied += $invoice_totals; //wont work because - check tests // $payment->applied += $invoice_totals; //wont work because - check tests

View File

@ -185,7 +185,7 @@ class RecurringExpenseApiTest extends TestCase
])->post('/api/v1/recurring_expenses/bulk?action=start', $data); ])->post('/api/v1/recurring_expenses/bulk?action=start', $data);
$arr = $response->json(); $arr = $response->json();
nlog($arr);
$this->assertEquals(RecurringInvoice::STATUS_ACTIVE, $arr['data'][0]['status_id']); $this->assertEquals(RecurringInvoice::STATUS_ACTIVE, $arr['data'][0]['status_id']);
} }
@ -207,7 +207,7 @@ nlog($arr);
])->post('/api/v1/recurring_expenses/bulk?action=stop', $data); ])->post('/api/v1/recurring_expenses/bulk?action=stop', $data);
$arr = $response->json(); $arr = $response->json();
nlog($arr);
$this->assertEquals(RecurringInvoice::STATUS_PAUSED, $arr['data'][0]['status_id']); $this->assertEquals(RecurringInvoice::STATUS_PAUSED, $arr['data'][0]['status_id']);
} }

View File

@ -311,9 +311,9 @@ class AuthorizeTest extends TestCase
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
// nlog($response); // nlog($response);
nlog($response->getTransactionResponse()->getMessages() !== null); // nlog($response->getTransactionResponse()->getMessages() !== null);
nlog($response->getTransactionResponse()->getMessages()); // nlog($response->getTransactionResponse()->getMessages());
nlog($response->getTransactionResponse()->getMessages()[0]); // nlog($response->getTransactionResponse()->getMessages()[0]);
//nlog($response->getTransactionResponse()->getMessages()[0]->getCode()); //nlog($response->getTransactionResponse()->getMessages()[0]->getCode());
$code = ''; $code = '';

View File

@ -275,7 +275,9 @@ class InvoiceInclusiveTest extends TestCase
$this->assertEquals($this->invoice_calc->getSubTotal(), 19); $this->assertEquals($this->invoice_calc->getSubTotal(), 19);
$this->assertEquals($this->invoice_calc->getTotalDiscount(), 0.95); $this->assertEquals($this->invoice_calc->getTotalDiscount(), 0.95);
$this->assertEquals($this->invoice_calc->getTotalTaxes(), 4.92); $this->assertEquals($this->invoice_calc->getTotalTaxes(), 4.92);
nlog($this->invoice_calc->getTaxMap());
// nlog($this->invoice_calc->getTaxMap());
$this->assertEquals(count($this->invoice_calc->getTaxMap()), 1); $this->assertEquals(count($this->invoice_calc->getTaxMap()), 1);
$this->assertEquals($this->invoice_calc->getTotal(), 18.05); $this->assertEquals($this->invoice_calc->getTotal(), 18.05);
$this->assertEquals($this->invoice_calc->getBalance(), 18.05); $this->assertEquals($this->invoice_calc->getBalance(), 18.05);