private function _checkOperation() { $data = $this->_repoBasic->getEntityByPk(Transaction::ENTITY_NAME, [Transaction::ATTR_OPERATION_ID => $this->operationId]); $pvAccounted = isset($data[Transaction::ATTR_VALUE]) ? $data[Transaction::ATTR_VALUE] : null; $this->assertEquals(self::DATA_PV_TOTAL, $pvAccounted); $this->_logger->debug("Total '{$pvAccounted}' PV is accounted for the order #{$this->orderId}."); }
/** * @param AggWarehouse $data * @return null|AggWarehouse */ public function create($data) { $result = null; $def = $this->_manTrans->begin(); try { $tbl = Cfg::ENTITY_MAGE_CATALOGINVENTORY_STOCK; $stockId = $data->getId(); if ($stockId) { /* lookup for catalog inventory stock by ID */ $stockData = $this->_repoGeneric->getEntityByPk($tbl, [Cfg::E_CATINV_STOCK_A_STOCK_ID => $stockId]); if (!$stockData) { /* create top level object (catalog inventory stock) */ $bind = [Cfg::E_CATINV_STOCK_A_WEBSITE_ID => $data->getWebsiteId(), Cfg::E_CATINV_STOCK_A_STOCK_NAME => $data->getCode()]; $stockId = $this->_repoGeneric->addEntity($tbl, $bind); } } else { /* create top level object (catalog inventory stock) */ $bind = [Cfg::E_CATINV_STOCK_A_WEBSITE_ID => $data->getWebsiteId(), Cfg::E_CATINV_STOCK_A_STOCK_NAME => $data->getCode()]; $stockId = $this->_repoGeneric->addEntity($tbl, $bind); } /* then create next level object (warehouse) */ $tbl = EntityWarehouse::ENTITY_NAME; $bind = [EntityWarehouse::ATTR_STOCK_REF => $stockId, EntityWarehouse::ATTR_CODE => $data->getCode(), EntityWarehouse::ATTR_CURRENCY => $data->getCurrency(), EntityWarehouse::ATTR_COUNTRY_CODE => $data->getCountryCode(), EntityWarehouse::ATTR_NOTE => $data->getNote()]; $this->_repoGeneric->addEntity($tbl, $bind); /* commit changes and compose result data object */ $this->_manTrans->commit($def); $result = $data; $result->setId($stockId); } finally { $this->_manTrans->end($def); } return $result; }
private function _calcQualification() { $req = new GlobalSalesCalcQualificationRequest(); $req->setGvMaxLevels(2); $resp = $this->_callGlobalSalesCalc->qualification($req); $this->assertTrue($resp->isSucceed()); $calcId = $resp->getCalcId(); /* validate calculation state */ $data = $this->repoBasic->getEntityByPk(Calculation::ENTITY_NAME, [Calculation::ATTR_ID => $calcId]); $this->assertEquals(Cfg::CALC_STATE_COMPLETE, $data[Calculation::ATTR_STATE]); return $calcId; }
/** @inheritdoc */ public function getById($id) { if (is_array($id)) { /* probably this is complex PK */ $pk = $id; } else { $pk = [$this->_idFieldName => $id]; } $result = $this->_repoGeneric->getEntityByPk($this->_entityName, $pk); if ($result) { $result = $this->_createEntityInstance($result); } return $result; }
private function _calcValueTv($nextPeriodBegin, $expectedBegin, $expectedEnd) { /* perform operation by the first date of the next period */ $datePerformed = $this->_toolPeriod->getTimestampTo($nextPeriodBegin); $request = new BonusCalcTvCompressionRequest(); $request->setDatePerformed($datePerformed); $response = $this->_callCalc->valueTv($request); $this->assertTrue($response->isSucceed()); $periodId = $response->getPeriodId(); $calcId = $response->getCalcId(); /* validate period */ $this->assertNotNull($periodId); $data = $this->_repoBasic->getEntityByPk(Period::ENTITY_NAME, [Period::ATTR_ID => $periodId]); $this->assertEquals($expectedBegin, $data[Period::ATTR_DSTAMP_BEGIN]); $this->assertEquals($expectedEnd, $data[Period::ATTR_DSTAMP_END]); /* validate calculation */ $this->assertNotNull($calcId); $data = $this->_repoBasic->getEntityByPk(Calculation::ENTITY_NAME, [Calculation::ATTR_ID => $calcId]); $this->assertEquals(Cfg::CALC_STATE_COMPLETE, $data[Calculation::ATTR_STATE]); }
public function getSaleOrderCustomerId($saleId) { $data = $this->_repoGeneric->getEntityByPk(Cfg::ENTITY_MAGE_SALES_ORDER, [Cfg::E_COMMON_A_ENTITY_ID => $saleId], [Cfg::E_SALE_ORDER_A_CUSTOMER_ID]); $result = $data[Cfg::E_SALE_ORDER_A_CUSTOMER_ID]; return $result; }