mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Fixes for Zoho Import
This commit is contained in:
parent
f7bd931c0c
commit
7b073d033a
@ -46,7 +46,7 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
'due_date' => isset($invoice_data['Due Date']) ? date('Y-m-d', strtotime($invoice_data['Due Date'])) : null,
|
'due_date' => isset($invoice_data['Due Date']) ? date('Y-m-d', strtotime($invoice_data['Due Date'])) : null,
|
||||||
'po_number' => $this->getString($invoice_data, 'PurchaseOrder'),
|
'po_number' => $this->getString($invoice_data, 'PurchaseOrder'),
|
||||||
'public_notes' => $this->getString($invoice_data, 'Notes'),
|
'public_notes' => $this->getString($invoice_data, 'Notes'),
|
||||||
'currency_id' => $this->getCurrencyByCode($invoice_data, 'Currency'),
|
// 'currency_id' => $this->getCurrencyByCode($invoice_data, 'Currency'),
|
||||||
'amount' => $this->getFloat($invoice_data, 'Total'),
|
'amount' => $this->getFloat($invoice_data, 'Total'),
|
||||||
'balance' => $this->getFloat($invoice_data, 'Balance'),
|
'balance' => $this->getFloat($invoice_data, 'Balance'),
|
||||||
'status_id' => $invoiceStatusMap[$status =
|
'status_id' => $invoiceStatusMap[$status =
|
||||||
|
@ -102,6 +102,10 @@ class CreateRawPdf implements ShouldQueue
|
|||||||
/* Set customized translations _NOW_ */
|
/* Set customized translations _NOW_ */
|
||||||
$t->replace(Ninja::transformTranslations($this->entity->client->getMergedSettings()));
|
$t->replace(Ninja::transformTranslations($this->entity->client->getMergedSettings()));
|
||||||
|
|
||||||
|
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||||
|
return (new Phantom)->generate($this->invitation, true);
|
||||||
|
}
|
||||||
|
|
||||||
$entity_design_id = '';
|
$entity_design_id = '';
|
||||||
|
|
||||||
if ($this->entity instanceof Invoice) {
|
if ($this->entity instanceof Invoice) {
|
||||||
|
2
app/Jobs/Vendor/CreatePurchaseOrderPdf.php
vendored
2
app/Jobs/Vendor/CreatePurchaseOrderPdf.php
vendored
@ -127,7 +127,7 @@ class CreatePurchaseOrderPdf implements ShouldQueue
|
|||||||
$t->replace(Ninja::transformTranslations($this->company->settings));
|
$t->replace(Ninja::transformTranslations($this->company->settings));
|
||||||
|
|
||||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||||
return (new Phantom)->generate($this->invitation);
|
return (new Phantom)->generate($this->invitation, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity_design_id = '';
|
$entity_design_id = '';
|
||||||
|
@ -42,7 +42,7 @@ class Phantom
|
|||||||
*
|
*
|
||||||
* @param $invitation
|
* @param $invitation
|
||||||
*/
|
*/
|
||||||
public function generate($invitation)
|
public function generate($invitation, $return_pdf = false)
|
||||||
{
|
{
|
||||||
$entity = false;
|
$entity = false;
|
||||||
|
|
||||||
@ -112,6 +112,9 @@ class Phantom
|
|||||||
|
|
||||||
$instance = Storage::disk(config('filesystems.default'))->put($file_path, $pdf);
|
$instance = Storage::disk(config('filesystems.default'))->put($file_path, $pdf);
|
||||||
|
|
||||||
|
if($return_pdf)
|
||||||
|
return $pdf;
|
||||||
|
|
||||||
return $file_path;
|
return $file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@ trait GeneratesCounter
|
|||||||
$replace[] = $client->id_number;
|
$replace[] = $client->id_number;
|
||||||
|
|
||||||
$search[] = '{$clientIdNumber}';
|
$search[] = '{$clientIdNumber}';
|
||||||
$replace[] = $client->id_number;
|
$replace[] = $client->id_number ?: $client->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_replace($search, $replace, $pattern);
|
return str_replace($search, $replace, $pattern);
|
||||||
|
@ -67,26 +67,26 @@ class PaymentTest extends TestCase
|
|||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_Taxes = false;
|
$invoice->uses_inclusive_Taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'date' => '2020/12/11',
|
'date' => '2020/12/11',
|
||||||
@ -175,25 +175,25 @@ class PaymentTest extends TestCase
|
|||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_Taxes = false;
|
$invoice->uses_inclusive_Taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'date' => '2020/12/11',
|
'date' => '2020/12/11',
|
||||||
@ -226,10 +226,10 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -277,23 +277,23 @@ class PaymentTest extends TestCase
|
|||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
$this->invoice->status_id = Invoice::STATUS_SENT;
|
$invoice->status_id = Invoice::STATUS_SENT;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => '',
|
'invoices' => '',
|
||||||
'date' => '2020/12/12',
|
'date' => '2020/12/12',
|
||||||
@ -319,7 +319,7 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPartialPaymentAmount()
|
public function testPartialPaymentAmount()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
@ -331,28 +331,28 @@ class PaymentTest extends TestCase
|
|||||||
'is_primary' => true,
|
'is_primary' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->partial = 2.0;
|
$invoice->partial = 2.0;
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -394,7 +394,7 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentGreaterThanPartial()
|
public function testPaymentGreaterThanPartial()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->setRelation('company', $this->company);
|
$client->setRelation('company', $this->company);
|
||||||
@ -409,32 +409,32 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$client->setRelation('contacts', $client_contact);
|
$client->setRelation('contacts', $client_contact);
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->partial = 5.0;
|
$invoice->partial = 5.0;
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->company->setRelation('company', $this->company);
|
$invoice->company->setRelation('company', $this->company);
|
||||||
$this->invoice->company->setRelation('client', $client);
|
$invoice->company->setRelation('client', $client);
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
$this->invoice->is_deleted = false;
|
$invoice->is_deleted = false;
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 6.0,
|
'amount' => 6.0,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 6.0,
|
'amount' => 6.0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -471,7 +471,7 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentLessThanPartialAmount()
|
public function testPaymentLessThanPartialAmount()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
@ -491,28 +491,28 @@ class PaymentTest extends TestCase
|
|||||||
'send_email' => true,
|
'send_email' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->partial = 5.0;
|
$invoice->partial = 5.0;
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -543,7 +543,7 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentValidationAmount()
|
public function testPaymentValidationAmount()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
@ -565,30 +565,30 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$client->setRelation('contact', $contact);
|
$client->setRelation('contact', $contact);
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->partial = 5.0;
|
$invoice->partial = 5.0;
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$this->invoice->setRelation('client', $client);
|
$invoice->setRelation('client', $client);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 1.0,
|
'amount' => 1.0,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -609,32 +609,32 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentChangesBalancesCorrectly()
|
public function testPaymentChangesBalancesCorrectly()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 2.0,
|
'amount' => 2.0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -657,7 +657,7 @@ class PaymentTest extends TestCase
|
|||||||
if ($response) {
|
if ($response) {
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
$invoice = Invoice::find($this->decodePrimaryKey($this->invoice->hashed_id));
|
$invoice = Invoice::find($this->decodePrimaryKey($invoice->hashed_id));
|
||||||
|
|
||||||
$this->assertEquals($invoice->balance, 8);
|
$this->assertEquals($invoice->balance, 8);
|
||||||
|
|
||||||
@ -669,25 +669,25 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testUpdatePaymentValidationWorks()
|
public function testUpdatePaymentValidationWorks()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$payment = PaymentFactory::create($this->company->id, $this->user->id);
|
$payment = PaymentFactory::create($this->company->id, $this->user->id);
|
||||||
$payment->amount = 10;
|
$payment->amount = 10;
|
||||||
@ -722,25 +722,25 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testUpdatePaymentValidationPasses()
|
public function testUpdatePaymentValidationPasses()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$payment = PaymentFactory::create($this->company->id, $this->user->id);
|
$payment = PaymentFactory::create($this->company->id, $this->user->id);
|
||||||
$payment->amount = 10;
|
$payment->amount = 10;
|
||||||
@ -754,7 +754,7 @@ class PaymentTest extends TestCase
|
|||||||
'client_id' => $this->encodePrimaryKey($client->id),
|
'client_id' => $this->encodePrimaryKey($client->id),
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->encodePrimaryKey($this->invoice->id),
|
'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -782,32 +782,32 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testDoublePaymentTestWithInvalidAmounts()
|
public function testDoublePaymentTestWithInvalidAmounts()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 15.0,
|
'amount' => 15.0,
|
||||||
'client_id' => $this->encodePrimaryKey($client->id),
|
'client_id' => $this->encodePrimaryKey($client->id),
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->encodePrimaryKey($this->invoice->id),
|
'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -837,28 +837,28 @@ class PaymentTest extends TestCase
|
|||||||
$this->assertEquals($payment->amount, 15);
|
$this->assertEquals($payment->amount, 15);
|
||||||
$this->assertEquals($payment->applied, 10);
|
$this->assertEquals($payment->applied, 10);
|
||||||
|
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 15.0,
|
'amount' => 15.0,
|
||||||
'client_id' => $this->encodePrimaryKey($client->id),
|
'client_id' => $this->encodePrimaryKey($client->id),
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->encodePrimaryKey($this->invoice->id),
|
'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -881,32 +881,32 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testDoublePaymentTestWithValidAmounts()
|
public function testDoublePaymentTestWithValidAmounts()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 20.0,
|
'amount' => 20.0,
|
||||||
'client_id' => $this->encodePrimaryKey($client->id),
|
'client_id' => $this->encodePrimaryKey($client->id),
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->encodePrimaryKey($this->invoice->id),
|
'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -929,28 +929,28 @@ class PaymentTest extends TestCase
|
|||||||
$this->assertEquals($payment->amount, 20);
|
$this->assertEquals($payment->amount, 20);
|
||||||
$this->assertEquals($payment->applied, 10);
|
$this->assertEquals($payment->applied, 10);
|
||||||
|
|
||||||
// $this->invoice = null;
|
// $invoice = null;
|
||||||
// $this->invoice = InvoiceFactory::create($this->company->id, $this->user->id);//stub the company and user_id
|
// $invoice = InvoiceFactory::create($this->company->id, $this->user->id);//stub the company and user_id
|
||||||
// $this->invoice->client_id = $client->id;
|
// $invoice->client_id = $client->id;
|
||||||
|
|
||||||
// $this->invoice->line_items = $this->buildLineItems();
|
// $invoice->line_items = $this->buildLineItems();
|
||||||
// $this->invoice->uses_inclusive_taxes = false;
|
// $invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
// $this->invoice->save();
|
// $invoice->save();
|
||||||
|
|
||||||
// $this->invoice_calc = new InvoiceSum($this->invoice);
|
// $invoice_calc = new InvoiceSum($invoice);
|
||||||
// $this->invoice_calc->build();
|
// $invoice_calc->build();
|
||||||
|
|
||||||
// $this->invoice = $this->invoice_calc->getInvoice();
|
// $invoice = $invoice_calc->getInvoice();
|
||||||
// $this->invoice->save();
|
// $invoice->save();
|
||||||
// $this->invoice->service()->markSent()->createInvitations()->save();
|
// $invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
// $data = [
|
// $data = [
|
||||||
// 'amount' => 20.0,
|
// 'amount' => 20.0,
|
||||||
// 'client_id' => $this->encodePrimaryKey($client->id),
|
// 'client_id' => $this->encodePrimaryKey($client->id),
|
||||||
// 'invoices' => [
|
// 'invoices' => [
|
||||||
// [
|
// [
|
||||||
// 'invoice_id' => $this->encodePrimaryKey($this->invoice->id),
|
// 'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
||||||
// 'amount' => 10,
|
// 'amount' => 10,
|
||||||
// ]
|
// ]
|
||||||
// ],
|
// ],
|
||||||
@ -983,27 +983,27 @@ class PaymentTest extends TestCase
|
|||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
$this->invoice->status_id = Invoice::STATUS_SENT;
|
$invoice->status_id = Invoice::STATUS_SENT;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_Taxes = false;
|
$invoice->uses_inclusive_Taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'date' => '2020/12/12',
|
'date' => '2020/12/12',
|
||||||
@ -1028,7 +1028,7 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$payment_id = $arr['data']['id'];
|
$payment_id = $arr['data']['id'];
|
||||||
|
|
||||||
$this->assertEquals($this->invoice->amount, $arr['data']['amount']);
|
$this->assertEquals($invoice->amount, $arr['data']['amount']);
|
||||||
|
|
||||||
$payment = Payment::whereId($this->decodePrimaryKey($payment_id))->first();
|
$payment = Payment::whereId($this->decodePrimaryKey($payment_id))->first();
|
||||||
|
|
||||||
@ -1043,28 +1043,28 @@ class PaymentTest extends TestCase
|
|||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
$this->invoice->status_id = Invoice::STATUS_SENT;
|
$invoice->status_id = Invoice::STATUS_SENT;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_Taxes = false;
|
$invoice->uses_inclusive_Taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 0,
|
'amount' => 0,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'date' => '2020/12/12',
|
'date' => '2020/12/12',
|
||||||
@ -1087,9 +1087,9 @@ class PaymentTest extends TestCase
|
|||||||
$payment_id = $arr['data']['id'];
|
$payment_id = $arr['data']['id'];
|
||||||
$payment = Payment::whereId($this->decodePrimaryKey($payment_id))->first();
|
$payment = Payment::whereId($this->decodePrimaryKey($payment_id))->first();
|
||||||
|
|
||||||
$this->assertEquals(round($payment->amount, 2), $this->invoice->amount);
|
$this->assertEquals(round($payment->amount, 2), $invoice->amount);
|
||||||
|
|
||||||
$this->assertEquals(round($payment->applied, 2), $this->invoice->amount);
|
$this->assertEquals(round($payment->applied, 2), $invoice->amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPaymentForInvoicesFromDifferentClients()
|
public function testPaymentForInvoicesFromDifferentClients()
|
||||||
@ -1215,20 +1215,20 @@ class PaymentTest extends TestCase
|
|||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
$this->invoice->status_id = Invoice::STATUS_SENT;
|
$invoice->status_id = Invoice::STATUS_SENT;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$credit = CreditFactory::create($this->company->id, $this->user->id);
|
$credit = CreditFactory::create($this->company->id, $this->user->id);
|
||||||
$credit->client_id = $client->id;
|
$credit->client_id = $client->id;
|
||||||
@ -1246,11 +1246,11 @@ class PaymentTest extends TestCase
|
|||||||
$credit->save(); //$10 credit
|
$credit->save(); //$10 credit
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 5,
|
'amount' => 5,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1299,28 +1299,28 @@ class PaymentTest extends TestCase
|
|||||||
$client->settings = $settings;
|
$client->settings = $settings;
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
$this->invoice->status_id = Invoice::STATUS_SENT;
|
$invoice->status_id = Invoice::STATUS_SENT;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_Taxes = false;
|
$invoice->uses_inclusive_Taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'client_id' => $client->hashed_id,
|
'client_id' => $client->hashed_id,
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'date' => '2020/12/12',
|
'date' => '2020/12/12',
|
||||||
@ -1357,32 +1357,32 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testPaymentActionArchive()
|
public function testPaymentActionArchive()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$this->invoice->line_items = $this->buildLineItems();
|
$invoice->line_items = $this->buildLineItems();
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => 20.0,
|
'amount' => 20.0,
|
||||||
'client_id' => $this->encodePrimaryKey($client->id),
|
'client_id' => $this->encodePrimaryKey($client->id),
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->encodePrimaryKey($this->invoice->id),
|
'invoice_id' => $this->encodePrimaryKey($invoice->id),
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1436,13 +1436,13 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
public function testDeleteRefundedPayment()
|
public function testDeleteRefundedPayment()
|
||||||
{
|
{
|
||||||
$this->invoice = null;
|
$invoice = null;
|
||||||
|
|
||||||
$client = ClientFactory::create($this->company->id, $this->user->id);
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
$this->invoice->client_id = $client->id;
|
$invoice->client_id = $client->id;
|
||||||
|
|
||||||
$item = InvoiceItemFactory::create();
|
$item = InvoiceItemFactory::create();
|
||||||
$item->quantity = 1;
|
$item->quantity = 1;
|
||||||
@ -1456,29 +1456,29 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$line_items[] = $item;
|
$line_items[] = $item;
|
||||||
|
|
||||||
$this->invoice->line_items = $line_items;
|
$invoice->line_items = $line_items;
|
||||||
$this->invoice->uses_inclusive_taxes = false;
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$this->invoice_calc = new InvoiceSum($this->invoice);
|
$invoice_calc = new InvoiceSum($invoice);
|
||||||
$this->invoice_calc->build();
|
$invoice_calc->build();
|
||||||
|
|
||||||
$this->invoice = $this->invoice_calc->getInvoice();
|
$invoice = $invoice_calc->getInvoice();
|
||||||
$this->invoice->save();
|
$invoice->save();
|
||||||
$this->invoice->service()->markSent()->createInvitations()->save();
|
$invoice->service()->markSent()->createInvitations()->save();
|
||||||
|
|
||||||
$this->assertEquals(10, $this->invoice->balance);
|
$this->assertEquals(10, $invoice->balance);
|
||||||
$this->assertEquals(10, $this->invoice->client->fresh()->balance);
|
$this->assertEquals(10, $invoice->client->fresh()->balance);
|
||||||
|
|
||||||
$this->invoice = $this->invoice->service()->markPaid()->save();
|
$invoice = $invoice->service()->markPaid()->save();
|
||||||
|
|
||||||
$this->assertEquals(0, $this->invoice->balance);
|
$this->assertEquals(0, $invoice->balance);
|
||||||
$this->assertEquals(0, $this->invoice->client->balance);
|
$this->assertEquals(0, $invoice->client->balance);
|
||||||
|
|
||||||
$this->assertTrue($this->invoice->payments()->exists());
|
$this->assertTrue($invoice->payments()->exists());
|
||||||
|
|
||||||
$payment = $this->invoice->payments()->first();
|
$payment = $invoice->payments()->first();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $this->encodePrimaryKey($payment->id),
|
'id' => $this->encodePrimaryKey($payment->id),
|
||||||
@ -1486,7 +1486,7 @@ class PaymentTest extends TestCase
|
|||||||
'date' => '2021/12/12',
|
'date' => '2021/12/12',
|
||||||
'invoices' => [
|
'invoices' => [
|
||||||
[
|
[
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $invoice->hashed_id,
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -1508,8 +1508,8 @@ class PaymentTest extends TestCase
|
|||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
$this->assertEquals(10, $this->invoice->fresh()->balance);
|
$this->assertEquals(10, $invoice->fresh()->balance);
|
||||||
$this->assertEquals(10, $this->invoice->fresh()->balance);
|
$this->assertEquals(10, $invoice->fresh()->balance);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'ids' => [$this->encodePrimaryKey($payment->id)],
|
'ids' => [$this->encodePrimaryKey($payment->id)],
|
||||||
@ -1520,14 +1520,14 @@ class PaymentTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/payments/bulk?action=delete', $data);
|
])->post('/api/v1/payments/bulk?action=delete', $data);
|
||||||
|
|
||||||
$this->assertEquals(10, $this->invoice->fresh()->balance);
|
$this->assertEquals(10, $invoice->fresh()->balance);
|
||||||
$this->assertEquals(10, $this->invoice->fresh()->balance);
|
$this->assertEquals(10, $invoice->fresh()->balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUniquePaymentNumbers()
|
public function testUniquePaymentNumbers()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'amount' => $this->invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'client_id' => $this->client->hashed_id,
|
'client_id' => $this->client->hashed_id,
|
||||||
'date' => '2020/12/12',
|
'date' => '2020/12/12',
|
||||||
'number' => 'duplicate',
|
'number' => 'duplicate',
|
||||||
|
Loading…
Reference in New Issue
Block a user