Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
writeoffstorebatchaction.php
1<?php
2
4
5use Bitrix\Catalog\EO_StoreDocumentElement;
11
16{
18 private ?EO_StoreDocumentElement $storeDocumentElement;
19 private int $productId;
20
21 private int $storeId;
22 private float $amount;
23 public function __construct(
24 int $documentElementId,
25 int $productId,
26 float $amount,
27 )
28 {
29 $this->productId = $productId;
30 $this->amount = $amount;
31
32 $this->storeDocumentElement = StoreDocumentElementTable::getList([
33 'filter' => [
34 '=ID' => $documentElementId,
35 ],
36 'limit' => 1
37 ])
38 ->fetchObject()
39 ;
40 }
41
42 public function canExecute(): Result
43 {
44 $this->productId = $this->storeDocumentElement->getElementId();
45 $this->storeId = $this->storeDocumentElement->getStoreFrom();
46
47 return $this->checkStoreAmount($this->storeDocumentElement);
48 }
49
53 public function execute(): Result
54 {
55 $distributor = new DeductDocument(
56 new BatchManager($this->productId),
57 $this->storeDocumentElement
58 );
59
60 return $distributor->writeOff($this->amount);
61 }
62}
__construct(int $documentElementId, int $productId, float $amount,)
static getList(array $parameters=array())
checkStoreAmount(EO_StoreDocumentElement $storeDocumentElement=null)