Exemplo n.º 1
0
 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"];
 }
Exemplo n.º 2
0
 public static function getInstance()
 {
     $logFile = QCConfig::getInstance()->get('logs')[self::$logFileKey];
     $logLevel = self::getMonologLevel(QCConfig::getInstance()->get('logs')[self::$logLevel]);
     if (self::$qcLogger) {
         return self::$qcLogger;
     } else {
         self::$qcLogger = new Logger(QCConfig::getInstance()->get('logs')[self::$loggerNamespace]);
         $handler = new StreamHandler($logFile, $logLevel);
         $handler->setFormatter(new PrintRLineFormatter());
         //$handler->setFormatter(new JsonFormatter());
         self::$qcLogger->pushHandler($handler);
     }
     return self::$qcLogger;
 }
Exemplo n.º 3
0
 public static function transform($dbResultSetRow)
 {
     $dwShippingLine = new DwShippingLine();
     $shippingProductId = QCConfig::getInstance()->get('reports')[QCConfigKey::_REVENUE_REPORT_SHIPMENT_GTIN_CONFIG_KEY];
     $dwShippingLine->setProductId($shippingProductId);
     $dwShippingLine->setNetPrice($dbResultSetRow['net_price']);
     $dwShippingLine->setTax($dbResultSetRow['tax']);
     $dwShippingLine->setGrossPrice($dbResultSetRow['gross_price']);
     $dwShippingLine->setBasePrice($dbResultSetRow['base_price']);
     $dwShippingLine->setPromoNetPrice($dbResultSetRow['promo_net_price']);
     $dwShippingLine->setPromoTax($dbResultSetRow['promo_tax']);
     $dwShippingLine->setPromoGrossPrice($dbResultSetRow['promo_gross_price']);
     $dwShippingLine->setPromoBasePrice($dbResultSetRow['promo_base_price']);
     $dwShippingLine->setPromotionId($dbResultSetRow['promotion_id']);
     return $dwShippingLine;
 }
Exemplo n.º 4
0
 /**
  * @param string $reportDateStr
  */
 public static function evalReportDate($orderDateStr)
 {
     if (!$orderDateStr || empty($orderDateStr)) {
         return null;
     }
     $reportCutoffHour = QCConfig::getInstance()->get('reports')[QCConfigKey::_REVENUE_REPORT_CUTOFF_HOUR_CONFIG_KEY];
     $dateFormat = QCConfig::getInstance()->get('reports')[QCConfigKey::_REVENUE_DATEFORMAT_CONFIG_KEY];
     $dateArray = date_parse_from_format($dateFormat, $orderDateStr);
     if ($dateArray['hour'] < $reportCutoffHour) {
         $reportDay = $dateArray['day'] - 1;
     } else {
         $reportDay = $dateArray['day'];
     }
     $reportDate = $dateArray['year'] . '-' . $dateArray['month'] . '-' . $reportDay;
     return $reportDate;
 }
Exemplo n.º 5
0
 private static function getReportFileNameFromDate($reportDate)
 {
     $qcConfig = QCConfig::getInstance()->get('reports');
     $reportFileName = $qcConfig[QCConfigKey::_REVENUE_REPORT_FOLDER] . "/" . $reportDate . "*" . $qcConfig[QCConfigKey::_REVENUE_REPORT_FILENAME_INFIX] . "*." . $qcConfig[QCConfigKey::_REVENUE_REPORT_FILENAME_EXT];
     QCLogger::getInstance()->debug("Computed reportsFilename using the input reportDate is " . $reportFileName);
     $reportFile = glob($reportFileName);
     if (count($reportFile) == 0) {
         QCLogger::getInstance()->debug("No files found having name with the report date: " . $reportDate);
         throw new Exception("No files found having name with the report date: " . $reportDate);
     }
     if (count($reportFile) > 1) {
         QCLogger::getInstance()->debug("Multiple filenames found having filename with reportDate " . $reportDate);
         QCLogger::getInstance()->debug("Filenames found are: " . print_r($reportFile));
         throw new Exception("Invalid arguments - multiple files found with name having reportDate " . $reportDate);
     }
     return $reportFile[0];
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 public function __construct()
 {
     $this->logger = QCLogger::getInstance();
     $this->config = QCConfig::getInstance();
     $this->setupMailClient();
 }
Exemplo n.º 8
0
 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];
 }
Exemplo n.º 9
0
 public function __construct()
 {
     $this->config = QCConfig::getInstance();
     $this->logger = QCLogger::getInstance();
     $this->logger->info('Constructing meedoo db connection object');
 }
Exemplo n.º 10
0
 public static function isGtinShippingItem($gtin)
 {
     $qcConfig = QCConfig::getInstance()->get('reports');
     $csvOfShipGtins = $qcConfig[QCConfigKey::_REVENUE_REPORT_SHIPMENT_GTINS_CONFIG_KEY];
     return StringUtils::indexOf($csvOfShipGtins, StringUtils::stripStart($gtin, '0'));
 }