Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Static Protected Attributes
Creditmemo Class Reference
Inheritance diagram for Creditmemo:
AbstractModel EntityInterface CreditmemoInterface AbstractExtensibleModel ExtensibleDataInterface AbstractModel CustomAttributesDataInterface DataObject ExtensibleDataInterface

Public Member Functions

 __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)
 
 getConfig ()
 
 getStore ()
 
 setOrder (\Magento\Sales\Model\Order $order)
 
 getOrder ()
 
 getEntityType ()
 
 getBillingAddress ()
 
 getShippingAddress ()
 
 getItemsCollection ()
 
 getAllItems ()
 
 getItemById ($itemId)
 
 getItemByOrderId ($orderId)
 
 addItem (\Magento\Sales\Model\Order\Creditmemo\Item $item)
 
 collectTotals ()
 
 roundPrice ($price, $type='regular', $negative=false)
 
 canRefund ()
 
 getInvoice ()
 
 setInvoice (Invoice $invoice)
 
 canCancel ()
 
 canVoid ()
 
 getStateName ($stateId=null)
 
 setShippingAmount ($amount)
 
 setAdjustmentPositive ($amount)
 
 setAdjustmentNegative ($amount)
 
 isLast ()
 
 addComment ($comment, $notify=false, $visibleOnFront=false)
 
 getCommentsCollection ($reload=false)
 
 getFilteredCollectionItems ($filter=null)
 
 getIncrementId ()
 
 isValidGrandTotal ()
 
 getItems ()
 
 getComments ()
 
 getDiscountDescription ()
 
 setItems ($items)
 
 getAdjustment ()
 
 getAdjustmentNegative ()
 
 getAdjustmentPositive ()
 
 getBaseAdjustment ()
 
 getBaseAdjustmentNegative ()
 
 setBaseAdjustmentNegative ($baseAdjustmentNegative)
 
 getBaseAdjustmentPositive ()
 
 setBaseAdjustmentPositive ($baseAdjustmentPositive)
 
 getBaseCurrencyCode ()
 
 getBaseDiscountAmount ()
 
 getBaseGrandTotal ()
 
 getBaseDiscountTaxCompensationAmount ()
 
 getBaseShippingAmount ()
 
 getBaseShippingDiscountTaxCompensationAmnt ()
 
 getBaseShippingInclTax ()
 
 getBaseShippingTaxAmount ()
 
 getBaseSubtotal ()
 
 getBaseSubtotalInclTax ()
 
 getBaseTaxAmount ()
 
 getBaseToGlobalRate ()
 
 getBaseToOrderRate ()
 
 getBillingAddressId ()
 
 getCreatedAt ()
 
 setCreatedAt ($createdAt)
 
 getCreditmemoStatus ()
 
 getDiscountAmount ()
 
 getEmailSent ()
 
 getGlobalCurrencyCode ()
 
 getGrandTotal ()
 
 getDiscountTaxCompensationAmount ()
 
 getInvoiceId ()
 
 getOrderCurrencyCode ()
 
 getOrderId ()
 
 getShippingAddressId ()
 
 getShippingAmount ()
 
 getShippingDiscountTaxCompensationAmount ()
 
 getShippingInclTax ()
 
 getShippingTaxAmount ()
 
 getState ()
 
 getStoreCurrencyCode ()
 
 getStoreId ()
 
 getStoreToBaseRate ()
 
 getStoreToOrderRate ()
 
 getSubtotal ()
 
 getSubtotalInclTax ()
 
 getTaxAmount ()
 
 getTransactionId ()
 
 setTransactionId ($transactionId)
 
 getUpdatedAt ()
 
 setComments ($comments)
 
 setStoreId ($id)
 
 setBaseShippingTaxAmount ($amount)
 
 setStoreToOrderRate ($rate)
 
 setBaseDiscountAmount ($amount)
 
 setBaseToOrderRate ($rate)
 
 setGrandTotal ($amount)
 
 setBaseSubtotalInclTax ($amount)
 
 setSubtotalInclTax ($amount)
 
 setBaseShippingAmount ($amount)
 
 setStoreToBaseRate ($rate)
 
 setBaseToGlobalRate ($rate)
 
 setBaseAdjustment ($baseAdjustment)
 
 setBaseSubtotal ($amount)
 
 setDiscountAmount ($amount)
 
 setSubtotal ($amount)
 
 setAdjustment ($adjustment)
 
 setBaseGrandTotal ($amount)
 
 setBaseTaxAmount ($amount)
 
 setShippingTaxAmount ($amount)
 
 setTaxAmount ($amount)
 
 setOrderId ($id)
 
 setEmailSent ($emailSent)
 
 setCreditmemoStatus ($creditmemoStatus)
 
 setState ($state)
 
 setShippingAddressId ($id)
 
 setBillingAddressId ($id)
 
 setInvoiceId ($id)
 
 setStoreCurrencyCode ($code)
 
 setOrderCurrencyCode ($code)
 
 setBaseCurrencyCode ($code)
 
 setGlobalCurrencyCode ($code)
 
 setIncrementId ($id)
 
 setUpdatedAt ($timestamp)
 
 setDiscountTaxCompensationAmount ($amount)
 
 setBaseDiscountTaxCompensationAmount ($amount)
 
 setShippingDiscountTaxCompensationAmount ($amount)
 
 setBaseShippingDiscountTaxCompensationAmnt ($amnt)
 
 setShippingInclTax ($amount)
 
 setBaseShippingInclTax ($amount)
 
 setDiscountDescription ($description)
 
 getExtensionAttributes ()
 
 setExtensionAttributes (\Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes)
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getEventObject ()
 
