Last active
November 14, 2016 13:11
-
-
Save romaninsh/56c409d7db1ab39dae55612d53497794 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace smbo\tests; | |
/** | |
* Tests usage of classes thorugh bridge | |
*/ | |
class InvoiceTest extends TestCase | |
{ | |
function testInvoiceCreation() | |
{ | |
$c = $this->app->add('Contact_Client'); | |
$c1 = $c->save('YOKE01'); | |
$n = $this->app->add('Nominal')->insert('Sales:Blah'); | |
$i1 = $c1->ref('Invoice')->insert([ | |
'ref_no'=>'101', | |
'note'=>'Brand Awareness Leads for the month', | |
'seq_no'=>'101', | |
'date'=>'11/07/2014', | |
'nominal'=>'Sales:Blah', | |
'lines'=>[[ | |
'total_net'=>375, | |
'total_vat'=>86.25, | |
]] | |
]); | |
$i1->reload(); | |
$this->assertEquals(375+86.25, $i1['total_gross']); | |
$this->assertEquals(375+86.25, $i1['amount_due']); | |
$c->reload(); | |
$this->assertEquals(375+86.25, $c['total_sale']); | |
$this->app->add('Account')->insert('MyBank'); | |
// next lets add some payment | |
$p1 = $c1->ref('Payment')->save([ | |
'note'=>'some payment', | |
'payment_type'=>'Cheque', | |
'account'=>'MyBank', | |
'total_gross'=>300, | |
]); | |
$this->assertEquals(300, $p1['amount_due_calc']); | |
$p1->allocate($c1->ref('Invoice')->loadAny()); | |
$p1->reload(); | |
$this->assertEquals(0, $p1['amount_due']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment