15 use Magento\Sales\Model\Order\InvoiceFactory;
120 private $invoiceFactory;
144 \
Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
147 \
Magento\Sales\Model\OrderFactory $orderFactory,
149 \
Magento\Framework\Math\CalculatorFactory $calculatorFactory,
157 InvoiceFactory $invoiceFactory =
null 159 $this->_creditmemoConfig = $creditmemoConfig;
160 $this->_orderFactory = $orderFactory;
161 $this->_cmItemCollectionFactory = $cmItemCollectionFactory;
162 $this->_calculatorFactory = $calculatorFactory;
164 $this->_commentFactory = $commentFactory;
165 $this->_commentCollectionFactory = $commentCollectionFactory;
206 return $this->
getOrder()->getStore();
229 if (!$this->_order instanceof \
Magento\Sales\Model\
Order) {
230 $this->_order = $this->_orderFactory->create()->load($this->
getOrderId());
232 return $this->_order->setHistoryEntityName($this->entityType);
252 return $this->
getOrder()->getBillingAddress();
262 return $this->
getOrder()->getShippingAddress();
270 $collection = $this->_cmItemCollectionFactory->create()->setCreditmemoFilter($this->
getId());
272 if ($this->
getId()) {
274 $item->setCreditmemo($this);
287 if (!
$item->isDeleted()) {
301 if (
$item->getId() == $itemId) {
317 if (
$item->getOrderItemId() == $orderId) {
331 if (!$item->getId()) {
361 if (!isset($this->_calculators[
$type])) {
362 $this->_calculators[
$type] = $this->_calculatorFactory->create([
'scope' => $this->
getStore()]);
374 if ($this->
getState() != self::STATE_CANCELED &&
375 $this->
getState() != self::STATE_REFUNDED &&
393 return $this->
getData(
'invoice');
404 $this->
setData(
'invoice', $invoice);
435 if (static::$_states ===
null) {
437 self::STATE_OPEN =>
__(
'Pending'),
438 self::STATE_REFUNDED =>
__(
'Refunded'),
439 self::STATE_CANCELED =>
__(
'Canceled'),
442 return static::$_states;
453 if ($stateId ===
null) {
457 if (static::$_states ===
null) {
460 if (isset(static::$_states[$stateId])) {
461 return static::$_states[$stateId];
463 return __(
'Unknown State');
482 if (substr(
$amount, -1) ==
'%') {
502 if (substr(
$amount, -1) ==
'%') {
524 if (!
$item->isLast()) {
553 public function addComment($comment, $notify =
false, $visibleOnFront =
false)
556 $comment = $this->_commentFactory->create()->setComment(
558 )->setIsCustomerNotified(
560 )->setIsVisibleOnFront(
564 $comment->setCreditmemo($this)->setParentId($this->
getId())->setStoreId($this->
getStoreId());
576 $collection = $this->_commentCollectionFactory->create()->setCreditmemoFilter($this->
getId())
577 ->setCreatedAtOrder();
579 if ($this->
getId()) {
581 $comment->setCreditmemo($this);
605 return $this->
getData(
'increment_id');
613 return !($this->
getGrandTotal() <= 0 && !$this->getAllowZeroGrandTotal());
const BASE_SHIPPING_AMOUNT
const DISCOUNT_DESCRIPTION
const GLOBAL_CURRENCY_CODE
const SHIPPING_ADDRESS_ID
const BASE_SHIPPING_INCL_TAX
setTransactionId($transactionId)
const BASE_DISCOUNT_AMOUNT
getItemByOrderId($orderId)
setAdjustmentNegative($amount)
setBaseTaxAmount($amount)
getDiscountTaxCompensationAmount()
setAdjustment($adjustment)
const BASE_ADJUSTMENT_NEGATIVE
$_commentCollectionFactory
setShippingDiscountTaxCompensationAmount($amount)
setDiscountTaxCompensationAmount($amount)
setBaseAdjustmentPositive($baseAdjustmentPositive)
setBaseToGlobalRate($rate)
getFilteredCollectionItems($filter=null)
_getExtensionAttributes()
const STORE_TO_ORDER_RATE
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\Order\Creditmemo\Config $creditmemoConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory, \Magento\Framework\Math\CalculatorFactory $calculatorFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], InvoiceFactory $invoiceFactory=null)
const STORE_CURRENCY_CODE
getShippingDiscountTaxCompensationAmount()
const BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT
setBaseDiscountTaxCompensationAmount($amount)
const SHIPPING_DISCOUNT_TAX_COMPENSATION_AMOUNT
setGlobalCurrencyCode($code)
setBaseShippingDiscountTaxCompensationAmnt($amnt)
getCommentsCollection($reload=false)
getBaseShippingDiscountTaxCompensationAmnt()
const REPORT_DATE_TYPE_ORDER_CREATED
const DISCOUNT_TAX_COMPENSATION_AMOUNT
setBaseShippingAmount($amount)
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
setOrder(\Magento\Sales\Model\Order $order)
setAdjustmentPositive($amount)
setDiscountAmount($amount)
getBaseAdjustmentNegative()
setShippingAddressId($id)
addItem(\Magento\Sales\Model\Order\Creditmemo\Item $item)
setBaseDiscountAmount($amount)
const ADJUSTMENT_POSITIVE
const SHIPPING_TAX_AMOUNT
setBaseSubtotalInclTax($amount)
$_cmItemCollectionFactory
setBaseAdjustment($baseAdjustment)
const ORDER_CURRENCY_CODE
const BASE_ADJUSTMENT_POSITIVE
setShippingAmount($amount)
setOrderCurrencyCode($code)
setCreditmemoStatus($creditmemoStatus)
const BASE_SHIPPING_TAX_AMOUNT
setSubtotalInclTax($amount)
setShippingTaxAmount($amount)
getBaseShippingTaxAmount()
setInvoice(Invoice $invoice)
getStateName($stateId=null)
setBaseAdjustmentNegative($baseAdjustmentNegative)
setStoreCurrencyCode($code)
const REPORT_DATE_TYPE_REFUND_CREATED
setBaseGrandTotal($amount)
getData($key='', $index=null)
getBaseDiscountTaxCompensationAmount()
const ADJUSTMENT_NEGATIVE
addComment($comment, $notify=false, $visibleOnFront=false)
setData($key, $value=null)
setBaseShippingInclTax($amount)
roundPrice($price, $type='regular', $negative=false)
setBaseCurrencyCode($code)
setBaseShippingTaxAmount($amount)
setStoreToBaseRate($rate)
const BASE_TO_GLOBAL_RATE
setShippingInclTax($amount)
setBaseToOrderRate($rate)
const BASE_SHIPPING_DISCOUNT_TAX_COMPENSATION_AMNT
setExtensionAttributes(\Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes)
getBaseAdjustmentPositive()
setStoreToOrderRate($rate)
const BASE_SUBTOTAL_INCL_TAX
setDiscountDescription($description)