setPrvCycleId($prvreading->getReadingCycleId()); $this->setPrvidx($prvreading->getNewidx()); $this->setPrvdate($prvreading->getNewdate()); $readingcycle = ReadingCyclePeer::getCurrentCycle(); $this->setReadingCycleId($readingcycle->getId()); $this->checkIdxdiff(); $this->checkNbofdays(); $this->checkDonotbill(); $this->setIsBilled(0); } public function checkIdxdiff() { if ($this->getIsClocked()) { $meter = MeterPeer::retrieveByPk($this->getMeterId()); $maxidx = pow(10,$meter->getDigits()); $idxdiff = ($maxidx - $this->getPrvidx()) + $this->getNewidx(); } else { $idxdiff = $this->getNewidx() - $this->getPrvidx(); } $this->setIdxdiff($idxdiff); } public function checkNbofdays() { $nbofdays = abs((strtotime($this->getNewdate()) - strtotime($this->getPrvdate())) / 86400 + 1); $this->setNbofdays($nbofdays); } public function checkDonotbill() { if (($this->getPrvidx() == $this->getNewidx()) || ($this->getIdxdiff() == 0)) { $this->setDonotbill(1); } else { $this->setDonotbill(0); } } }