<?php
 namespace App\Config; class InvoiceOverCashTolerance extends XmlBasicAbstract { protected $fileName=CONFIG_FILE_INVOICES_OVERCASHTOLERANCE; protected function getAll_rawData_extractDataFromFile(\SimpleXMLElement $xml) { return [ 'positiveLimit' => (Double)$xml->positiveLimit, 'negativeLimit' => (Double)$xml->negativeLimit, ]; } protected function getAll_rawData_fileNotExists() { $return= [ 'positiveLimit' => 0.01, 'negativeLimit' => 0.01, ]; return $return; } protected function save_check() { global $CFG; if (!is_numeric($this->itemsList['positiveLimit']) or $this->itemsList['positiveLimit']<$CFG['invoiceCashing']['statusTolerancePercent'] or $this->itemsList['positiveLimit']>1) { $this->addErrorMessage('The positive limit of the over-cash tolerance is not valid.'); } if (!is_numeric($this->itemsList['negativeLimit']) or $this->itemsList['negativeLimit']<$CFG['invoiceCashing']['statusTolerancePercent'] or $this->itemsList['negativeLimit']>1) { $this->addErrorMessage('The negative limit of the over-cash tolerance is not valid.'); } } protected function save_write_do_getXml() { $xml=simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><invoiceOverCashTolerance />'); $xml->positiveLimit=$this->itemsList['positiveLimit']; $xml->negativeLimit=$this->itemsList['negativeLimit']; return $xml; } } 