- Public Member Functions inherited from AbstractExtensibleModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getCustomAttributes ()
 
 getCustomAttribute ($attributeCode)
 
 setCustomAttributes (array $attributes)
 
 setCustomAttribute ($attributeCode, $attributeValue)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 setId ($value)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from CreditmemoInterface
 getEntityId ()
 
 setEntityId ($entityId)
 
 setExtensionAttributes (\Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes)
 

Static Public Member Functions

static getStates ()
 

Data Fields

const STATE_OPEN = 1
 
const STATE_REFUNDED = 2
 
const STATE_CANCELED = 3
 
const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'
 
const REPORT_DATE_TYPE_REFUND_CREATED = 'refund_created'
 
- Data Fields inherited from CustomAttributesDataInterface
const CUSTOM_ATTRIBUTES = 'custom_attributes'
 
- Data Fields inherited from ExtensibleDataInterface
const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'
 
- Data Fields inherited from CreditmemoInterface
const ENTITY_ID = 'entity_id'
 
const STORE_ID = 'store_id'
 
const ADJUSTMENT_POSITIVE = 'adjustment_positive'
 
const BASE_SHIPPING_TAX_AMOUNT = 'base_shipping_tax_amount'
 
const STORE_TO_ORDER_RATE = 'store_to_order_rate'
 
const BASE_DISCOUNT_AMOUNT = 'base_discount_amount'
 
const BASE_TO_ORDER_RATE = 'base_to_order_rate'
 
const GRAND_TOTAL = 'grand_total'
 
const BASE_ADJUSTMENT_NEGATIVE = 'base_adjustment_negative'
 
const BASE_SUBTOTAL_INCL_TAX = 'base_subtotal_incl_tax'
 
const SHIPPING_AMOUNT = 'shipping_amount'
 
const SUBTOTAL_INCL_TAX = 'subtotal_incl_tax'
 
const ADJUSTMENT_NEGATIVE = 'adjustment_negative'
 
const BASE_SHIPPING_AMOUNT = 'base_shipping_amount'
 
const STORE_TO_BASE_RATE = 'store_to_base_rate'
 
const BASE_TO_GLOBAL_RATE = 'base_to_global_rate'
 
const BASE_ADJUSTMENT = 'base_adjustment'
 
const BASE_SUBTOTAL = 'base_subtotal'
 
const DISCOUNT_AMOUNT = 'discount_amount'
 
const SUBTOTAL = 'subtotal'
 
const ADJUSTMENT = 'adjustment'
 
const BASE_GRAND_TOTAL = 'base_grand_total'
 
const BASE_ADJUSTMENT_POSITIVE = 'base_adjustment_positive'
 
const BASE_TAX_AMOUNT = 'base_tax_amount'
 
const SHIPPING_TAX_AMOUNT = 'shipping_tax_amount'
 
const TAX_AMOUNT = 'tax_amount'
 
const ORDER_ID = 'order_id'
 
const EMAIL_SENT = 'email_sent'
 
const CREDITMEMO_STATUS = 'creditmemo_status'
 
const STATE = 'state'
 
const SHIPPING_ADDRESS_ID = 'shipping_address_id'
 
const BILLING_ADDRESS_ID = 'billing_address_id'
 
const INVOICE_ID = 'invoice_id'
 
const STORE_CURRENCY_CODE = 'store_currency_code'
 
const ORDER_CURRENCY_CODE = 'order_currency_code'
 
const BASE_CURRENCY_CODE = 'base_currency_code'
 
const GLOBAL_CURRENCY_CODE = 'global_currency_code'
 
const TRANSACTION_ID = 'transaction_id'
 
const INCREMENT_ID = 'increment_id'
 
const CREATED_AT = 'created_at'
 
const UPDATED_AT = 'updated_at'
 
const DISCOUNT_TAX_COMPENSATION_AMOUNT = 'discount_tax_compensation_amount'
 
const BASE_DISCOUNT_TAX_COMPENSATION_AMOUNT = 'base_discount_tax_compensation_amount'
 
const SHIPPING_DISCOUNT_TAX_COMPENSATION_AMOUNT = 'shipping_discount_tax_compensation_amount'
 
const BASE_SHIPPING_DISCOUNT_TAX_COMPENSATION_AMNT = 'base_shipping_discount_tax_compensation_amnt'
 
const SHIPPING_INCL_TAX = 'shipping_incl_tax'
 
const BASE_SHIPPING_INCL_TAX = 'base_shipping_incl_tax'
 
const DISCOUNT_DESCRIPTION = 'discount_description'
 
const ITEMS = 'items'
 
const COMMENTS = 'comments'
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractExtensibleModel
 filterCustomAttributes ($data)
 
 initializeCustomAttributes ()
 
 convertCustomAttributeValues (array &$customAttributes)
 
 getCustomAttributesCodes ()
 
 _setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
 
 _getExtensionAttributes ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $entityType = 'creditmemo'
 
 $_order
 
 $_calculators = []
 
 $_eventPrefix = 'sales_order_creditmemo'
 
 $_eventObject = 'creditmemo'
 
 $_creditmemoConfig
 
 $_orderFactory
 
 $_cmItemCollectionFactory
 
 $_calculatorFactory
 
 $_storeManager
 
 $_commentFactory
 
 $_commentCollectionFactory
 
 $priceCurrency
 
- Protected Attributes inherited from AbstractExtensibleModel
 $extensionAttributesFactory
 
 $extensionAttributes
 
 $customAttributeFactory
 
 $customAttributesCodes = null
 
 $customAttributesChanged = false
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Static Protected Attributes

static $_states
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Order creditmemo model

@api @method \Magento\Sales\Model\Order\Invoice setSendEmail(bool $value) @method \Magento\Sales\Model\Order\Invoice setCustomerNote(string $value) @method string getCustomerNote() @method \Magento\Sales\Model\Order\Invoice setCustomerNoteNotify(bool $value) @method bool getCustomerNoteNotify() @SuppressWarnings(PHPMD.ExcessivePublicCount) @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Since
100.0.2

