public function cancelAction() { $idProformaInvoice = $this->getRequest()->getParam("id", ""); $proformaInvoice = ProformaInvoiceQuery::create()->findByPKOrThrow($idProformaInvoice, $this->i18n->_("The Proforma Invoice with id {$idProformaInvoice} does not exist.")); $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $idProformaInvoice)->find(); $canceledProformaInvoiceEntries = new ProformaInvoiceEntryCollection(); $proformaInvoice->setCanceled(ProformaInvoice::$Cancelled["Yes"]); while ($proformaInvoiceEntries->valid()) { $proformaInvoiceEntry = $proformaInvoiceEntries->read(); $proformaInvoiceEntry->setStatus(ProformaInvoiceEntry::$Status["Canceled"]); $canceledProformaInvoiceEntries->append($proformaInvoiceEntry); } $sapConnectionClient = new SAPConnectorClient(); $result = $sapConnectionClient->purchaseQuotation($proformaInvoice, $canceledProformaInvoiceEntries); if ($result->cancelPurchaseQuotationResult->code == 200) { $this->getProformaInvoiceCatalog()->beginTransaction(); $this->cancelPaymentsByIdProformaInvoice($idProformaInvoice); $this->getProformaInvoiceCatalog()->commit(); $this->setFlash('ok', $this->i18n->_("The Proforma Invoice with id {$result->cancelPurchaseQuotationResult->id} was canceled.")); } else { $this->setFlash('error', $result->cancelPurchaseQuotationResult->code . " - " . $result->cancelPurchaseQuotationResult->message); } $this->newLogForDelete($proformaInvoice); $this->_redirect('proforma-invoice/list'); }
/** * @param ProformaInvoice $proformaInvoice * @param ProformaInvoiceEntryCollection $proformaInvoiceEntries * @return stdClass * @author Erick Guevara Mart�nez */ public function purchaseQuotation(ProformaInvoice $proformaInvoice, ProformaInvoiceEntryCollection $proformaInvoiceEntries) { $parameters["purchaseQuotationSachi"] = $proformaInvoice->toSAPArray(); $parameters["purchaseQuotationSachi"]["Lines"] = $proformaInvoiceEntries->toSAPArray(); $this->createLogrequest($parameters); return !$proformaInvoice->isCanceled() ? $this->soapClient->purchaseQuotation($parameters) : $this->soapClient->cancelPurchaseQuotation($parameters); }