From a43b613e1069d04752cf479462d71b18b56e2816 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 14 Feb 2017 22:02:54 +0200 Subject: [PATCH] Improve invoice tests --- app/Ninja/Repositories/InvoiceRepository.php | 2 -- resources/views/invoices/edit.blade.php | 2 +- tests/acceptance/InvoiceCest.php | 15 +++++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 94854bb6acc9..d03ea7b311e6 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -498,8 +498,6 @@ class InvoiceRepository extends BaseRepository if ($invoice->is_amount_discount) { $total -= $invoice->discount; } else { - //$total *= (100 - $invoice->discount) / 100; - //$total = round($total, 2); $discount = round($total * ($invoice->discount / 100), 2); $total -= $discount; } diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index f6e1ae83aa79..125342172cc6 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -253,7 +253,7 @@ - {{ $invoiceLabels['item'] }} + {{ $invoiceLabels['item'] }} {{ $invoiceLabels['description'] }} @if ($account->showCustomField('custom_invoice_item_label1')) {{ $account->custom_invoice_item_label1 }} diff --git a/tests/acceptance/InvoiceCest.php b/tests/acceptance/InvoiceCest.php index 4c244c2400ca..35156472a7e8 100644 --- a/tests/acceptance/InvoiceCest.php +++ b/tests/acceptance/InvoiceCest.php @@ -28,6 +28,8 @@ class InvoiceCest $I->click('Save'); $I->see($clientEmail); + $clientId = $I->grabFromCurrentUrl('~clients/(\d+)~'); + $I->amOnPage('/tax_rates/create'); $I->fillField(['name' => 'name'], $itemTaxName); $I->fillField(['name' => 'rate'], 21); @@ -38,18 +40,22 @@ class InvoiceCest $invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value'); + // check tax and discount rounding $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); $I->selectDataPicker($I, '#invoice_date'); $I->selectDataPicker($I, '#due_date', '+ 15 day'); $I->fillField('#po_number', rand(100, 200)); $I->fillField('#discount', 15); - + $I->selectOption('#taxRateSelect1', $itemTaxName . ' 21%'); $this->fillItem($I, 1, 'Item', 'Notes', 64.50, 3); $I->click('#saveButton'); $I->wait(1); $I->see($invoiceNumber); - //$I->see('199.01'); + $I->see('199.01'); + + $I->amOnPage("/clients/{$clientId}#invoices"); + $I->see('199.01'); } /* @@ -87,7 +93,8 @@ class InvoiceCest } } */ - private function createRecurringInvoice(AcceptanceTester $I) + + public function createRecurringInvoice(AcceptanceTester $I) { $clientEmail = $this->faker->safeEmail; @@ -118,7 +125,7 @@ class InvoiceCest } - private function cloneInvoice(AcceptanceTester $I) + public function cloneInvoice(AcceptanceTester $I) { $I->wantTo('clone an invoice'); $I->amOnPage('/invoices/1/clone');