Improvements to taxing

This commit is contained in:
Deon George
2013-12-05 16:22:23 +11:00
parent 8ba487a4a6
commit 778eada7f0
13 changed files with 253 additions and 212 deletions

View File

@@ -66,7 +66,7 @@ class Model_Payment extends ORM_OSB {
public function balance($format=FALSE) {
$result = $this->total();
foreach ($this->items('ALLOC') as $pio)
foreach ($this->subitems('ALLOC') as $pio)
$result -= $pio->alloc_amt;
return $format ? Currency::display($result) : Currency::round($result);
@@ -78,7 +78,7 @@ class Model_Payment extends ORM_OSB {
public function credit($format=FALSE) {
$result = 0;
foreach ($this->items('CREDIT') as $pio)
foreach ($this->subitems('CREDIT') as $pio)
$result += $pio->alloc_amt*-1;
return $format ? Currency::display($result) : Currency::round($result);
@@ -105,7 +105,7 @@ class Model_Payment extends ORM_OSB {
* @param type [ALLOC|CREDIT|ALL]
* @see payment_items
*/
public function items($type='ALL') {
public function subitems($type='ALL') {
if (! $this->_sub_items_sorted) {
Sort::MAsort($this->_sub_items,'invoice_id');
$this->_sub_items_sorted = TRUE;
@@ -145,7 +145,7 @@ class Model_Payment extends ORM_OSB {
*/
public function save(Validation $validation = NULL) {
// Our items will be clobbered once we save the object, so we need to save it here.
$items = $this->items();
$items = $this->subitems();
// If a user modified this payment, we'll update the source to their ID.
if ($ao = Auth::instance()->get_user())