<?php
namespace App\Config; class SupplierInvoiceOverPaymentTolerance extends XmlBasicAbstract { protected $fileName = CONFIG_FILE_SUPPLIERINVOICES_OVERPAYMENTTOLERANCE; protected function getAll_rawData_extractDataFromFile(\SimpleXMLElement $xml) { return [ 'positiveLimit' => (float)$xml->positiveLimit, 'negativeLimit' => (float)$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['supplierInvoicePayment']['statusTolerancePercent'] or $this->itemsList['positiveLimit']>1) { $this->addErrorMessage('The positive limit of the overpayment tolerance is not valid.'); } if (!is_numeric($this->itemsList['negativeLimit']) or $this->itemsList['negativeLimit'] < $CFG['supplierInvoicePayment']['statusTolerancePercent'] or $this->itemsList['negativeLimit']>1) { $this->addErrorMessage('The negative limit of the overpayment tolerance is not valid.'); } } protected function save_write_do_getXml() { $xml=simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><supplierInvoiceOverSupplierTolerance />'); $xml->positiveLimit = $this->itemsList['positiveLimit']; $xml->negativeLimit = $this->itemsList['negativeLimit']; return $xml; } }