/** * * @param int $invoiceMapId * @return \ifirma\SendResult */ private function _sendInvoiceBasedOnProforma($invoiceMapId) { $invoiceMap = InvoiceMap::get($invoiceMapId); if ($invoiceMap === null) { return SendResult::makeInvalidResponse(SendResult::MESSAGE_MISSING_INVOICE_PROFORMA); } $invoiceResponseObj = $this->_getInvoiceResponseObject($invoiceMap); if ($invoiceResponseObj === null) { return SendResult::makeInvalidResponse(SendResult::MESSAGE_MISSING_INVOICE_PROFORMA); } $sendInvoiceResult = $invoiceResponseObj->sendInvoiceBasedOnThisProforma(); if (!$sendInvoiceResult->isOk()) { return SendResult::makeInvalidResponse($sendInvoiceResult->getMessage() !== '' ? $sendInvoiceResult->getMessage() : SendResult::MESSAGE_UNABLE_TO_SEND_INVOICE); } $sendInvoiceResultContent = $sendInvoiceResult->getContent(); $newInvoiceId = $sendInvoiceResultContent[Response::KEY_INVOICE_ID]; $newInvoiceMapObj = $this->_createAndSaveInvoiceMapObject($newInvoiceId, $invoiceMap->{InvoiceMap::COLUMN_NAME_ORDER_ID}, InvoiceMap::INVOICE_TYPE_NORMAL); $newInvoiceObj = Invoice::get($newInvoiceId); $newInvoiceMapObj->updateInvoiceNumber(Invoice::filterNumber($newInvoiceObj->{InvoiceResponse::KEY_PELNY_NUMER})); return SendResult::makeValidResponse($sendInvoiceResult->getMessage() !== '' ? $sendInvoiceResult->getMessage() : SendResult::MESSAGE_INVOICE_SUCCESSFULLY_SEND); }
/** * * @param int $invoiceMapId * @return \ifirma\SendResult */ private function _sendInvoiceBasedOnProforma($invoiceMapId) { global $loader, $registry; $loader->model('module/invoice_map'); $invoiceMapModel = $registry->get('model_module_invoice_map'); $invoiceMap = $invoiceMapModel->get($invoiceMapId); if ($invoiceMap === null) { return SendResult::makeInvalidResponse(SendResult::MESSAGE_MISSING_INVOICE_PROFORMA); } $invoiceResponseObj = $this->_getInvoiceResponseObject($invoiceMap); if ($invoiceResponseObj === null) { return SendResult::makeInvalidResponse(SendResult::MESSAGE_MISSING_INVOICE_PROFORMA); } $sendInvoiceResult = $invoiceResponseObj->sendInvoiceBasedOnThisProforma(); if (!$sendInvoiceResult->isOk()) { return SendResult::makeInvalidResponse($sendInvoiceResult->getMessage() !== '' ? $sendInvoiceResult->getMessage() : SendResult::MESSAGE_UNABLE_TO_SEND_INVOICE); } $sendInvoiceResultContent = $sendInvoiceResult->getContent(); $newInvoiceId = $sendInvoiceResultContent[ConnectorResponse::KEY_INVOICE_ID]; $newInvoiceObj = Invoice::get($newInvoiceId); $this->_createAndSaveInvoiceMapObject($newInvoiceId, $invoiceMap[ModelModuleInvoiceMap::COLUMN_NAME_ORDER_ID], ModelModuleInvoiceMap::INVOICE_TYPE_NORMAL, Invoice::filterNumber($newInvoiceObj->{InvoiceResponse::KEY_PELNY_NUMER})); // $invoiceMapModel->updateInvoiceNumber($invoiceMap[ModelModuleInvoiceMap::COLUMN_NAME_ORDER_ID], Invoice::filterNumber($newInvoiceObj->{InvoiceResponse::KEY_PELNY_NUMER})); return SendResult::makeValidResponse($sendInvoiceResult->getMessage() !== '' ? $sendInvoiceResult->getMessage() : SendResult::MESSAGE_INVOICE_SUCCESSFULLY_SEND); }