mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on tests
This commit is contained in:
parent
4b2592fa39
commit
0a3d9b24de
@ -498,6 +498,8 @@ class InvoiceRepository extends BaseRepository
|
|||||||
if ($invoice->is_amount_discount) {
|
if ($invoice->is_amount_discount) {
|
||||||
$total -= $invoice->discount;
|
$total -= $invoice->discount;
|
||||||
} else {
|
} else {
|
||||||
|
//$total *= (100 - $invoice->discount) / 100;
|
||||||
|
//$total = round($total, 2);
|
||||||
$discount = round($total * ($invoice->discount / 100), 2);
|
$discount = round($total * ($invoice->discount / 100), 2);
|
||||||
$total -= $discount;
|
$total -= $discount;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class InvoiceCest
|
|||||||
|
|
||||||
$this->faker = Factory::create();
|
$this->faker = Factory::create();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public function createInvoice(AcceptanceTester $I)
|
public function createInvoice(AcceptanceTester $I)
|
||||||
{
|
{
|
||||||
$clientEmail = $this->faker->safeEmail;
|
$clientEmail = $this->faker->safeEmail;
|
||||||
@ -27,6 +27,12 @@ class InvoiceCest
|
|||||||
$I->click('Save');
|
$I->click('Save');
|
||||||
$I->see($clientEmail);
|
$I->see($clientEmail);
|
||||||
|
|
||||||
|
$I->amOnPage('/tax_rates/create');
|
||||||
|
$I->fillField(['name' => 'name'], 'TAX_21');
|
||||||
|
$I->fillField(['name' => 'rate'], 21);
|
||||||
|
$I->click('Save');
|
||||||
|
$I->see($itemTaxName);
|
||||||
|
|
||||||
$I->amOnPage('/invoices/create');
|
$I->amOnPage('/invoices/create');
|
||||||
|
|
||||||
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
|
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
|
||||||
@ -35,15 +41,16 @@ class InvoiceCest
|
|||||||
$I->selectDataPicker($I, '#invoice_date');
|
$I->selectDataPicker($I, '#invoice_date');
|
||||||
$I->selectDataPicker($I, '#due_date', '+ 15 day');
|
$I->selectDataPicker($I, '#due_date', '+ 15 day');
|
||||||
$I->fillField('#po_number', rand(100, 200));
|
$I->fillField('#po_number', rand(100, 200));
|
||||||
$I->fillField('#discount', rand(0, 20));
|
$I->fillField('#discount', 15);
|
||||||
|
|
||||||
$this->fillItems($I);
|
$this->fillItem($I, 'Item', 'Notes', 64.50, 3);
|
||||||
|
|
||||||
$I->click('#saveButton');
|
$I->click('#saveButton');
|
||||||
$I->wait(1);
|
$I->wait(1);
|
||||||
$I->see($invoiceNumber);
|
$I->see($invoiceNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public function editInvoice(AcceptanceTester $I)
|
public function editInvoice(AcceptanceTester $I)
|
||||||
{
|
{
|
||||||
$I->wantTo('edit an invoice');
|
$I->wantTo('edit an invoice');
|
||||||
@ -78,7 +85,7 @@ class InvoiceCest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public function createRecurringInvoice(AcceptanceTester $I)
|
private function createRecurringInvoice(AcceptanceTester $I)
|
||||||
{
|
{
|
||||||
$clientEmail = $this->faker->safeEmail;
|
$clientEmail = $this->faker->safeEmail;
|
||||||
|
|
||||||
@ -109,7 +116,7 @@ class InvoiceCest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function cloneInvoice(AcceptanceTester $I)
|
private function cloneInvoice(AcceptanceTester $I)
|
||||||
{
|
{
|
||||||
$I->wantTo('clone an invoice');
|
$I->wantTo('clone an invoice');
|
||||||
$I->amOnPage('/invoices/1/clone');
|
$I->amOnPage('/invoices/1/clone');
|
||||||
@ -146,15 +153,20 @@ class InvoiceCest
|
|||||||
for ($i = 1; $i <= $max; $i++) {
|
for ($i = 1; $i <= $max; $i++) {
|
||||||
$row_selector = sprintf('table.invoice-table tbody tr:nth-child(%d) ', $i);
|
$row_selector = sprintf('table.invoice-table tbody tr:nth-child(%d) ', $i);
|
||||||
|
|
||||||
$product_key = $this->faker->text(10);
|
$product = $this->faker->text(10);
|
||||||
$description = $this->faker->text(80);
|
$description = $this->faker->text(80);
|
||||||
$unit_cost = $this->faker->randomFloat(2, 0, 100);
|
$cost = $this->faker->randomFloat(2, 0, 100);
|
||||||
$quantity = $this->faker->randomDigitNotNull;
|
$quantity = $this->faker->randomDigitNotNull;
|
||||||
|
|
||||||
|
$this->fillItem($I, $product, $description, $cost, $quantity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fillItem(AcceptanceTester $I, $product, $description, $cost, $quantity)
|
||||||
|
{
|
||||||
$I->fillField($row_selector.'#product_key', $product_key);
|
$I->fillField($row_selector.'#product_key', $product_key);
|
||||||
$I->fillField($row_selector.'textarea', $description);
|
$I->fillField($row_selector.'textarea', $description);
|
||||||
$I->fillField($row_selector.'td:nth-child(4) input', $unit_cost);
|
$I->fillField($row_selector.'td:nth-child(4) input', $unit_cost);
|
||||||
$I->fillField($row_selector.'td:nth-child(5) input', $quantity);
|
$I->fillField($row_selector.'td:nth-child(5) input', $quantity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user