Definition at line 31 of file Creditmemo.php.

Constructor & Destructor Documentation

◆ __construct()

__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 
)
Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Framework\Api\ExtensionAttributesFactory$extensionFactory
AttributeValueFactory$customAttributeFactory
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
Creditmemo\CommentFactory$commentFactory
\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment\CollectionFactory$commentCollectionFactory
PriceCurrencyInterface$priceCurrency
\Magento\Framework\Model\ResourceModel\AbstractResource$resource
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data
InvoiceFactory$invoiceFactory@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 141 of file Creditmemo.php.

158  {
159  $this->_creditmemoConfig = $creditmemoConfig;
160  $this->_orderFactory = $orderFactory;
161  $this->_cmItemCollectionFactory = $cmItemCollectionFactory;
162  $this->_calculatorFactory = $calculatorFactory;
163  $this->_storeManager = $storeManager;
164  $this->_commentFactory = $commentFactory;
165  $this->_commentCollectionFactory = $commentCollectionFactory;
166  $this->priceCurrency = $priceCurrency;
167  $this->invoiceFactory = $invoiceFactory ?: ObjectManager::getInstance()->get(InvoiceFactory::class);
168  parent::__construct(
169  $context,
170  $registry,
171  $extensionFactory,
173  $resource,
174  $resourceCollection,
175  $data
176  );
177  }
$storeManager
$resource
Definition: bulk.php:12
$invoiceFactory
Definition: order_info.php:82

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize creditmemo resource model

Returns
void

Definition at line 184 of file Creditmemo.php.

185  {
186  $this->_init(\Magento\Sales\Model\ResourceModel\Order\Creditmemo::class);
187  }

◆ addComment()

addComment (   $comment,
  $notify = false,
  $visibleOnFront = false 
)

Adds comment to credit memo with additional possibility to send it to customer via email and show it in customer account

Parameters
\Magento\Sales\Model\Order\Creditmemo\Comment | string$comment
bool$notify
bool$visibleOnFront
Returns
\Magento\Sales\Model\Order\Creditmemo\Comment

Definition at line 553 of file Creditmemo.php.

554  {
555  if (!$comment instanceof \Magento\Sales\Model\Order\Creditmemo\Comment) {
556  $comment = $this->_commentFactory->create()->setComment(
557  $comment
558  )->setIsCustomerNotified(
559  $notify
560  )->setIsVisibleOnFront(
561  $visibleOnFront
562  );
563  }
564  $comment->setCreditmemo($this)->setParentId($this->getId())->setStoreId($this->getStoreId());
565  $this->setComments(array_merge($this->getComments(), [$comment]));
566  return $comment;
567  }

◆ addItem()

Parameters
\Magento\Sales\Model\Order\Creditmemo\Item$item
Returns
$this

Definition at line 328 of file Creditmemo.php.

329  {
330  $item->setCreditmemo($this)->setParentId($this->getId())->setStoreId($this->getStoreId());
331  if (!$item->getId()) {
332  $this->setItems(array_merge($this->getItems(), [$item]));
333  }
334  return $this;
335  }

◆ canCancel()

canCancel ( )

Check creditmemo cancel action availability

Returns
bool

Definition at line 413 of file Creditmemo.php.

◆ canRefund()

canRefund ( )
Returns
bool

Definition at line 372 of file Creditmemo.php.

373  {
374  if ($this->getState() != self::STATE_CANCELED &&
375  $this->getState() != self::STATE_REFUNDED &&
376  $this->getOrder()->getPayment()->canRefund()
377  ) {
378  return true;
379  }
380  return false;
381  }

◆ canVoid()

canVoid ( )

Check invoice void action availability

Returns
bool

Definition at line 423 of file Creditmemo.php.

424  {
425  return false;
426  }

◆ collectTotals()

collectTotals ( )

Creditmemo totals collecting

Returns
$this

Definition at line 342 of file Creditmemo.php.

343  {
344  foreach ($this->getConfig()->getTotalModels() as $model) {
345  $model->collect($this);
346  }
347  return $this;
348  }

◆ getAdjustment()

getAdjustment ( )

Returns adjustment

Returns
float

Implements CreditmemoInterface.

Definition at line 673 of file Creditmemo.php.

◆ getAdjustmentNegative()

getAdjustmentNegative ( )

Returns adjustment_negative

Returns
float

Implements CreditmemoInterface.

Definition at line 683 of file Creditmemo.php.

◆ getAdjustmentPositive()

getAdjustmentPositive ( )

Returns adjustment_positive

Returns
float

Implements CreditmemoInterface.

Definition at line 693 of file Creditmemo.php.

◆ getAllItems()

getAllItems ( )
Returns
\Magento\Sales\Model\Order\Creditmemo\Item[]

Definition at line 283 of file Creditmemo.php.

284  {
285  $items = [];
286  foreach ($this->getItems() as $item) {
287  if (!$item->isDeleted()) {
288  $items[] = $item;
289  }
290  }
291  return $items;
292  }
$items

◆ getBaseAdjustment()

getBaseAdjustment ( )

Returns base_adjustment

Returns
float

Implements CreditmemoInterface.

Definition at line 703 of file Creditmemo.php.

◆ getBaseAdjustmentNegative()

getBaseAdjustmentNegative ( )

Returns base_adjustment_negative

Returns
float

Implements CreditmemoInterface.

Definition at line 713 of file Creditmemo.php.

◆ getBaseAdjustmentPositive()

getBaseAdjustmentPositive ( )

Returns base_adjustment_positive

Returns
float

Implements CreditmemoInterface.

