renamed income/expense

This commit is contained in:
denisdulici
2019-12-31 15:49:09 +03:00
parent e2189158b9
commit 2428feb73b
235 changed files with 815 additions and 2147 deletions

View File

@ -0,0 +1,119 @@
<?php
namespace Tests\Feature\Purchases;
use App\Jobs\Purchase\CreateBill;
use Tests\Feature\FeatureTestCase;
class BillsTest extends FeatureTestCase
{
public function testItShouldSeeBillListPage()
{
$this->loginAs()
->get(route('bills.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.bills', 2));
}
public function testItShouldSeeBillCreatePage()
{
$this->loginAs()
->get(route('bills.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.bills', 1)]));
}
public function testItShouldCreateBill()
{
$this->loginAs()
->post(route('bills.store'), $this->getBillRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldCreateBillWithRecurring()
{
$this->loginAs()
->post(route('bills.store'), $this->getBillRequest(true))
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldSeeBillUpdatePage()
{
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
$this->loginAs()
->get(route('bills.edit', ['bill' => $bill->id]))
->assertStatus(200)
->assertSee($bill->contact_name)
->assertSee($bill->contact_email);
}
public function testItShouldUpdateBill()
{
$request = $this->getBillRequest();
$bill = $this->dispatch(new CreateBill($request));
$request['contact_name'] = $this->faker->name;
$this->loginAs()
->patch(route('bills.update', $bill->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteBill()
{
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
$this->loginAs()
->delete(route('bills.destroy', $bill->id))
->assertStatus(200);
$this->assertFlashLevel('success');
}
private function getBillRequest($recurring = false)
{
$amount = $this->faker->randomFloat(2, 2);
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
$data = [
'company_id' => $this->company->id,
'billed_at' => $this->faker->date(),
'due_at' => $this->faker->date(),
'bill_number' => '1',
'order_number' => '1',
'currency_code' => setting('default.currency', 'USD'),
'currency_rate' => '1',
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('expense')->pluck('id')->first(),
'recurring_frequency' => 'no',
'contact_id' => '0',
'contact_name' => $this->faker->name,
'contact_email' =>$this->faker->email,
'contact_tax_number' => null,
'contact_phone' => null,
'contact_address' => $this->faker->address,
'bill_status_code' => 'draft',
'amount' => $amount,
];
if ($recurring) {
$data['recurring_frequency'] = 'yes';
$data['recurring_interval'] = '1';
$data['recurring_custom_frequency'] = $this->faker->randomElement(['monthly', 'weekly']);
$data['recurring_count'] = '1';
}
return $data;
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace Tests\Feature\Purchases;
use App\Jobs\Banking\CreateTransaction;
use App\Models\Banking\Transaction;
use Tests\Feature\FeatureTestCase;
class PaymentsTest extends FeatureTestCase
{
public function testItShouldSeePaymentListPage()
{
$this->loginAs()
->get(route('payments.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.payments', 2));
}
public function testItShouldSeePaymentCreatePage()
{
$this->loginAs()
->get(route('payments.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.payments', 1)]));
}
public function testItShouldCreatePayment()
{
$this->loginAs()
->post(route('payments.store'), factory(Transaction::class)->states('expense')->raw())
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldUpdatePayment()
{
$request = factory(Transaction::class)->states('expense')->raw();
$payment = $this->dispatch(new CreateTransaction($request));
$request['name'] = $this->faker->text(15);
$this->loginAs()
->patch(route('payments.update', $payment->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeletePayment()
{
$payment = $this->dispatch(new CreateTransaction(factory(Transaction::class)->states('expense')->raw()));
$this->loginAs()
->delete(route('payments.destroy', $payment->id))
->assertStatus(200);
$this->assertFlashLevel('success');
}
}

View File

@ -0,0 +1,97 @@
<?php
namespace Tests\Feature\Purchases;
use App\Jobs\Common\CreateContact;
use Tests\Feature\FeatureTestCase;
class VendorsTest extends FeatureTestCase
{
public function testItShouldSeeVendorListPage()
{
$this->loginAs()
->get(route('vendors.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.vendors', 2));
}
public function testItShouldSeeVendorCreatePage()
{
$this->loginAs()
->get(route('vendors.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.vendors', 1)]));
}
public function testItShouldCreateVendor()
{
$this->loginAs()
->post(route('vendors.store'), $this->getVendorRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldSeeVendorDetailPage()
{
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
$this->loginAs()
->get(route('vendors.show', ['vendor' => $vendor->id]))
->assertStatus(200)
->assertSee($vendor->email);
}
public function testItShouldSeeVendorUpdatePage()
{
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
$this->loginAs()
->get(route('vendors.edit', ['vendor' => $vendor->id]))
->assertStatus(200)
->assertSee($vendor->email)
->assertSee($vendor->name);
}
public function testItShouldUpdateVendor()
{
$request = $this->getVendorRequest();
$vendor = $this->dispatch(new CreateContact($request));
$request['name'] = $this->faker->name;
$this->loginAs()
->patch(route('vendors.update', $vendor->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteVendor()
{
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
$this->loginAs()
->delete(route('vendors.destroy', $vendor->id))
->assertStatus(200);
$this->assertFlashLevel('success');
}
private function getVendorRequest()
{
return [
'company_id' => $this->company->id,
'type' => 'vendor',
'name' => $this->faker->name,
'email' => $this->faker->email,
'tax_number' => $this->faker->randomNumber(9),
'phone' => $this->faker->phoneNumber,
'address' => $this->faker->address,
'website' => 'www.akaunting.com',
'currency_code' => $this->company->currencies()->enabled()->first()->code,
'enabled' => $this->faker->boolean ? 1 : 0
];
}
}