35 public function resolveParams($documentImport)
42 $params = $documentImport->getFieldValues();
46 foreach ($availableFields as $k)
52 if(isset($params[$k]))
53 $fields[$k] = $params[$k];
56 if(isset($params[
'COMMENT']))
57 $fields[$k] = $params[
'COMMENT'];
59 case 'DELIVERY_DOC_DATE':
60 if(isset($params[
'1C_DATE']))
61 $fields[$k] = $params[
'1C_DATE'];
63 case 'DELIVERY_DOC_NUM':
64 if(isset($params[
'REK_VALUES'][
'1C_DELIVERY_NUM']))
65 $fields[$k] = $params[
'REK_VALUES'][
'1C_DELIVERY_NUM'];
71 if(isset($params[
'REK_VALUES'][
'DEDUCTED']))
72 $deducted = $params[
'REK_VALUES'][
'DEDUCTED'];
73 if(isset($params[
'REK_VALUES'][
'CANCEL']))
74 $cancel = $params[
'REK_VALUES'][
'CANCEL'];
78 elseif($cancel ==
'Y')
81 case 'ALLOW_DELIVERY':
83 if(isset($params['REK_VALUES']['DEDUCTED']))
84 $value = $params['REK_VALUES']['DEDUCTED'];
89 case 'TRACKING_NUMBER':
90 if(isset($params['REK_VALUES']['1C_TRACKING_NUMBER']))
91 $fields[$k] = $params['REK_VALUES']['1C_TRACKING_NUMBER'];
93 case 'BASE_PRICE_DELIVERY':
97 $deliverySystemId = 0;
98 if(isset($params['REK_VALUES']['DELIVERY_SYSTEM_ID']))
100 $deliverySystemId = $params[
'REK_VALUES'][
'DELIVERY_SYSTEM_ID'];
103 if($deliverySystemId<=0)
105 if(isset($params[
'REK_VALUES'][
'DELIVERY_SYSTEM_ID_DEFAULT']))
107 $deliverySystemId = $params[
'REK_VALUES'][
'DELIVERY_SYSTEM_ID_DEFAULT'];
112 $settings = $this->getSettings();
114 if($deliverySystemId<=0)
116 $deliverySystemId = $settings->shipmentServiceFor($this->getEntityTypeId());
119 if($deliverySystemId<=0)
121 $deliverySystemId = $settings->shipmentServiceDefaultFor($this->getEntityTypeId());
124 $fields[$k] = $deliverySystemId;
129 $result[
'TRAITS'] = isset($fields)? $fields:array();
130 $result[
'ITEMS'] = isset($params[
'ITEMS'])? $this->modifyItemIdByItemName($params[
'ITEMS']):array();
131 $result[
'TAXES'] = isset($params[
'TAXES'])? $params[
'TAXES']:array();
141 static public function sanitizeFields($shipment=
null, array &$fields, ISettings $settings)
143 if(!empty($shipment) && !($shipment instanceof Shipment))
144 throw new ArgumentException(
"Entity must be instanceof Shipment");
146 foreach($fields as $k=>$v)
150 case 'BASE_PRICE_DELIVERY':
151 if((!empty($shipment)? $shipment->getPrice():
'') != $v)
154 $fields[
'CURRENCY'] = $settings->getCurrency();
155 $fields[
'CUSTOM_PRICE_DELIVERY'] =
"Y";
159 unset($fields[
'BASE_PRICE_DELIVERY']);
163 if(!empty($shipment))
165 unset($fields[
'DELIVERY_ID']);
170 unset($fields[
'ID']);
173 public function externalize(array $fields)
177 $traits = $fields[
'TRAITS'];
178 $items = $fields[
'ITEMS'] ?? [];
179 $stories = $fields[
'STORIES'] ?? [];
180 $taxes = $fields[
'TAXES'] ?? [];
181 $businessValue = $fields[
'BUSINESS_VALUE'];
188 foreach ($availableFields as $k=>$v)
194 $value = (!empty($traits[
'ID_1C']) ? $traits[
'ID_1C'] : $traits[
'ID']);
197 $value = $traits[
'ID'];
201 $value = $traits[
'DATE_INSERT'];
210 $replaceCurrency = $settings->getReplaceCurrency();
211 $value = mb_substr($replaceCurrency <>
''? $replaceCurrency : $traits[$k], 0, 3);
213 case 'CURRENCY_RATE':
214 $value = self::CURRENCY_RATE_DEFAULT;;
218 foreach ($items as $item)
222 $price = $price + $item[
'PRICE'] * $item[
'QUANTITY'];
226 $value = $price + $traits[
'PRICE_DELIVERY'];
230 $value = $traits[
'VERSION'];
233 $value = $traits[
'ORDER_ID'];
236 if (count($taxes) > 0)
238 $value = $this->externalizeTaxes($taxes, $v);
242 if (count($stories) > 0)
244 $value = $this->externalizeStories($stories, $v);
248 $value = $traits[
'COMMENTS'];
251 if (count($items) > 0)
253 $value = $this->externalizeItems($items, $v);
258 foreach($v[
'FIELDS'] as $name=>$fieldInfo)
263 case 'PRICE_DELIVERY':
264 $valueRV = ($traits[
'PRICE_DELIVERY'] <>
''? $traits[
'PRICE_DELIVERY']:
"0.0000");
266 case 'DATE_ALLOW_DELIVERY':
267 case 'DELIVERY_LOCATION':
268 case 'DATE_DEDUCTED':
269 case 'REASON_UNDO_DEDUCTED':
271 case 'REASON_MARKED':
272 case 'TRACKING_NUMBER':
273 $valueRV = $traits[$name];
276 $valueRV = $traits[
'CANCELED'];
278 case 'DELIVERY_SYSTEM_ID':
279 $valueRV = $traits[
'DELIVERY_ID'];
281 case 'DELIVERY_STATUS':
282 $valueRV = $traits[
'STATUS_ID'];
284 case 'DELIVERY_DEDUCTED':
285 $valueRV = $traits[
'DEDUCTED'];
288 $valueRV = $traits[
'DELIVERY_NAME'];
290 case 'DELIVERY_DATE_CANCEL':
291 $valueRV = $traits[
'DATE_CANCELED'];
293 case 'CANCEL_REASON':
294 $valueRV = $traits[
'REASON_CANCELED'];
297 $valueRV =
'['.$traits[
'LID'].
'] '.static::getSiteNameByLid($traits[
'LID']);
300 $value = array_merge($value, $this->externalizeRekv($businessValue[$name], $fieldInfo));
303 if(!in_array($name, array(
'REKV')))
305 $value[] = $this->externalizeRekvValue($name, $valueRV, $fieldInfo);
310 if(!in_array($k, array(
'TAXES',
'STORES',
'ITEMS',
'REK_VALUES')))
312 $this->externalizeField($value, $v);
315 $result[$k] = $value;
317 $result = $this->modifyTrim($result);
321 public function externalizeItems(array $taxes, array $info)
325 return $converter->externalizeItems($taxes, $info);
328 public function externalizeStories(array $stories, array $info)
332 return $converter->externalizeStories($stories, $info);
335 public function externalizeTaxes(array $items, array $info)
339 return $converter->externalizeTaxes($items, $info);
344 if(is_array($list) && count($list)>0)
346 foreach($list as $item)
348 foreach($item as $fields)
355 return $fields[
"PRICE"];
if(!function_exists(__NAMESPACE__.'\\___1034172934'))