Invoice testing and line item catchup
This commit is contained in:
33
tests/Feature/InvoiceTest.php
Normal file
33
tests/Feature/InvoiceTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\Service;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InvoiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvoiceAmount()
|
||||
{
|
||||
// Create two services for the same account
|
||||
|
||||
// First service was billed a month ago, so this invoice will have 1 service charge
|
||||
$o = factory(Service::class)->states('next-invoice')->make();
|
||||
$o->setRelation('product',factory(Product::class)->states('strict')->make());
|
||||
$this->assertEquals(110,$o->next_invoice_items(FALSE)->sum('total'),'Invoice Equals 110');
|
||||
|
||||
// Second service wasnt billed, connected 1.5 months ago, so invoice will have 2 service charges - 1 x 0.5 month and 1 x full month. and a connection charge
|
||||
$o = factory(Service::class)->states('new-connect')->make();
|
||||
$o->setRelation('product',factory(Product::class)->states('strict')->make());
|
||||
$this->assertEqualsWithDelta(110+110+55+55,$o->next_invoice_items(FALSE)->sum('total'),2.5,'Invoice Equals 220');
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@ use Tests\TestCase;
|
||||
class ServiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic feature test example.
|
||||
* Test billing calculations
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
Reference in New Issue
Block a user