Definition at line 734 of file Creditmemo.php.

◆ getBaseCurrencyCode()

getBaseCurrencyCode ( )

Returns base_currency_code

Returns
string

Implements CreditmemoInterface.

Definition at line 755 of file Creditmemo.php.

◆ getBaseDiscountAmount()

getBaseDiscountAmount ( )

Returns base_discount_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 765 of file Creditmemo.php.

◆ getBaseDiscountTaxCompensationAmount()

getBaseDiscountTaxCompensationAmount ( )

Returns base_discount_tax_compensation_amount

Returns
float|null

Implements CreditmemoInterface.

Definition at line 785 of file Creditmemo.php.

◆ getBaseGrandTotal()

getBaseGrandTotal ( )

Returns base_grand_total

Returns
float

Implements CreditmemoInterface.

Definition at line 775 of file Creditmemo.php.

◆ getBaseShippingAmount()

getBaseShippingAmount ( )

Returns base_shipping_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 795 of file Creditmemo.php.

◆ getBaseShippingDiscountTaxCompensationAmnt()

getBaseShippingDiscountTaxCompensationAmnt ( )

Returns base_shipping_discount_tax_compensation_amnt

Returns
float|null

Implements CreditmemoInterface.

Definition at line 805 of file Creditmemo.php.

◆ getBaseShippingInclTax()

getBaseShippingInclTax ( )

Returns base_shipping_incl_tax

Returns
float

Implements CreditmemoInterface.

Definition at line 815 of file Creditmemo.php.

◆ getBaseShippingTaxAmount()

getBaseShippingTaxAmount ( )

Returns base_shipping_tax_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 825 of file Creditmemo.php.

◆ getBaseSubtotal()

getBaseSubtotal ( )

Returns base_subtotal

Returns
float

Implements CreditmemoInterface.

Definition at line 835 of file Creditmemo.php.

◆ getBaseSubtotalInclTax()

getBaseSubtotalInclTax ( )

Returns base_subtotal_incl_tax

Returns
float

Implements CreditmemoInterface.

Definition at line 845 of file Creditmemo.php.

◆ getBaseTaxAmount()

getBaseTaxAmount ( )

Returns base_tax_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 855 of file Creditmemo.php.

◆ getBaseToGlobalRate()

getBaseToGlobalRate ( )

Returns base_to_global_rate

Returns
float

Implements CreditmemoInterface.

Definition at line 865 of file Creditmemo.php.

◆ getBaseToOrderRate()

getBaseToOrderRate ( )

Returns base_to_order_rate

Returns
float

Implements CreditmemoInterface.

Definition at line 875 of file Creditmemo.php.

◆ getBillingAddress()

getBillingAddress ( )

Retrieve billing address

Returns
Address

Definition at line 250 of file Creditmemo.php.

251  {
252  return $this->getOrder()->getBillingAddress();
253  }

◆ getBillingAddressId()

getBillingAddressId ( )

Returns billing_address_id

Returns
int

Implements CreditmemoInterface.

Definition at line 885 of file Creditmemo.php.

◆ getComments()

getComments ( )

Return creditmemo comments

Returns
\Magento\Sales\Api\Data\CreditmemoCommentInterface[]|null

Implements CreditmemoInterface.

Definition at line 637 of file Creditmemo.php.

◆ getCommentsCollection()

getCommentsCollection (   $reload = false)
Parameters
bool$reload
Returns
\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment\Collection @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 574 of file Creditmemo.php.

575  {
576  $collection = $this->_commentCollectionFactory->create()->setCreditmemoFilter($this->getId())
577  ->setCreatedAtOrder();
578 
579  if ($this->getId()) {
580  foreach ($collection as $comment) {
581  $comment->setCreditmemo($this);
582  }
583  }
584  return $collection;
585  }

◆ getConfig()

getConfig ( )

Retrieve Creditmemo configuration model

Returns
\Magento\Sales\Model\Order\Creditmemo\Config

Definition at line 194 of file Creditmemo.php.

◆ getCreatedAt()

getCreatedAt ( )

Returns created_at

Returns
string

Implements CreditmemoInterface.

Definition at line 895 of file Creditmemo.php.

◆ getCreditmemoStatus()

getCreditmemoStatus ( )

Returns creditmemo_status

Returns
int

Implements CreditmemoInterface.

Definition at line 913 of file Creditmemo.php.

◆ getDiscountAmount()

getDiscountAmount ( )

Returns discount_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 923 of file Creditmemo.php.

◆ getDiscountDescription()

getDiscountDescription ( )

Returns discount_description

Returns
string

Implements CreditmemoInterface.

Definition at line 655 of file Creditmemo.php.

◆ getDiscountTaxCompensationAmount()

getDiscountTaxCompensationAmount ( )

Returns discount_tax_compensation_amount

Returns
float|null

Implements CreditmemoInterface.

Definition at line 963 of file Creditmemo.php.

◆ getEmailSent()

getEmailSent ( )

Returns email_sent

Returns
int

Implements CreditmemoInterface.

Definition at line 933 of file Creditmemo.php.

◆ getEntityType()

getEntityType ( )

Return order entity type

Returns
string

Definition at line 240 of file Creditmemo.php.

241  {
242  return $this->entityType;
243  }

◆ getExtensionAttributes()

getExtensionAttributes ( )

{Retrieve existing extension attributes object or create a new one.

Returns
\Magento\Sales\Api\Data\CreditmemoExtensionInterface|null
}

Returns
\Magento\Sales\Api\Data\CreditmemoExtensionInterface|null

Implements CreditmemoInterface.

Definition at line 1492 of file Creditmemo.php.

◆ getFilteredCollectionItems()

getFilteredCollectionItems (   $filter = null)

Get creditmemos collection filtered by $filter

