Skip to content

Instantly share code, notes, and snippets.

@romaninsh
Created November 14, 2016 12:36
Show Gist options
  • Select an option

  • Save romaninsh/682199df28a49ee53b96ddbc9b721cbf to your computer and use it in GitHub Desktop.

Select an option

Save romaninsh/682199df28a49ee53b96ddbc9b721cbf to your computer and use it in GitHub Desktop.
<?php
namespace smbo\tests;
class VATRules extends TestCase
{
function complextest($is_invoice_basis, $is_invoice_locked, $is_purchase) {
if($is_invoice_basis) {
$this->app->system['is_invoice_basis'] = true;
}
if($is_purchase) {
$c = $this->app->add('Contact_Supplier');
}else{
$c = $this->app->add('Contact_Client');
}
$c1 = $c->save('Smith Consultancy');
$i1 = $c1->ref('Invoice')->insert([
'ref_no'=>'inv101',
'date'=>'2015-01-01',
'lines'=>[[
'total_gross'=>375,
]]
]);
if ($is_invoice_locked) {
// payment locks invoice
$i->ref('Payment')->insert(['total_gross'=>375]);
}
// Now perform action
$i['date'] = '2015-03-01';
try {
$i->save();
return true;
} catch(LogicException $e) {
return false;
}
}
function test000() { $this->assertTrue($this->complextest(false, false, false)); }
function test001() { $this->assertTrue($this->complextest(false, false, true)); }
function test010() { $this->assertFalse($this->complextest(false, true, false)); }
function test011() { $this->assertTrue($this->complextest(false, true, true)); }
function test100() { $this->assertTrue($this->complextest(true, false, false)); }
function test101() { $this->assertFalse($this->complextest(true, false, true)); }
function test110() { $this->assertFalse($this->complextest(true, true, false)); }
function test111() { $this->assertFalse($this->complextest(true, true, true)); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment