Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
writeoffstorebatchaction.php
1
<?php
2
3
namespace
Bitrix\Catalog\Document\Action\Store
;
4
5
use Bitrix\Catalog\EO_StoreDocumentElement;
6
use
Bitrix\Catalog\Product\Store\BatchManager
;
7
use
Bitrix\Catalog\StoreDocumentElementTable
;
8
use
Bitrix\Main\Result
;
9
use
Bitrix\Catalog\Document\Action
;
10
use
Bitrix\Catalog\Product\Store\DistributionStrategy\DeductDocument
;
11
15
class
WriteOffStoreBatchAction
implements
Action
16
{
17
use
WriteOffAmountValidator
;
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
}
Bitrix\Catalog\Document\Action\Store\WriteOffStoreBatchAction
Definition
writeoffstorebatchaction.php:16
Bitrix\Catalog\Document\Action\Store\WriteOffStoreBatchAction\execute
execute()
Definition
writeoffstorebatchaction.php:53
Bitrix\Catalog\Document\Action\Store\WriteOffStoreBatchAction\canExecute
canExecute()
Definition
writeoffstorebatchaction.php:42
Bitrix\Catalog\Document\Action\Store\WriteOffStoreBatchAction\__construct
__construct(int $documentElementId, int $productId, float $amount,)
Definition
writeoffstorebatchaction.php:23
Bitrix\Catalog\Product\Store\BatchManager
Definition
batchmanager.php:19
Bitrix\Catalog\Product\Store\DistributionStrategy\DeductDocument
Definition
deductdocument.php:17
Bitrix\Catalog\StoreDocumentElementTable
Definition
storedocumentelementtable.php:50
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Catalog\Document\Action
Definition
action.php:11
Bitrix\Catalog\Document\Action\Store
Definition
basestorequantityaction.php:3
Bitrix\Catalog\Document\Action\Store\WriteOffAmountValidator
trait WriteOffAmountValidator
Definition
writeoffamountvalidator.php:15
Bitrix\Catalog\Document\Action\Store\checkStoreAmount
checkStoreAmount(EO_StoreDocumentElement $storeDocumentElement=null)
Definition
writeoffamountvalidator.php:18
Bitrix\Catalog\Document\Action
modules
catalog
lib
document
action
store
writeoffstorebatchaction.php
Создано системой
1.10.0