Parameters
array | null$filter
Returns
\Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection

Definition at line 593 of file Creditmemo.php.

594  {
595  return $this->getResourceCollection()->getFiltered($filter);
596  }

◆ getGlobalCurrencyCode()

getGlobalCurrencyCode ( )

Returns global_currency_code

Returns
string

Implements CreditmemoInterface.

Definition at line 943 of file Creditmemo.php.

◆ getGrandTotal()

getGrandTotal ( )

Returns grand_total

Returns
float

Implements CreditmemoInterface.

Definition at line 953 of file Creditmemo.php.

◆ getIncrementId()

getIncrementId ( )

Returns increment id

Returns
string

Implements CreditmemoInterface.

Definition at line 603 of file Creditmemo.php.

604  {
605  return $this->getData('increment_id');
606  }

◆ getInvoice()

getInvoice ( )

Returns assigned invoice

Returns
Invoice|null

Definition at line 388 of file Creditmemo.php.

389  {
390  if (!$this->getData('invoice') instanceof \Magento\Sales\Api\Data\InvoiceInterface && $this->getInvoiceId()) {
391  $this->setInvoice($this->invoiceFactory->create()->load($this->getInvoiceId()));
392  }
393  return $this->getData('invoice');
394  }

◆ getInvoiceId()

getInvoiceId ( )

Returns invoice_id

Returns
int

Implements CreditmemoInterface.

Definition at line 973 of file Creditmemo.php.

◆ getItemById()

getItemById (   $itemId)
Parameters
mixed$itemId
Returns
mixed

Definition at line 298 of file Creditmemo.php.

299  {
300  foreach ($this->getItemsCollection() as $item) {
301  if ($item->getId() == $itemId) {
302  return $item;
303  }
304  }
305  return false;
306  }

◆ getItemByOrderId()

getItemByOrderId (   $orderId)

Returns credit memo item by its order id

Parameters
mixed$orderId
Returns
\Magento\Sales\Model\Order\Creditmemo\Item|bool

Definition at line 314 of file Creditmemo.php.

315  {
316  foreach ($this->getItemsCollection() as $item) {
317  if ($item->getOrderItemId() == $orderId) {
318  return $item;
319  }
320  }
321  return false;
322  }

◆ getItems()

getItems ( )

Return creditmemo items

Returns
\Magento\Sales\Api\Data\CreditmemoItemInterface[]

Implements CreditmemoInterface.

Definition at line 621 of file Creditmemo.php.

◆ getItemsCollection()

getItemsCollection ( )
Returns
mixed

Definition at line 268 of file Creditmemo.php.

269  {
270  $collection = $this->_cmItemCollectionFactory->create()->setCreditmemoFilter($this->getId());
271 
272  if ($this->getId()) {
273  foreach ($collection as $item) {
274  $item->setCreditmemo($this);
275  }
276  }
277  return $collection;
278  }

◆ getOrder()

getOrder ( )

Retrieve the order the creditmemo for created for

Returns
\Magento\Sales\Model\Order

Definition at line 227 of file Creditmemo.php.

228  {
229  if (!$this->_order instanceof \Magento\Sales\Model\Order) {
230  $this->_order = $this->_orderFactory->create()->load($this->getOrderId());
231  }
232  return $this->_order->setHistoryEntityName($this->entityType);
233  }

◆ getOrderCurrencyCode()

getOrderCurrencyCode ( )

Returns order_currency_code

Returns
string

Implements CreditmemoInterface.

Definition at line 983 of file Creditmemo.php.

◆ getOrderId()

getOrderId ( )

Returns order_id

Returns
int

Implements CreditmemoInterface.

Definition at line 993 of file Creditmemo.php.

◆ getShippingAddress()

getShippingAddress ( )

Retrieve shipping address

Returns
Address

Definition at line 260 of file Creditmemo.php.

261  {
262  return $this->getOrder()->getShippingAddress();
263  }

◆ getShippingAddressId()

getShippingAddressId ( )

Returns shipping_address_id

Returns
int

Implements CreditmemoInterface.

Definition at line 1003 of file Creditmemo.php.

◆ getShippingAmount()

getShippingAmount ( )

Returns shipping_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 1013 of file Creditmemo.php.

◆ getShippingDiscountTaxCompensationAmount()

getShippingDiscountTaxCompensationAmount ( )

Returns shipping_discount_tax_compensation_amount

Returns
float|null

Implements CreditmemoInterface.

Definition at line 1023 of file Creditmemo.php.

◆ getShippingInclTax()

getShippingInclTax ( )

Returns shipping_incl_tax

Returns
float

Implements CreditmemoInterface.

Definition at line 1033 of file Creditmemo.php.

◆ getShippingTaxAmount()

getShippingTaxAmount ( )

Returns shipping_tax_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 1043 of file Creditmemo.php.

◆ getState()

getState ( )

Returns state

Returns
int

Implements CreditmemoInterface.

Definition at line 1053 of file Creditmemo.php.

◆ getStateName()

getStateName (   $stateId = null)

Retrieve Creditmemo state name by state identifier

Parameters
int$stateId
Returns
\Magento\Framework\Phrase

Definition at line 451 of file Creditmemo.php.

452  {
453  if ($stateId === null) {
454  $stateId = $this->getState();
455  }
456 
457  if (static::$_states === null) {
458  static::getStates();
459  }
460  if (isset(static::$_states[$stateId])) {
461  return static::$_states[$stateId];
462  }
463  return __('Unknown State');
464  }
__()
Definition: __.php:13

◆ getStates()

static getStates ( )
static

Retrieve Creditmemo states array

Returns
array

Definition at line 433 of file Creditmemo.php.

