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; }