Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
unreservestoreproductaction.php
1
<?php
2
3
namespace
Bitrix\Catalog\Document\Action\Reserve
;
4
5
use
Bitrix\Catalog\Document\Action
;
6
use
Bitrix\Main\Application
;
7
use
Bitrix\Main\Error
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Main\Result
;
10
11
Loc::loadMessages
(
12
Application::getDocumentRoot
() .
'/bitrix/modules/catalog/general/store_docs_type.php'
13
);
14
18
class
UnReserveStoreProductAction
implements
Action
19
{
20
use
BaseReserveStoreProductAction
;
21
25
public
function
canExecute
():
Result
26
{
27
$result =
new
Result
();
28
29
$reservedQuantity = $this->
getProductTotalReservedQuantity
();
30
if
($reservedQuantity < $this->amount)
31
{
32
$message =
Loc::getMessage
(
"CATALOG_STORE_DOCS_ERR_WRONG_RESERVED_AMOUNT"
, [
33
'#PRODUCT#'
=> $this->
getProductName
(),
34
]);
35
$result->addError(
new
Error
($message));
36
return
$result;
37
}
38
39
$reservedQuantity = $this->
getStoreReservedQuantity
();
40
if
($reservedQuantity < $this->amount)
41
{
42
$message =
Loc::getMessage
(
"CATALOG_STORE_DOCS_ERR_INSUFFICIENTLY_AMOUNT"
, [
43
'#PRODUCT#'
=> $this->
getProductName
(),
44
'#STORE#'
=> $this->
getStoreName
(),
45
]);
46
$result->addError(
new
Error
($message));
47
return
$result;
48
}
49
50
return
$result;
51
}
52
56
protected
function
getNewProductQuantity
(): float
57
{
58
return
$this->
getProductTotalQuantity
() +
$this->amount
;
59
}
60
64
protected
function
getNewProductReservedQuantity
(): float
65
{
66
return
$this->
getProductTotalReservedQuantity
() -
$this->amount
;
67
}
68
72
protected
function
getNewStoreReservedQuantity
(): float
73
{
74
return
$this->
getStoreReservedQuantity
() -
$this->amount
;
75
}
76
}
Bitrix\Catalog\Document\Action\Reserve\UnReserveStoreProductAction
Definition
unreservestoreproductaction.php:19
Bitrix\Catalog\Document\Action\Reserve\UnReserveStoreProductAction\getNewProductReservedQuantity
getNewProductReservedQuantity()
Definition
unreservestoreproductaction.php:64
Bitrix\Catalog\Document\Action\Reserve\UnReserveStoreProductAction\getNewProductQuantity
getNewProductQuantity()
Definition
unreservestoreproductaction.php:56
Bitrix\Catalog\Document\Action\Reserve\UnReserveStoreProductAction\getNewStoreReservedQuantity
getNewStoreReservedQuantity()
Definition
unreservestoreproductaction.php:72
Bitrix\Catalog\Document\Action\Reserve\UnReserveStoreProductAction\canExecute
canExecute()
Definition
unreservestoreproductaction.php:25
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getDocumentRoot
static getDocumentRoot()
Definition
application.php:717
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
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\Reserve
Definition
basereservestoreproductaction.php:3
Bitrix\Catalog\Document\Action\Reserve\BaseReserveStoreProductAction
trait BaseReserveStoreProductAction
Definition
basereservestoreproductaction.php:21
Bitrix\Catalog\Document\Action\Reserve\$amount
$amount
Definition
basereservestoreproductaction.php:37
Bitrix\Catalog\Document\Action
Bitrix\Catalog\Document\Action\getProductTotalQuantity
getProductTotalQuantity()
Definition
productandstoreinfo.php:201
Bitrix\Catalog\Document\Action\getStoreReservedQuantity
getStoreReservedQuantity()
Definition
productandstoreinfo.php:129
Bitrix\Catalog\Document\Action\getProductName
getProductName()
Definition
productandstoreinfo.php:139
Bitrix\Catalog\Document\Action\getStoreName
getStoreName()
Definition
productandstoreinfo.php:51
Bitrix\Catalog\Document\Action\getProductTotalReservedQuantity
getProductTotalReservedQuantity()
Definition
productandstoreinfo.php:211
modules
catalog
lib
document
action
reserve
unreservestoreproductaction.php
Создано системой
1.10.0