434  {
435  if (static::$_states === null) {
436  static::$_states = [
437  self::STATE_OPEN => __('Pending'),
438  self::STATE_REFUNDED => __('Refunded'),
439  self::STATE_CANCELED => __('Canceled'),
440  ];
441  }
442  return static::$_states;
443  }
__()
Definition: __.php:13

◆ getStore()

getStore ( )

Retrieve creditmemo store instance

Returns
\Magento\Store\Model\Store

Definition at line 204 of file Creditmemo.php.

205  {
206  return $this->getOrder()->getStore();
207  }

◆ getStoreCurrencyCode()

getStoreCurrencyCode ( )

Returns store_currency_code

Returns
string

Implements CreditmemoInterface.

Definition at line 1063 of file Creditmemo.php.

◆ getStoreId()

getStoreId ( )

Returns store_id

Returns
int

Implements CreditmemoInterface.

Definition at line 1073 of file Creditmemo.php.

◆ getStoreToBaseRate()

getStoreToBaseRate ( )

Returns store_to_base_rate

Returns
float

Implements CreditmemoInterface.

Definition at line 1083 of file Creditmemo.php.

◆ getStoreToOrderRate()

getStoreToOrderRate ( )

Returns store_to_order_rate

Returns
float

Implements CreditmemoInterface.

Definition at line 1093 of file Creditmemo.php.

◆ getSubtotal()

getSubtotal ( )

Returns subtotal

Returns
float

Implements CreditmemoInterface.

Definition at line 1103 of file Creditmemo.php.

◆ getSubtotalInclTax()

getSubtotalInclTax ( )

Returns subtotal_incl_tax

Returns
float

Implements CreditmemoInterface.

Definition at line 1113 of file Creditmemo.php.

◆ getTaxAmount()

getTaxAmount ( )

Returns tax_amount

Returns
float

Implements CreditmemoInterface.

Definition at line 1123 of file Creditmemo.php.

◆ getTransactionId()

getTransactionId ( )

Returns transaction_id

Returns
string

Implements CreditmemoInterface.

Definition at line 1133 of file Creditmemo.php.

◆ getUpdatedAt()

getUpdatedAt ( )

Returns updated_at

Returns
string

Implements CreditmemoInterface.

Definition at line 1154 of file Creditmemo.php.

◆ isLast()

isLast ( )

Checking if the creditmemo is last

Returns
bool

Definition at line 520 of file Creditmemo.php.

521  {
522  $items = $this->getAllItems();
523  foreach ($items as $item) {
524  if (!$item->isLast()) {
525  return false;
526  }
527  }
528 
529  if (empty($items)) {
530  $order = $this->getOrder();
531  if ($order) {
532  foreach ($order->getItems() as $orderItem) {
533  if ($orderItem->canRefund()) {
534  return false;
535  }
536  }
537  }
538  }
539 
540  return true;
541  }
$orderItem
Definition: order.php:30
$order
Definition: order.php:55
$items

◆ isValidGrandTotal()

isValidGrandTotal ( )
Returns
bool

Definition at line 611 of file Creditmemo.php.

612  {
613  return !($this->getGrandTotal() <= 0 && !$this->getAllowZeroGrandTotal());
614  }

◆ roundPrice()

roundPrice (   $price,
  $type = 'regular',
  $negative = false 
)

Round price considering delta

Parameters
float$price
string$type
bool$negativeIndicates if we perform addition (true) or subtraction (false) of rounded value
Returns
float

Definition at line 358 of file Creditmemo.php.

359  {
360  if ($price) {
361  if (!isset($this->_calculators[$type])) {
362  $this->_calculators[$type] = $this->_calculatorFactory->create(['scope' => $this->getStore()]);
363  }
364  $price = $this->_calculators[$type]->deltaRound($price, $negative);
365  }
366  return $price;
367  }
$price
$type
Definition: item.phtml:13

◆ setAdjustment()

setAdjustment (   $adjustment)

