Exemplo n.º 1
0
 /**
  * Run invoice mapper test
  *
  * @return void
  */
 public function testInvoke()
 {
     $this->invoiceMock->expects($this->once())->method('getData')->will($this->returnValue(['field-1' => 'value-1']));
     $this->invoiceMock->expects($this->once())->method('getAllItems')->will($this->returnValue([$this->invoiceItemMock]));
     $this->invoiceBuilderMock->expects($this->once())->method('populateWithArray')->with($this->equalTo(['field-1' => 'value-1']))->will($this->returnSelf());
     $this->invoiceItemMapperMock->expects($this->once())->method('extractDto')->with($this->equalTo($this->invoiceItemMock))->will($this->returnValue('item-1'));
     $this->invoiceBuilderMock->expects($this->once())->method('setItems')->with($this->equalTo(['item-1']))->will($this->returnSelf());
     $this->invoiceBuilderMock->expects($this->once())->method('create')->will($this->returnValue('data-object-with-invoice'));
     $this->assertEquals('data-object-with-invoice', $this->invoiceMapper->extractDto($this->invoiceMock));
 }
Exemplo n.º 2
0
 /**
  * 
  * @param string $id
  * @param string $type
  * @return \ifirma\SendResult
  */
 private function _sendInvoice($id, $type)
 {
     $invoice = InvoiceBuilder::factory($id, $type);
     if ($invoice === null) {
         return SendResult::makeInvalidResponse(SendResult::MESSAGE_INVALID_USE);
     }
     $sendResponse = $invoice->send();
     if (!$sendResponse->isOk()) {
         return SendResult::makeInvalidResponse($sendResponse->getMessage() === null ? SendResult::MESSAGE_UNABLE_TO_SEND_INVOICE : $sendResponse->getMessage());
     }
     $responseContent = $sendResponse->getContent();
     $invoiceMap = $this->_createAndSaveInvoiceMapObject($responseContent[Response::KEY_INVOICE_ID], $id, $this->_getInvoiceMapType($type));
     if ($invoiceMap === null) {
         return SendResult::makeInvalidResponse(SendResult::MESSAGE_SEND_OK_UNABLE_TO_SAVE);
     }
     $newInvoiceObj = $invoice::get($responseContent[Response::KEY_INVOICE_ID]);
     $invoiceMap->updateInvoiceNumber(Invoice::filterNumber($newInvoiceObj->{InvoiceResponse::KEY_PELNY_NUMER}));
     $this->_comparePricesOnInvoices($newInvoiceObj, $id);
     return SendResult::makeValidResponse($sendResponse->getMessage() === null ? SendResult::MESSAGE_INVOICE_SUCCESSFULLY_SEND : $sendResponse->getMessage());
 }
Exemplo n.º 3
0
 /**
  * @param \Magento\Sales\Model\Order\Invoice $object
  * @return \Magento\Framework\Service\Data\AbstractExtensibleObject
  */
 public function extractDto(\Magento\Sales\Model\Order\Invoice $object)
 {
     $this->invoiceBuilder->populateWithArray($object->getData());
     $this->invoiceBuilder->setItems($this->getItems($object));
     return $this->invoiceBuilder->create();
 }