当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::canInvoice方法代码示例

本文整理汇总了PHP中Magento\Sales\Model\Order::canInvoice方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::canInvoice方法的具体用法?PHP Order::canInvoice怎么用?PHP Order::canInvoice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Sales\Model\Order的用法示例。


在下文中一共展示了Order::canInvoice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCanNotInvoiceWhenDidNotHaveQtyToInvoice

 public function testCanNotInvoiceWhenDidNotHaveQtyToInvoice()
 {
     $this->item->expects($this->any())
         ->method('getQtyToInvoice')
         ->willReturn(0);
     $this->item->expects($this->any())
         ->method('getLockedDoInvoice')
         ->willReturn(false);
     $this->assertFalse($this->order->canInvoice());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:10,代码来源:OrderTest.php

示例2: _createInvoice

 /**
  * @throws Exception
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _createInvoice()
 {
     $this->_adyenLogger->addAdyenNotificationCronjob('Creating invoice for order');
     if ($this->_order->canInvoice()) {
         /* We do not use this inside a transaction because order->save()
          * is always done on the end of the notification
          * and it could result in a deadlock see https://github.com/Adyen/magento/issues/334
          */
         try {
             $invoice = $this->_order->prepareInvoice();
             $invoice->getOrder()->setIsInProcess(true);
             // set transaction id so you can do a online refund from credit memo
             $invoice->setTransactionId($this->_pspReference);
             $autoCapture = $this->_isAutoCapture();
             $createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId());
             if (!$autoCapture && $createPendingInvoice) {
                 // if amount is zero create a offline invoice
                 $value = (int) $this->_value;
                 if ($value == 0) {
                     $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::CAPTURE_OFFLINE);
                 } else {
                     $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::NOT_CAPTURE);
                 }
                 $invoice->register();
             } else {
                 $invoice->register()->pay();
             }
             $invoice->save();
             $this->_adyenLogger->addAdyenNotificationCronjob('Created invoice');
         } catch (Exception $e) {
             $this->_adyenLogger->addAdyenNotificationCronjob('Error saving invoice. The error message is: ' . $e->getMessage());
             throw new Exception(sprintf('Error saving invoice. The error message is:', $e->getMessage()));
         }
         $this->_setPaymentAuthorized();
         $invoiceAutoMail = (bool) $this->_getConfigData('send_invoice_update_mail', 'adyen_abstract', $this->_order->getStoreId());
         if ($invoiceAutoMail) {
             $invoice->sendEmail();
         }
     } else {
         $this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order');
     }
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:46,代码来源:Cron.php

示例3: check

 /**
  * Check order status before save
  *
  * @param Order $order
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function check(Order $order)
 {
     if (!$order->getId()) {
         return $order;
     }
     if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
         if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
             if ($order->getState() !== Order::STATE_COMPLETE) {
                 $order->setState(Order::STATE_COMPLETE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_COMPLETE));
             }
         } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
             if ($order->getState() !== Order::STATE_CLOSED) {
                 $order->setState(Order::STATE_CLOSED)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED));
             }
         }
     }
     if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
         $order->setState(Order::STATE_PROCESSING)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:State.php

示例4: check

 /**
  * Check order status before save
  *
  * @param Order $order
  * @return $this
  */
 public function check(Order $order)
 {
     if (!$order->getId()) {
         return $order;
     }
     $userNotification = $order->hasCustomerNoteNotify() ? $order->getCustomerNoteNotify() : null;
     if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
         if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
             if ($order->getState() !== Order::STATE_COMPLETE) {
                 $order->setState(Order::STATE_COMPLETE, true, '', $userNotification, false);
             }
         } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
             if ($order->getState() !== Order::STATE_CLOSED) {
                 $order->setState(Order::STATE_CLOSED, true, '', $userNotification, false);
             }
         }
     }
     if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
         $order->setState(Order::STATE_PROCESSING, true, '', $userNotification);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:State.php

示例5: _createInvoice

 protected function _createInvoice($params)
 {
     try {
         if ($this->_order->canInvoice()) {
             $payment = $this->_order->getPayment();
             $payment->setTransactionId($params['invoice_id']);
             $payment->setCurrencyCode($params['list_currency']);
             $payment->setParentTransactionId($params['sale_id']);
             $payment->setShouldCloseParentTransaction(true);
             $payment->setIsTransactionClosed(0);
             $payment->registerCaptureNotification($params['invoice_list_amount'], true);
             $this->_order->save();
             // notify customer
             $invoice = $payment->getCreatedInvoice();
             if ($invoice && !$this->_order->getEmailSent()) {
                 $this->orderSender->send($this->_order);
                 $this->_order->addStatusHistoryComment(__('You notified customer about invoice #%1.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save();
             }
         }
     } catch (Exception $e) {
         throw new Exception(sprintf('Error Creating Invoice: "%s"', $e->getMessage()));
     }
 }
开发者ID:craigchristenson,项目名称:magento2-2checkout,代码行数:23,代码来源:Notification.php

示例6: _processInvoice

 protected function _processInvoice()
 {
     if ($this->_order->canInvoice()) {
         $invoice = $this->_order->prepareInvoice();
         switch ($this->_paymentInst->getConfigPaymentAction()) {
             case \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE:
                 $invoice->register();
                 $this->_order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, 'authorized');
                 break;
             case \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE:
                 $this->_paymentInst->setAssistCaptureResponse(true);
                 $invoice->register()->capture();
                 break;
         }
         /** @var \Magento\Framework\DB\Transaction $transaction */
         $transaction = $this->_transactionFactory->create();
         $transaction->addObject($invoice)->addObject($invoice->getOrder())->save();
         $this->_invoiceSender->send($invoice);
     } elseif ($this->_order->isCanceled()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Order canceled'));
     } else {
         throw new \Magento\Framework\Exception\LocalizedException(__('Order paid'));
     }
 }
开发者ID:vuleticd,项目名称:vuleticd_assist2,代码行数:24,代码来源:Ipn.php


注:本文中的Magento\Sales\Model\Order::canInvoice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。