{Sets the credit memo adjustment.

Parameters
float$adjustment
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1290 of file Creditmemo.php.

◆ setAdjustmentNegative()

setAdjustmentNegative (   $amount)
Parameters
string$amount
Returns
$this

Implements CreditmemoInterface.

Definition at line 499 of file Creditmemo.php.

500  {
501  $amount = trim($amount);
502  if (substr($amount, -1) == '%') {
503  $amount = (double)substr($amount, 0, -1);
504  $amount = $this->getOrder()->getGrandTotal() * $amount / 100;
505  }
506 
507  $amount = $this->priceCurrency->round($amount);
508  $this->setData('base_adjustment_negative', $amount);
509 
510  $amount = $this->priceCurrency->round($amount * $this->getOrder()->getBaseToOrderRate());
511  $this->setData('adjustment_negative', $amount);
512  return $this;
513  }
$amount
Definition: order.php:14

◆ setAdjustmentPositive()

setAdjustmentPositive (   $amount)
Parameters
string$amount
Returns
$this

Implements CreditmemoInterface.

Definition at line 479 of file Creditmemo.php.

480  {
481  $amount = trim($amount);
482  if (substr($amount, -1) == '%') {
483  $amount = (double)substr($amount, 0, -1);
484  $amount = $this->getOrder()->getGrandTotal() * $amount / 100;
485  }
486 
487  $amount = $this->priceCurrency->round($amount);
488  $this->setData('base_adjustment_positive', $amount);
489 
490  $amount = $this->priceCurrency->round($amount * $this->getOrder()->getBaseToOrderRate());
491  $this->setData('adjustment_positive', $amount);
492  return $this;
493  }
$amount
Definition: order.php:14

◆ setBaseAdjustment()

setBaseAdjustment (   $baseAdjustment)

{Sets the credit memo base adjustment.

Parameters
float$baseAdjustment
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1258 of file Creditmemo.php.

◆ setBaseAdjustmentNegative()

setBaseAdjustmentNegative (   $baseAdjustmentNegative)

Set base_adjustment_negative

Parameters
float$baseAdjustmentNegative
Returns
$this

Implements CreditmemoInterface.

Definition at line 724 of file Creditmemo.php.

◆ setBaseAdjustmentPositive()

setBaseAdjustmentPositive (   $baseAdjustmentPositive)

Set base_adjustment_positive

Parameters
float$baseAdjustmentPositive
Returns
$this

Implements CreditmemoInterface.

Definition at line 745 of file Creditmemo.php.

◆ setBaseCurrencyCode()

setBaseCurrencyCode (   $code)

{Sets the credit memo base currency code.

Parameters
string$code
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1402 of file Creditmemo.php.

◆ setBaseDiscountAmount()

setBaseDiscountAmount (   $amount)

{Sets the credit memo base discount amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1194 of file Creditmemo.php.

◆ setBaseDiscountTaxCompensationAmount()

setBaseDiscountTaxCompensationAmount (   $amount)

{Sets the credit memo base discount tax compensation amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1442 of file Creditmemo.php.

◆ setBaseGrandTotal()

setBaseGrandTotal (   $amount)

{Sets the credit memo base grand total.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1298 of file Creditmemo.php.

◆ setBaseShippingAmount()

setBaseShippingAmount (   $amount)

{Sets the credit memo base shipping amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1234 of file Creditmemo.php.

◆ setBaseShippingDiscountTaxCompensationAmnt()

setBaseShippingDiscountTaxCompensationAmnt (   $amnt)

{Sets the credit memo base shipping discount tax compensation amount.

Parameters
float$amnt
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1458 of file Creditmemo.php.

◆ setBaseShippingInclTax()

setBaseShippingInclTax (   $amount)

{Sets the credit memo base shipping including tax.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1474 of file Creditmemo.php.

◆ setBaseShippingTaxAmount()

setBaseShippingTaxAmount (   $amount)

{Sets the credit memo base shipping tax amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1178 of file Creditmemo.php.

◆ setBaseSubtotal()

setBaseSubtotal (   $amount)

{Sets the credit memo base subtotal.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1266 of file Creditmemo.php.

◆ setBaseSubtotalInclTax()

setBaseSubtotalInclTax (   $amount)

{Sets the credit memo base subtotal including tax.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1218 of file Creditmemo.php.

◆ setBaseTaxAmount()

setBaseTaxAmount (   $amount)

{Sets the credit memo base tax amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1306 of file Creditmemo.php.

◆ setBaseToGlobalRate()

setBaseToGlobalRate (   $rate)

{Sets the credit memo base-to-global rate.

Parameters
float$rate
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1250 of file Creditmemo.php.

◆ setBaseToOrderRate()

setBaseToOrderRate (   $rate)

{Sets the credit memo base-to-order rate.

Parameters
float$rate
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1202 of file Creditmemo.php.

◆ setBillingAddressId()

setBillingAddressId (   $id)

{Sets the credit memo billing address ID.

Parameters
int$id
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1370 of file Creditmemo.php.

◆ setComments()

setComments (   $comments)

{Sets credit memo comments.

Parameters
}

Implements CreditmemoInterface.

Definition at line 1162 of file Creditmemo.php.

◆ setCreatedAt()

setCreatedAt (   $createdAt)

{Sets the credit memo created-at timestamp.

Parameters
string$createdAttimestamp
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 903 of file Creditmemo.php.

◆ setCreditmemoStatus()

setCreditmemoStatus (   $creditmemoStatus)

{Sets the credit memo status.

Parameters
int$creditmemoStatus
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1346 of file Creditmemo.php.

◆ setDiscountAmount()

setDiscountAmount (   $amount)

{Sets the credit memo discount amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1274 of file Creditmemo.php.

◆ setDiscountDescription()

setDiscountDescription (   $description)

{Sets the credit memo discount description.

Parameters
string$description
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1482 of file Creditmemo.php.

◆ setDiscountTaxCompensationAmount()

setDiscountTaxCompensationAmount (   $amount)

{Sets the credit memo discount tax compensation amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1434 of file Creditmemo.php.

◆ setEmailSent()

setEmailSent (   $emailSent)

{Sets the credit memo email sent flag value.

Parameters
int$emailSent
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1338 of file Creditmemo.php.

◆ setExtensionAttributes()

setExtensionAttributes ( \Magento\Sales\Api\Data\CreditmemoExtensionInterface  $extensionAttributes)

{}

Parameters
\Magento\Sales\Api\Data\CreditmemoExtensionInterface$extensionAttributes
Returns
$this

Definition at line 1503 of file Creditmemo.php.

1504  {
1506  }
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)

◆ setGlobalCurrencyCode()

setGlobalCurrencyCode (   $code)

{Sets the credit memo global currency code.

Parameters
string$code
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1410 of file Creditmemo.php.

◆ setGrandTotal()

setGrandTotal (   $amount)

{Sets the credit memo grand total.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1210 of file Creditmemo.php.

◆ setIncrementId()

setIncrementId (   $id)

{Sets the credit memo increment ID.

Parameters
string$id
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1418 of file Creditmemo.php.

◆ setInvoice()

setInvoice ( Invoice  $invoice)

Sets invoice

Parameters
Invoice$invoice
Returns
$this

Definition at line 402 of file Creditmemo.php.

403  {
404  $this->setData('invoice', $invoice);
405  return $this;
406  }
$invoice

◆ setInvoiceId()

setInvoiceId (   $id)

{Sets the credit memo invoice ID.

Parameters
int$id
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1378 of file Creditmemo.php.

◆ setItems()

setItems (   $items)

{Sets credit memo items.

Parameters
}

Implements CreditmemoInterface.

Definition at line 663 of file Creditmemo.php.

◆ setOrder()

setOrder ( \Magento\Sales\Model\Order  $order)

Declare order for creditmemo

Parameters
\Magento\Sales\Model\Order$order
Returns
$this

Definition at line 215 of file Creditmemo.php.

216  {
217  $this->_order = $order;
218  $this->setOrderId($order->getId())->setStoreId($order->getStoreId());
219  return $this;
220  }
$order
Definition: order.php:55

◆ setOrderCurrencyCode()

setOrderCurrencyCode (   $code)

{Sets the credit memo order currency code.

Parameters
string$code
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1394 of file Creditmemo.php.

◆ setOrderId()

setOrderId (   $id)

{Sets the credit memo order ID.

Parameters
int$id
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1330 of file Creditmemo.php.

◆ setShippingAddressId()

setShippingAddressId (   $id)

{Sets the credit memo shipping address ID.

Parameters
int$id
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1362 of file Creditmemo.php.

◆ setShippingAmount()

setShippingAmount (   $amount)
Parameters
float$amount
Returns
$this

Implements CreditmemoInterface.

Definition at line 470 of file Creditmemo.php.

◆ setShippingDiscountTaxCompensationAmount()

setShippingDiscountTaxCompensationAmount (   $amount)

{Sets the credit memo shipping discount tax compensation amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1450 of file Creditmemo.php.

◆ setShippingInclTax()

setShippingInclTax (   $amount)

{Sets the credit memo shipping including tax.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1466 of file Creditmemo.php.

◆ setShippingTaxAmount()

setShippingTaxAmount (   $amount)

{Sets the credit memo shipping tax amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1314 of file Creditmemo.php.

◆ setState()

setState (   $state)

{Sets the credit memo state.

Parameters
int$state
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1354 of file Creditmemo.php.

◆ setStoreCurrencyCode()

setStoreCurrencyCode (   $code)

{Sets the credit memo store currency code.

Parameters
string$code
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1386 of file Creditmemo.php.

◆ setStoreId()

setStoreId (   $id)

{Sets the credit memo store ID.

Parameters
int$id
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1170 of file Creditmemo.php.

◆ setStoreToBaseRate()

setStoreToBaseRate (   $rate)

{Sets the credit memo store-to-base rate.

Parameters
float$rate
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1242 of file Creditmemo.php.

◆ setStoreToOrderRate()

setStoreToOrderRate (   $rate)

{Sets the credit memo store-to-order rate.

Parameters
float$rate
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1186 of file Creditmemo.php.

◆ setSubtotal()

setSubtotal (   $amount)

{Sets the credit memo subtotal.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1282 of file Creditmemo.php.

◆ setSubtotalInclTax()

setSubtotalInclTax (   $amount)

{Sets the credit memo subtotal including tax.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1226 of file Creditmemo.php.

◆ setTaxAmount()

setTaxAmount (   $amount)

{Sets the credit memo tax amount.

Parameters
float$amount
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1322 of file Creditmemo.php.

◆ setTransactionId()

setTransactionId (   $transactionId)

Sets the credit memo transaction ID.

Parameters
string$transactionId
Returns
$this

Implements CreditmemoInterface.

Definition at line 1144 of file Creditmemo.php.

◆ setUpdatedAt()

setUpdatedAt (   $timestamp)

{Sets the credit memo updated-at timestamp.

Parameters
string$timestamp
Returns
$this
}

Implements CreditmemoInterface.

Definition at line 1426 of file Creditmemo.php.

Field Documentation

◆ $_calculatorFactory

$_calculatorFactory
protected

Definition at line 95 of file Creditmemo.php.

◆ $_calculators

$_calculators = []
protected

Definition at line 65 of file Creditmemo.php.

◆ $_cmItemCollectionFactory

$_cmItemCollectionFactory
protected

Definition at line 90 of file Creditmemo.php.

◆ $_commentCollectionFactory

$_commentCollectionFactory
protected

Definition at line 110 of file Creditmemo.php.

◆ $_commentFactory

$_commentFactory
protected

Definition at line 105 of file Creditmemo.php.

◆ $_creditmemoConfig

$_creditmemoConfig
protected

Definition at line 80 of file Creditmemo.php.

◆ $_eventObject

$_eventObject = 'creditmemo'
protected

Definition at line 75 of file Creditmemo.php.

◆ $_eventPrefix

$_eventPrefix = 'sales_order_creditmemo'
protected

Definition at line 70 of file Creditmemo.php.

◆ $_order

$_order
protected

Definition at line 58 of file Creditmemo.php.

◆ $_orderFactory

$_orderFactory
protected

Definition at line 85 of file Creditmemo.php.

◆ $_states

$_states
staticprotected

Definition at line 53 of file Creditmemo.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 100 of file Creditmemo.php.

◆ $entityType

$entityType = 'creditmemo'
protected

Definition at line 48 of file Creditmemo.php.

◆ $priceCurrency

$priceCurrency
protected

Definition at line 115 of file Creditmemo.php.

◆ REPORT_DATE_TYPE_ORDER_CREATED

const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'

Definition at line 39 of file Creditmemo.php.

◆ REPORT_DATE_TYPE_REFUND_CREATED

const REPORT_DATE_TYPE_REFUND_CREATED = 'refund_created'

Definition at line 41 of file Creditmemo.php.

◆ STATE_CANCELED

const STATE_CANCELED = 3

Definition at line 37 of file Creditmemo.php.

◆ STATE_OPEN

const STATE_OPEN = 1

Definition at line 33 of file Creditmemo.php.

◆ STATE_REFUNDED

const STATE_REFUNDED = 2

Definition at line 35 of file Creditmemo.php.


The documentation for this class was generated from the following file: