2015-10-20 19:12:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Codeception\Util\Fixtures;
|
|
|
|
use Faker\Factory;
|
|
|
|
|
2015-10-21 14:40:31 +02:00
|
|
|
class CheckBalanceCest
|
2015-10-20 19:12:34 +02:00
|
|
|
{
|
|
|
|
private $faker;
|
|
|
|
|
|
|
|
public function _before(AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
$I->checkIfLogin($I);
|
|
|
|
|
|
|
|
$this->faker = Factory::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkBalance(AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
$I->wantTo('ensure the balance is correct');
|
2016-10-02 11:51:30 +02:00
|
|
|
|
2015-10-20 19:12:34 +02:00
|
|
|
$clientEmail = $this->faker->safeEmail;
|
|
|
|
$productKey = $this->faker->text(10);
|
|
|
|
$productPrice = $this->faker->numberBetween(1, 20);
|
|
|
|
|
|
|
|
// create client
|
|
|
|
$I->amOnPage('/clients/create');
|
2015-10-28 20:22:07 +01:00
|
|
|
$I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
|
2015-10-20 19:12:34 +02:00
|
|
|
$I->click('Save');
|
|
|
|
$I->wait(1);
|
|
|
|
$I->see($clientEmail);
|
|
|
|
|
|
|
|
$clientId = $I->grabFromCurrentUrl('~clients/(\d+)~');
|
2016-10-02 11:51:30 +02:00
|
|
|
|
2015-10-20 19:12:34 +02:00
|
|
|
// create product
|
|
|
|
$I->amOnPage('/products/create');
|
|
|
|
$I->fillField(['name' => 'product_key'], $productKey);
|
|
|
|
$I->fillField(['name' => 'notes'], $this->faker->text(80));
|
|
|
|
$I->fillField(['name' => 'cost'], $productPrice);
|
|
|
|
$I->click('Save');
|
|
|
|
$I->wait(1);
|
2016-10-02 11:51:30 +02:00
|
|
|
//$I->see($productKey);
|
|
|
|
|
2015-10-20 19:12:34 +02:00
|
|
|
// create invoice
|
|
|
|
$I->amOnPage('/invoices/create');
|
|
|
|
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
|
|
|
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
|
2016-02-29 19:08:09 +01:00
|
|
|
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
|
2016-12-05 19:22:11 +01:00
|
|
|
$I->click('Mark Sent');
|
2017-03-22 21:28:03 +01:00
|
|
|
$I->wait(5);
|
2015-10-20 19:12:34 +02:00
|
|
|
$I->see($clientEmail);
|
|
|
|
$invoiceId = $I->grabFromCurrentUrl('~invoices/(\d+)~');
|
|
|
|
$I->amOnPage("/clients/{$clientId}");
|
|
|
|
$I->see('Balance $' . $productPrice);
|
2016-10-02 11:51:30 +02:00
|
|
|
|
2015-10-20 19:12:34 +02:00
|
|
|
// update the invoice
|
|
|
|
$I->amOnPage('/invoices/' . $invoiceId);
|
2015-10-28 20:22:07 +01:00
|
|
|
$I->fillField(['name' => 'invoice_items[0][qty]'], 2);
|
2017-03-25 20:51:08 +01:00
|
|
|
$I->click('Save Invoice');
|
2015-10-20 19:12:34 +02:00
|
|
|
$I->wait(1);
|
|
|
|
$I->amOnPage("/clients/{$clientId}");
|
|
|
|
$I->see('Balance $' . ($productPrice * 2));
|
|
|
|
|
|
|
|
// enter payment
|
|
|
|
$I->amOnPage("/payments/create/{$clientId}/{$invoiceId}");
|
|
|
|
$I->click('Save');
|
|
|
|
$I->wait(1);
|
|
|
|
$I->see('Balance $0.00');
|
|
|
|
$I->see('Paid to Date $' . ($productPrice * 2));
|
|
|
|
|
|
|
|
// archive the invoice
|
2016-06-07 16:29:26 +02:00
|
|
|
$I->amOnPage('/invoices/' . $invoiceId);
|
2015-10-28 20:22:07 +01:00
|
|
|
$I->executeJS('submitBulkAction("archive")');
|
2015-10-20 19:12:34 +02:00
|
|
|
$I->wait(1);
|
|
|
|
$I->amOnPage("/clients/{$clientId}");
|
|
|
|
$I->see('Balance $0.00');
|
|
|
|
$I->see('Paid to Date $' . ($productPrice * 2));
|
2016-06-07 16:18:52 +02:00
|
|
|
|
2015-10-20 19:12:34 +02:00
|
|
|
// delete the invoice
|
2016-06-07 16:29:26 +02:00
|
|
|
$I->amOnPage('/invoices/' . $invoiceId);
|
2016-10-06 12:02:25 +02:00
|
|
|
$I->executeJS('submitBulkAction("restore")');
|
2016-11-09 15:13:13 +01:00
|
|
|
$I->wait(2);
|
2015-10-28 20:22:07 +01:00
|
|
|
$I->executeJS('submitBulkAction("delete")');
|
2015-10-20 19:12:34 +02:00
|
|
|
$I->wait(1);
|
|
|
|
$I->amOnPage("/clients/{$clientId}");
|
|
|
|
$I->see('Balance $0.00');
|
|
|
|
$I->see('Paid to Date $0.00');
|
2015-10-30 13:56:25 +01:00
|
|
|
|
|
|
|
// restore the invoice
|
2016-06-07 16:29:26 +02:00
|
|
|
$I->amOnPage('/invoices/' . $invoiceId);
|
2015-10-30 13:56:25 +01:00
|
|
|
$I->executeJS('submitBulkAction("restore")');
|
|
|
|
$I->wait(1);
|
|
|
|
$I->amOnPage("/clients/{$clientId}");
|
|
|
|
$I->see('Balance $0.00');
|
|
|
|
$I->see('Paid to Date $' . ($productPrice * 2));
|
2015-10-20 19:12:34 +02:00
|
|
|
}
|
2016-10-02 11:51:30 +02:00
|
|
|
}
|