Skip to content

Commit

Permalink
Invoice test and invoice update issue solved
Browse files Browse the repository at this point in the history
  • Loading branch information
Batuhan Baş committed Nov 5, 2018
1 parent 97b3536 commit 413b68f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/Incomes/Invoices.php
Expand Up @@ -240,6 +240,7 @@ public function update(Invoice $invoice, Request $request)
{
$taxes = [];

$tax = 0;
$tax_total = 0;
$sub_total = 0;
$discount_total = 0;
Expand Down
22 changes: 12 additions & 10 deletions tests/Feature/Incomes/InvoicesTest.php
Expand Up @@ -58,6 +58,7 @@ public function testItShouldUpdateInvoice()
->assertStatus(302);

$this->assertFlashLevel('success');

}

public function testItShouldDeleteInvoice()
Expand All @@ -70,25 +71,24 @@ public function testItShouldDeleteInvoice()
->assertRedirect(url('incomes/invoices'));

$this->assertFlashLevel('success');

}

private function getInvoiceRequest($recurring = 0)
{
$amount = $this->faker->randomFloat(2, 2);

$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];

$data = [
'company_id' => $this->company->id,
'customer_id' => '0',
'currency_code' => setting('general.default_currency'),
'currency_rate' => '1',
'invoiced_at' => $this->faker->date(),
'due_at' => $this->faker->date(),
'invoice_number' => $this->faker->lexify('INV ???'),
'order_number' => $this->faker->randomDigit,
'item_id' => null,
'item_name' => $this->faker->text(5),
'item_quantity' => '1',
'item_price' => $amount,
'item_currency' => setting('general.default_currency'),
'invoice_number' => '1',
'order_number' => '1',
'currency_code' => setting('general.default_currency'),
'currency_rate' => '1',
'item' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
Expand All @@ -100,6 +100,7 @@ private function getInvoiceRequest($recurring = 0)
'customer_address' => $this->faker->address,
'invoice_status_code' => 'draft',
'amount' => $amount,
'company_id' => $this->company->id,
];

if ($recurring) {
Expand All @@ -108,6 +109,7 @@ private function getInvoiceRequest($recurring = 0)
$data['recurring_custom_frequency'] = $this->faker->randomElement(['monthly', 'weekly']);
$data['recurring_count'] = '1';
}

return $data;
}
}

0 comments on commit 413b68f

Please sign in to comment.