36 'ORDER_ID',
'PAYMENT_ID',
'ENTITY_ID',
'ENTITY_TYPE',
37 'DATE_INSERT',
'QUANTITY',
'XML_ID'
54 return Internals\PayableItemTable::getMap();
68 $item = static::createPayableItemObject();
72 $item->item = $entity;
74 if ($entity->getId() > 0)
76 $item->setFieldNoDemand(
'ENTITY_ID', $entity->getId());
79 $item->setFieldNoDemand(
'ENTITY_TYPE', static::getEntityType());
80 $item->setFieldNoDemand(
'XML_ID', static::generateXmlId());
87 return (
float)$this->getField(
'QUANTITY');
106 private static function createPayableItemObject(array $fields = array())
109 $entityClassName = $registry->get(static::getRegistryEntity());
111 return new $entityClassName($fields);
121 public static function loadForPayment($id)
123 if (intval($id) <= 0)
132 $dbRes = $payableItemCollection::getList([
134 '=PAYMENT_ID' => $id,
135 '=ENTITY_TYPE' => static::getEntityType()
140 while ($data = $dbRes->fetch())
142 $entityList[] = static::createPayableItemObject($data);
156 if (!$this->isChanged())
161 $id = $this->getId();
165 $fields = $this->getFields()->getChangedValues();
173 if ((
int)$this->getField(
'ENTITY_ID') === 0)
175 $this->setFieldNoDemand(
'ENTITY_ID', $this->
getEntityObject()->getId());
178 $this->setFieldNoDemand(
'DATE_INSERT',
new Main\
Type\
DateTime());
179 $this->setFieldNoDemand(
'PAYMENT_ID', $payment->getId());
181 $fields = $this->getFields()->getValues();
186 $this->setFieldNoDemand(
'ID', $id);
190 if (!$r->isSuccess())
192 return $result->addErrors($r->getErrors());
208 return Internals\PayableItemTable::update($primary, $data);
218 return Internals\PayableItemTable::add($data);