61 abstract public static function getType();
71 abstract public static function getName();
92 public static function create($handler)
94 if (class_exists($handler))
96 return new $handler();
107 $this->fields[
'TYPE'] = static::getType();
116 return $this->fields[$name];
125 $this->fields[$name] = $value;
133 foreach (
$fields as $name => $value)
144 if (!$this->
getField(
'LINK_PARAMS'))
155 $ofd = $cashbox->getOfd();
161 return $ofd->generateCheckLink($this->
getField(
'LINK_PARAMS'));
182 $entityRegistryType =
null;
184 foreach ($this->entities as $entity)
186 if ($entity instanceof
Payment)
188 $this->fields[
'PAYMENT_ID'] = $entity->getId();
189 $this->fields[
'SUM'] = $entity->getSum();
190 $this->fields[
'CURRENCY'] = $entity->getField(
'CURRENCY');
196 $this->fields[
'SHIPMENT_ID'] = $entity->getId();
199 if ($entityRegistryType ===
null)
201 $entityRegistryType = $entity::getRegistryType();
203 elseif ($entityRegistryType !== $entity::getRegistryType())
209 $collection = $entity->getCollection();
211 if ($orderId ===
null)
213 $orderId = $collection->getOrder()->getId();
215 elseif ($orderId != $collection->getOrder()->getId())
221 $this->fields[
'ORDER_ID'] = $orderId;
222 $this->fields[
'ENTITY_REGISTRY_TYPE'] = $entityRegistryType;
238 if ($this->fields[
'ORDER_ID'] > 0)
240 $orderId = $this->fields[
'ORDER_ID'];
242 elseif ($this->fields[
'PAYMENT_ID'] > 0)
245 $paymentClassName = $registry->getPaymentClassName();
246 $dbRes = $paymentClassName::getList([
248 'ID' => $this->fields[
'PAYMENT_ID']
251 $data = $dbRes->fetch();
252 $orderId = $data[
'ORDER_ID'];
254 elseif ($this->fields[
'SHIPMENT_ID'] > 0)
257 $shipmentClassName = $registry->getShipmentClassName();
258 $dbRes = $shipmentClassName::getList([
260 'ID' => $this->fields[
'SHIPMENT_ID']
263 $data = $dbRes->fetch();
264 $orderId = $data[
'ORDER_ID'];
273 $orderClassName = $registry->getOrderClassName();
276 $order = $orderClassName::load($orderId);
279 if ($this->fields[
'PAYMENT_ID'] > 0)
281 $payment = $order->getPaymentCollection()->getItemById($this->fields[
'PAYMENT_ID']);
284 $this->entities[] = $payment;
288 if ($this->fields[
'SHIPMENT_ID'] > 0)
290 $shipment = $order->getShipmentCollection()->getItemById($this->fields[
'SHIPMENT_ID']);
293 $this->entities[] = $shipment;
308 if ((
int)$this->fields[
'ID'] > 0)
316 if (!$result->isSuccess())
321 $checkId = $result->getId();
322 $this->fields[
'ID'] = $checkId;
324 foreach ($this->cashboxList as $cashbox)
327 'CHECK_ID' => $checkId,
328 'CASHBOX_ID' => $cashbox[
'ID']
340 $this->fields[
'CASHBOX_ID'] = $cashboxId;
346 public function init($settings)
348 $this->fields = $settings;
360 self::EVENT_ON_CHECK_PREPARE_DATA,
361 [$result, static::getType()]
365 if ($event->getResults())
367 foreach ($event->getResults() as $eventResult)
371 $result = $eventResult->getParameters();
390 static $vatList = array();
396 $dbRes = Catalog\VatTable::getList(array(
'filter' => array(
'ACTIVE' =>
'Y')));
397 while ($data = $dbRes->fetch())
399 $vatList[(int)$data[
'RATE']] = (
int)$data[
'ID'];
404 if (!isset($vatList[$vatRate]))
409 return $vatList[$vatRate];
Exception is thrown when the type of an argument is not accepted by function.
static includeModule($moduleName)
Includes a module by its name.
static add(array $data)
Adds row to entity table.
static update($primary, array $data)
Updates row in entity table by primary key.
Base class for fatal exceptions.
__construct()
Check constructor.
setAvailableCashbox(array $cashboxList)
const CALCULATED_SIGN_INCOME
const EVENT_ON_CHECK_PREPARE_DATA
const PARAM_CALCULATION_ATTR
const SUPPORTED_ENTITY_TYPE_ALL
const SUPPORTED_ENTITY_TYPE_SHIPMENT
static getSupportedEntityType()
const PAYMENT_TYPE_ADVANCE
const PAYMENT_TYPE_CREDIT
getVatIdByVatRate($vatRate)
const PARAM_FISCAL_DOC_ATTR
setEntities(array $entities)
const PARAM_FISCAL_DOC_NUMBER
const CALCULATED_SIGN_CONSUMPTION
const SUPPORTED_ENTITY_TYPE_NONE
static getCalculatedSign()
const PARAM_FISCAL_RECEIPT_NUMBER
const PARAM_REG_NUMBER_KKT
const SUPPORTED_ENTITY_TYPE_PAYMENT
const PAYMENT_TYPE_CASHLESS
static getObjectById($id)
static getInstance($type)