/** * @beforeClass */ public static function setUpSomeSharedFixtures() { self::$logger = QCLogger::getInstance(); self::$csvRecords = Registry::getInstance()->get('csvRecords'); self::$revenueOrdersModel = Registry::getInstance()->get('revReportModel'); parent::setUpSharedFixtures(); }
/** * */ public static function setUpSharedFixtures() { // self::$logger = QCLogger::getInstance(); // self::$revenueOrdersModel = Registry::getInstance()->get('revReportModel'); $revenueReportFile = Registry::getInstance()->get('revenueReportFile'); if (!file_exists($revenueReportFile)) { throw new \Exception("Revenue Report file " . $revenueReportFile . " is not found"); } else { if (filesize($revenueReportFile) == 0) { throw new \Exception("Revenue report file " . $revenueReportFile . " is empty"); } } if (!isset(self::$logger)) { self::$logger = QCLogger::getInstance(); } self::$logger->info("BEGIN " . __METHOD__); if (!isset(self::$revenueOrdersModel)) { self::$revenueOrdersModel = Registry::getInstance()->get('revReportModel'); //if still its not set throw exception if (!isset(self::$revenueOrdersModel)) { throw new \Exception("Not bootstrapped properly; missing revReportModel"); } } self::$logger->debug("Revenue orders" . PHP_EOL . print_r(self::$revenueOrdersModel->getOrders(), true)); self::$logger->info("END " . __METHOD__); }
public function __construct($paymentRequestXml) { if (!$paymentRequestXml) { throw new Exception("Invalid request xml : " . print_r($paymentRequestXml, true)); } $this->requestXmlElement = new SimpleXMLElement($paymentRequestXml); //$this->requestXmlElement = simplexml_load_file ("/tmp/csRequest.xml"); //$this->requestXmlElement->registerXPathNamespace('cs',"https://ebctest.cybersource.com/ebctest/reports/dtd/tdr_1_9.dtd"); $this->requestXmlElement->registerXPathNamespace('cs', "https://ebc.cybersource.com/ebc/reports/dtd/tdr_1_9.dtd"); $this->logger = QCLogger::getInstance(); }
public function __construct($argv) { $this->logger = QCLogger::getInstance(); $this->config = QCConfig::getInstance(); //get revenue report filename from arg $this->revenueReportFile = RevenueReportUtils::getReportFileName($argv); $this->revenueReportDate = RevenueReportUtils::getReportDate($argv); $this->templateReportSheet = APPLICATION_ROOT_FOLDER . '/' . $this->config->get('reports')['cklein.consolidated.report.tempate.file']; $this->reportsFolder = $this->config->get("reports")["cklien.consolidated.reports.folder"]; $this->reportsFilename = $this->config->get('reports')["cklien.consolidated.reports.filename"]; $this->reportsFileExt = $this->config->get('reports')["cklien.consolidated.reports.file.ext"]; $this->reportsRecipients = $this->config->get('reports')["cklien.consolidated.reports.recipients.csv"]; }
/** * @dataProvider getOrders */ public function testOrder($revenueOrder) { $this->logger = QCLogger::getInstance(); $this->logger->info("BEGIN " . __METHOD__); $this->logger->debug("Received Revenue Order :" . print_r($revenueOrder, true)); //check if the txn is a refund and if so ignore the Cybersource validation if ($revenueOrder->isTxnARefund()) { $this->logger->debug("Transaction is a refund and ignoring the verification"); return; } $orderId = $revenueOrder->getOrderId(); $this->logger->info("Testing Order #" . $orderId); $this->logger->info("Checking if this order is present in WMS shipment"); $wmsShipmentDAO = new WmsShipmentDAO(); $wmsShipmentInfo = $wmsShipmentDAO->getShipmentInfo($orderId); $this->assertNotEmpty($wmsShipmentInfo, "Shipment for order # " . $orderId . " is not found in db "); $this->logger->info("END " . __METHOD__); }
/** * @dataProvider getOrders */ public function testOrder($revenueOrder) { $this->logger = QCLogger::getInstance(); $this->logger->info("BEGIN " . __METHOD__); $this->logger->debug("Received Revenue Order :" . print_r($revenueOrder, true)); //check if the txn is a refund and if so ignore the Cybersource validation if ($revenueOrder->isTxnARefund()) { $this->logger->debug("Transaction is a refund and ignoring the verification"); return; } $orderId = $revenueOrder->getOrderId(); $revOrderDate = date_create($revenueOrder->getOrderDate()); $revOrderDateFormatted = date_format($revOrderDate, 'Ymd'); $this->logger->info("Testing Order #" . $orderId . "with orderDate = " . $revOrderDateFormatted); $this->logger->info("Sum of all prices for this order # - present in the report = " . $revenueOrder->getSumOfLinePrice()); $this->logger->info("Checking against the payment registered in Payment Gateway"); $txnPaidAmount = Transaction::getTxnPaymentAmount($orderId, $revOrderDateFormatted); $this->assertEquals($revenueOrder->getSumOfAllRecords(), $txnPaidAmount, "Total of all records for orderId " . $orderId . " in the report is not same as the Payment done in Payment-Gateway, which is " . $txnPaidAmount); }
public static function transform($csvRecords) { if (!$csvRecords || count($csvRecords) == 0) { return null; } $logger = QCLogger::getInstance(); $logger->addInfo("BEGIN RevenueCSV2Model::transform" . PHP_EOL); $shipmentGtin = QCConfig::getInstance()->get('reports')[QCConfigKey::_REVENUE_REPORT_SHIPMENT_GTIN_CONFIG_KEY]; $revenueOrders = array(); $orderCount = 0; $revenueReportDate = null; foreach ($csvRecords as $csvRecord) { $logger->debug("CSV record " . print_r($csvRecord, true) . PHP_EOL); //Check if order model object is alredy created for the current record //if so reuse that object if (!isset($revenueOrders[$csvRecord[1]])) { $orderCount = 1; $revenueOrder = new RevenueOrder(); $revenueOrder->setOrderId($csvRecord[1]); $revenueOrder->setOrderDate($csvRecord[0]); $revenueOrders[$csvRecord[1]] = array(); $revenueOrders[$csvRecord[1]][] = $revenueOrder; } //if ($csvRecord[5] == $shipmentGtin){ if (ShipUtils::isGtinShippingItem($csvRecord[5])) { $revenueShipmentLine = new RevenueShipmentLine($csvRecord[5], $csvRecord[6], $csvRecord[7]); $revenueOrders[$csvRecord[1]][0]->addShipmentLine($revenueShipmentLine); } else { $revenueOrderLine = new RevenueOrderLine($csvRecord[5], $csvRecord[6], $csvRecord[7]); $revenueOrders[$csvRecord[1]][0]->addOrderLine($revenueOrderLine); $revenueOrders[$csvRecord[1]][0]->incrementOrderLineCount(); } //adding price //$revenueOrders[$csvRecord[1]][0]->addSumOfLinePrice($csvRecord[6]); } $logger->addDebug("Constructing RevenueReport model obj" . PHP_EOL); $revenueReportModel = new RevenueReport(); $revenueReportModel->setOrderCount($orderCount); $revenueReportModel->setOrders($revenueOrders); $logger->addDebug("Order count = " . $orderCount . PHP_EOL); return $revenueReportModel; }
static function shutdown() { $logger = QCLogger::getInstance(); if (Registry::getInstance()->isRegistered(BaseTestListener::FAILURE_TESTCASES_KEY)) { $listOfFailureTCs = Registry::getInstance()->get(BaseTestListener::FAILURE_TESTCASES_KEY); if ($listOfFailureTCs && count($listOfFailureTCs) > 0) { $logger->info("Test completed with failures...sending email of failures"); $testResultHandler = new TestResultHandler(); $testResultHandler->onFailure($listOfFailureTCs); } } if (Registry::getInstance()->isRegistered(BaseTestListener::ERR_TESTCASES_KEY)) { $listOfErrorTCs = Registry::getInstance()->get(BaseTestListener::ERR_TESTCASES_KEY); if ($listOfErrorTCs && count($listOfErrorTCs) > 0) { $logger->info("Test completed with errors...sending email of failures"); $testResultHandler = new TestResultHandler(); $testResultHandler->onError($listOfErrorTCs); } } }
public static function getReportFileName($arguments) { foreach ($arguments as $arg) { if (StringUtils::startsWith($arg, self::reportFileArgName)) { $reportFileName = StringUtils::split($arg, '=', 2)[1]; QCLogger::getInstance()->debug(__METHOD__ . " report filename found in argument = " . $reportFileName); return $reportFileName; } if (StringUtils::startsWith($arg, self::reportDateArgName)) { $reportFileName = self::getReportFileNameFromDate(StringUtils::split($arg, '=', 2)[1]); QCLogger::getInstance()->debug(__METHOD__ . " report filename constructed out of the date provided in argument = " . $reportFileName); return $reportFileName; } } //will come to this code block if there are no arguments having report file details //will construct using current date time $reportFileName = self::getReportFileNameFromDate(self::getTodaysDate()); QCLogger::getInstance()->debug(__METHOD__ . " report filename constructed using current date = " . $reportFileName); return $reportFileName; }
/** * @beforeClass */ public static function setUpSomeSharedFixtures() { self::$logger = QCLogger::getInstance(); self::$csvRecords = Registry::getInstance()->get('csvRecords'); }
private function __construct() { $this->objects = new \ArrayObject(); $this->logger = QCLogger::getInstance(); $this->logger->debug("Constructing Registry instance"); }
public function __construct() { $this->logger = QCLogger::getInstance(); }
public function __construct($revenueReportFilepath) { $this->logger = QCLogger::getInstance(); $this->csvRecords = Reader::createFromPath($revenueReportFilepath); }
/** * @dataProvider getOrders */ public function testOrder($revenueOrder) { $this->logger = QCLogger::getInstance(); $this->logger->info("BEGIN " . __METHOD__); $this->logger->debug("Received Revenue Order :" . print_r($revenueOrder, true)); //check if the txn is a refund and if so ignore the Cybersource validation if ($revenueOrder->isTxnARefund()) { $this->logger->debug("Transaction is a refund and ignoring the verification"); return; } $orderId = $revenueOrder->getOrderId(); $this->logger->info("Testing Order #" . $orderId); $this->logger->info("Sum of all prices for this order # - present in the report = " . $revenueOrder->getSumOfLinePrice()); $this->logger->info("Checking against the value in db"); $dwOrderDAO = new DwOrderDAO(); $dwOrderInfo = $dwOrderDAO->getOrderInfo($orderId); $this->assertNotNull($dwOrderInfo, "Order, with # " . $orderId . ", is not found in db"); $dwOrderLineCount = $dwOrderInfo->getOrderLineCount(); $dwPromoGrossPrice = $dwOrderInfo->getOrderPromoGrossPrice(); $dwSumOfAllOrderLineQty = $dwOrderInfo->getSumOfAllOrderLineQty(); $dwMerchantGrossPrice = $dwOrderInfo->getMerchantGrossPrice(); $dwOrderLines = $dwOrderInfo->getOrderLines(); $dwShippingLines = $dwOrderInfo->getShippingLines(); $dwSumOfOrderLineGPPostLineAdj = $dwOrderInfo->getSumOfOrderLineGPPostLineAdj(); $this->assertGreaterThan(0, $dwOrderLineCount, "Count of orderLines is not greater than 0 for orderId:" . $orderId); $this->logger->debug("dwOrderLineCount = " . $dwOrderLineCount); $this->logger->debug("dwMerchantGrossPrice = " . $dwMerchantGrossPrice); $this->logger->debug("dwPromoGrossPrice = " . $dwPromoGrossPrice); $this->logger->debug("dwSumOfOrderLineGPPostLineAdj= " . $dwSumOfOrderLineGPPostLineAdj); $this->logger->debug("dw-order-lines from db for order-id " . $orderId . " " . print_r($dwOrderLines, true)); $this->assertEquals(false, empty($dwOrderInfo), "Order, " . $orderId . ", is not found in db"); $this->assertEquals($revenueOrder->getSumOfLinePrice(), $dwOrderInfo->getOrderGrossPrice(), "Sum of prices for order " . $orderId . " in report is = " . $revenueOrder->getSumOfLinePrice() . ". It is not matching with the gross price value " . $dwOrderInfo->getOrderGrossPrice() . " found in db "); $revenueOrderLines = $revenueOrder->getOrderLines(); foreach ($revenueOrderLines as $revenueOrderLine) { $this->logger->info("Checking for orderLine : productId : " . $revenueOrderLine->getGtin()); if ($revenueOrder->isLineRepeating($revenueOrderLine->getGtin())) { $this->logger->debug("This orderLine is split "); } $revenueGtinTrimmed = ltrim($revenueOrderLine->getGtin(), '0'); $revenueQty = $revenueOrderLine->getQty(); $revenuePrice = round($revenueOrderLine->getPrice() * $revenueQty, 2, PHP_ROUND_HALF_DOWN); $this->logger->debug("Revenue data for GTIN " . $revenueGtinTrimmed . ", Qty = " . $revenueQty . ", Price = " . $revenuePrice); if (!isset($dwOrderLines[$revenueGtinTrimmed])) { $this->logger->error("Revenue record having Gtin = " . $revenueGtinTrimmed . " is not found as a order line for order " . $orderId); $this->assertEquals(true, false, "Revenue record having Gtin = " . $revenueGtinTrimmed . " is not found as a order line for order " . $orderId); } $this->assertNotEmpty($dwOrderLines[$revenueGtinTrimmed], "Order Line having GTIN - " . $revenueGtinTrimmed . " is not found in the db"); //each line adjusted by the line-promotion + order-promotion/total-order-line $dwOrderLineQty = $dwOrderLines[$revenueGtinTrimmed][0]->getQty(); //compute the order level discount to be applied to this line $dwOrderLevelAdj = round($dwOrderLines[$revenueGtinTrimmed][0]->getAdjGrossPrice() / $dwSumOfOrderLineGPPostLineAdj * $dwPromoGrossPrice, 2, PHP_ROUND_HALF_DOWN); $this->logger->debug("order level adjustment to be applied to this order-line = " . $dwOrderLevelAdj); $this->logger->debug("Order line quantity = " . $dwOrderLineQty); $this->logger->debug("Order-line adjusted GP = " . $dwOrderLines[$revenueGtinTrimmed][0]->getAdjGrossPrice()); if ($dwOrderLineQty > 1) { //check if this discount can be distributed across all quantities EVENLY without loosing a cent //find the disc per quantity rounded to 2 decimal places $dwOrderLevelAdjPerQty = round($dwOrderLevelAdj / $dwOrderLineQty, 2, PHP_ROUND_HALF_DOWN); $this->logger->debug("Per qty adjustment amount = " . $dwOrderLevelAdjPerQty); //check to see if this discPerQty * Qty equals the discountComputer for this order-line //note that all adjustment/discount values are negative value (< 0 ) $discrepancyInDiscount = round($dwOrderLevelAdjPerQty * $dwOrderLineQty, 2, PHP_ROUND_HALF_DOWN) - $dwOrderLevelAdj; $this->logger->debug("Discrepancy in discount" . $discrepancyInDiscount); if ($discrepancyInDiscount != 0) { //the order-line will be split into two records and the discrepancy should have been added one of the order-lines having quantity as 1 //this item will be repeated in Revenue report, lets check $this->assertTrue($revenueOrder->isLineRepeating($revenueOrderLine->getGtin()), 'Order line, having GTIN - ' . $revenueGtinTrimmed . ' is supposed to be split into two lines, which is not the case'); $dwOrderLineBasePrice = $dwOrderLines[$revenueGtinTrimmed][0]->getBasePrice(); $this->logger->debug("Order line base price = " . $dwOrderLineBasePrice); //split order-line promotion value proportionately $newOrderLinePromoAdj = round($dwOrderLines[$revenueGtinTrimmed][0]->getPromoGrossPrice() * $revenueQty / $dwOrderLineQty, 2, PHP_ROUND_HALF_DOWN); $this->logger->debug("Order line promo split into two = " . $newOrderLinePromoAdj); if ($revenueQty == 1) { $dwOrderLineAdjPrice = $dwOrderLineBasePrice + $newOrderLinePromoAdj + round($dwOrderLevelAdjPerQty - $discrepancyInDiscount, 2, PHP_ROUND_HALF_DOWN); } else { $dwOrderLineAdjPrice = $dwOrderLineBasePrice * ($dwOrderLineQty - 1) + $newOrderLinePromoAdj + round($dwOrderLevelAdjPerQty * ($dwOrderLineQty - 1), 2, PHP_ROUND_HALF_DOWN); } $this->assertEquals($revenuePrice, $dwOrderLineAdjPrice, "Price in revenue file for GTIN " . $revenueGtinTrimmed . " is not same as in db (" . $dwOrderLineAdjPrice . ")"); continue; } } $this->logger->debug("order level discount computed for orderline:" . $revenueGtinTrimmed . " = " . $dwOrderLevelAdj); //$dwOrderLineGPRatio = round(($dwOrderLines[$revenueGtinTrimmed][0]->getAdjGrossPrice()/$dwMerchantGrossPrice),4); //$dwOrderLineGPRatio = $dwOrderLines[$revenueGtinTrimmed][0]->getAdjGrossPrice()/$dwSumOfOrderLineGPPostLineAdj; //$dwMerchantGrossPrice; //$this->logger->debug("orderLineRatio for orderline - ".$revenueGtinTrimmed."= ".$dwOrderLineGPRatio); //$adjPriceFromDb = $dwOrderLines[$revenueGtinTrimmed][0]->getAdjGrossPrice()+$dwOrderLineGPRatio * $dwPromoGrossPrice; $dwOrderLineAdjPrice = $dwOrderLines[$revenueGtinTrimmed][0]->getAdjGrossPrice() + $dwOrderLevelAdj; $this->logger->debug("Adjusted order line (computed from db) = " . $dwOrderLineAdjPrice); $this->assertEquals($revenuePrice, $dwOrderLineAdjPrice, "Price in revenue file for GTIN " . $revenueGtinTrimmed . " is not same as in db (" . $dwOrderLineAdjPrice . ")"); //$this->assertEquals($revenuePrice, $adjPriceFromDb, "Price in revenue file for GTIN ".$revenueGtinTrimmed." is not same as in db (".$adjPriceFromDb.")"); } //test shipping line values $revenueShippingLines = $revenueOrder->getShipmentLines(); $this->logger->debug("revenueShippingLines " . print_r($revenueShippingLines, true)); foreach ($revenueShippingLines as $revenueShippingLine) { $this->logger->info("Checking shipping line : product-Id :" . $revenueShippingLine->getGtin()); $shippingGtin = ltrim($revenueShippingLine->getGtin(), '0'); $shippingPrice = $revenueShippingLine->getPrice(); $this->logger->debug("dw-order-lines from db for order-id " . $orderId . " " . print_r($dwShippingLines, true)); if (!isset($dwShippingLines[$shippingGtin])) { $this->logger->error("Revenue record having shipping Gtin = " . $shippingGtin . " is not found as a order line for order " . $orderId); $this->assertEquals(true, false, "Revenue record having Gtin = " . $shippingGtin . " is not found as a order line for order " . $orderId); } $this->assertNotEmpty($dwShippingLines[$shippingGtin], "Shipping Line having GTIN - " . $shippingGtin . " is not found in the db"); $adjShippingPriceFromDb = $dwShippingLines[$shippingGtin][0]->getAdjGrossPrice(); //+$dwPromoGrossPrice; $this->assertEquals($shippingPrice, $adjShippingPriceFromDb, "Shipping gross price (" . $shippingPrice . ") in revenue file for GTIN " . $shippingGtin . " is not same as in db (" . $adjShippingPriceFromDb . ")"); } $this->logger->info("END " . __METHOD__); }
public function __construct() { $this->logger = QCLogger::getInstance(); $this->config = QCConfig::getInstance(); $this->setupMailClient(); }
public function __construct() { $this->config = QCConfig::getInstance(); $this->logger = QCLogger::getInstance(); $this->logger->info('Constructing meedoo db connection object'); }
public function __construct() { $this->logger = QCLogger::getInstance(); $this->config = QCConfig::getInstance(); $csConfig = $this->config->get('cybersource'); $this->csQueryPath = $csConfig[CSConfigKey::ONDEMAND_QUERY_PATH]; $this->csMerchantID = $csConfig[CSConfigKey::ONDEMAND_REQ_MERCHANTID]; $this->csEndpoint = $csConfig[CSConfigKey::ONDEMAND_REQ_ENDPOINT]; $credConfig = QCConfig::getCredConfig()->get(QCConfigKey::_CK_CREDENTIALS_CONFIG_SECTION); $this->csUsername = $credConfig[CSConfigKey::ONDEMAND_REQ_USERNAME]; $this->csPassword = $credConfig[CSConfigKey::ONDEMAND_REQ_PASSWORD]; }