From 133ae4d5c68efbd1dbd356deba750c5429742306 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 2 Feb 2013 17:35:21 +1100 Subject: [PATCH] Fix to not record /bin/bash allocation --- modules/payment/classes/Model/Payment.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/payment/classes/Model/Payment.php b/modules/payment/classes/Model/Payment.php index 944c1da6..0c2d49ca 100644 --- a/modules/payment/classes/Model/Payment.php +++ b/modules/payment/classes/Model/Payment.php @@ -191,8 +191,12 @@ class Model_Payment extends ORM_OSB { parent::save($validation); // Need to save the associated items and their taxes - if ($this->saved()) { + if (! $this->changed() OR $this->saved()) { foreach ($items as $pio) { + // Skip applying 0 payments to invoices. + if (Currency::round($pio->alloc_amt) == 0 AND ! $pio->loaded()) + continue; + $pio->payment_id = $this->id; if (! $pio->check()) { @@ -208,8 +212,9 @@ class Model_Payment extends ORM_OSB { } } - } else + } else { throw new Kohana_Exception('Couldnt save payment for some reason?'); + } return TRUE; }