Line item discounts

This commit is contained in:
Hillel Coren 2017-12-21 21:36:00 +02:00
parent 2f6de520ec
commit 569cfdb5d2
5 changed files with 79 additions and 9 deletions

View File

@ -16,7 +16,7 @@ php:
addons: addons:
hosts: hosts:
- ninja.dev - www.ninja.test
cache: cache:
directories: directories:
@ -63,14 +63,14 @@ before_script:
- php artisan migrate --database=db-ninja-0 --seed --no-interaction - php artisan migrate --database=db-ninja-0 --seed --no-interaction
- php artisan migrate --database=db-ninja-1 --seed --no-interaction - php artisan migrate --database=db-ninja-1 --seed --no-interaction
- php artisan migrate --database=db-ninja-2 --seed --no-interaction - php artisan migrate --database=db-ninja-2 --seed --no-interaction
# Start webserver on ninja.dev:8000 # Start webserver on ninja.test:8000
- php artisan serve --host=ninja.dev --port=8000 & # '&' allows to run in background - php artisan serve --host=www.ninja.test --port=8000 & # '&' allows to run in background
# Start PhantomJS # Start PhantomJS
- phantomjs --webdriver=4444 & # '&' allows to run in background - phantomjs --webdriver=4444 & # '&' allows to run in background
# Give it some time to start # Give it some time to start
- sleep 5 - sleep 5
# Make sure the app is up-to-date # Make sure the app is up-to-date
- curl -L http://ninja.dev:8000/update - curl -L http://www.ninja.test:8000/update
- php artisan ninja:create-test-data 4 true - php artisan ninja:create-test-data 4 true
- php artisan db:seed --no-interaction --class=UserTableSeeder # development seed - php artisan db:seed --no-interaction --class=UserTableSeeder # development seed
- sed -i 's/DB_TYPE=db-ninja-1/DB_TYPE=db-ninja-2/g' .env - sed -i 's/DB_TYPE=db-ninja-1/DB_TYPE=db-ninja-2/g' .env
@ -91,6 +91,7 @@ script:
- php ./vendor/codeception/codeception/codecept run --debug acceptance PaymentCest.php - php ./vendor/codeception/codeception/codecept run --debug acceptance PaymentCest.php
- php ./vendor/codeception/codeception/codecept run --debug acceptance TaskCest.php - php ./vendor/codeception/codeception/codecept run --debug acceptance TaskCest.php
- php ./vendor/codeception/codeception/codecept run --debug acceptance GatewayFeesCest.php - php ./vendor/codeception/codeception/codecept run --debug acceptance GatewayFeesCest.php
- php ./vendor/codeception/codeception/codecept run --debug acceptance DiscountCest.php
- php ./vendor/codeception/codeception/codecept run --debug acceptance AllPagesCept.php - php ./vendor/codeception/codeception/codecept run --debug acceptance AllPagesCept.php
#- sed -i 's/NINJA_DEV=true/NINJA_PROD=true/g' .env #- sed -i 's/NINJA_DEV=true/NINJA_PROD=true/g' .env

View File

@ -1,4 +1,4 @@
<table class="table invoice-table"> <table class="table invoice-table {{ $isTasks ? 'task-table' : 'product-table' }}">
<thead {!! $isTasks ? 'style="display:none;" data-bind="visible: $root.hasTasks"' : ($invoice->has_tasks || ! empty($tasks) ? 'data-bind="visible: $root.hasItems"' : '') !!}> <thead {!! $isTasks ? 'style="display:none;" data-bind="visible: $root.hasTasks"' : ($invoice->has_tasks || ! empty($tasks) ? 'data-bind="visible: $root.hasItems"' : '') !!}>
@if ($isTasks) @if ($isTasks)
<tr data-bind="visible: $root.hasItems"> <tr data-bind="visible: $root.hasItems">
@ -32,7 +32,7 @@
</td> </td>
<td> <td>
<div id="scrollable-dropdown-menu"> <div id="scrollable-dropdown-menu">
<input type="text" data-bind="productTypeahead: product_key, items: $root.products, key: 'product_key', valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[{{ $isTasks ? 'T' : '' }}' + $index() + '][product_key]'}" class="form-control invoice-item handled"/> <input id="product_key" type="text" data-bind="productTypeahead: product_key, items: $root.products, key: 'product_key', valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[{{ $isTasks ? 'T' : '' }}' + $index() + '][product_key]'}" class="form-control invoice-item handled"/>
</div> </div>
</td> </td>
<td> <td>

View File

@ -2,7 +2,7 @@
// This is global bootstrap for autoloading // This is global bootstrap for autoloading
use Codeception\Util\Fixtures; use Codeception\Util\Fixtures;
Fixtures::add('url', 'http://ninja.dev:8000'); Fixtures::add('url', 'http://www.ninja.test:8000');
Fixtures::add('username', 'user@example.com'); Fixtures::add('username', 'user@example.com');
Fixtures::add('password', 'password'); Fixtures::add('password', 'password');

View File

@ -8,7 +8,7 @@ class_name: AcceptanceTester
modules: modules:
enabled: enabled:
- WebDriver: - WebDriver:
url: 'http://ninja.dev:8000/' url: 'http://www.ninja.test:8000'
window_size: 1024x768 window_size: 1024x768
wait: 5 wait: 5
browser: firefox browser: firefox

View File

@ -0,0 +1,69 @@
<?php
use Codeception\Util\Fixtures;
use Faker\Factory;
class DiscountCest
{
private $faker;
public function _before(AcceptanceTester $I)
{
$I->checkIfLogin($I);
$this->faker = Factory::create();
}
public function lineItemDiscounts(AcceptanceTester $I)
{
$I->wantTo('test line item discounts');
$clientEmail = $this->faker->safeEmail;
$itemTaxName = $this->faker->word;
$itemTaxRate = rand(1, 1000) / 10;
$itemDiscount = rand(1, 1000) / 10;
$discount = rand(1, 1000) / 10;
$itemAmount = rand(1, 10000) / 10;
$quantity = rand(1,20);
$I->amOnPage('/settings/invoice_design#product_fields');
$I->selectOption('#product_fields_select', 'product.discount');
$I->click('Save');
$I->amOnPage('/clients/create');
$I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
$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'], $itemTaxRate);
$I->click('Save');
$I->see($itemTaxName);
$I->amOnPage('/invoices/create');
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
// check tax and discount rounding
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
$I->fillField('#discount', $discount);
$this->fillItem($I, 1, 'Item', 'Notes', $itemAmount, $quantity, $itemDiscount);
$I->click('Mark Sent');
}
private function fillItem(AcceptanceTester $I, $row, $product, $description, $cost, $quantity, $discount)
{
$row_selector = sprintf('table.product-table tr:nth-child(%d) ', $row);
$I->fillField($row_selector.'#product_key', $product);
$I->fillField($row_selector.'textarea', $description);
$I->fillField($row_selector.'td:nth-child(4) input', $cost);
$I->fillField($row_selector.'td:nth-child(5) input', $quantity);
$I->fillField($row_selector.'td:nth-child(6) input', $discount);
}
}