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"]; }
public function setDbConfig() { $ordersConfig = $this->config->get('ordersdb'); $this->dbType = $ordersConfig[QCConfigKey::_ORDERS_DB_TYPE_CONFIG_KEY]; $this->dbName = $ordersConfig[QCConfigKey::_ORDERS_DB_NAME_CONFIG_KEY]; $this->dbServer = $ordersConfig[QCConfigKey::_ORDERS_DB_SERVER_CONFIG_KEY]; $this->dbCharset = $ordersConfig[QCConfigKey::_ORDERS_DB_CHARSET_CONFIG_KEY]; $this->dbPort = $ordersConfig[QCConfigKey::_ORDERS_DB_PORT_CONFIG_KEY]; //all cred are stored in a separate cred file $credConfig = QCConfig::getCredConfig(); $ckCredConfig = $credConfig->get(QCConfigKey::_CK_CREDENTIALS_CONFIG_SECTION); $this->dbUsername = $ckCredConfig[QCConfigKey::_ORDERS_DB_USERNAME_CONFIG_KEY]; $this->dbPassword = $ckCredConfig[QCConfigKey::_ORDERS_DB_PASSWORD_CONFIG_KEY]; }
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; }
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; }
/** * @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; }
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]; }
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; }
private function setupMailClient() { $aws = $this->config->get('aws'); $credConfig = QCConfig::getCredConfig(); if (!$credConfig) { throw new Exception("Missing AWS credentials file"); } $this->mailClient = new PHPMailer(); $this->mailClient->isSMTP(); $this->mailClient->SMTPAuth = true; $this->debugSendEmail = $this->config->get('logs')[$this->debugSendEmailConfigKey]; if ($this->debugSendEmail) { $this->mailClient->SMTPDebug = 2; } $this->mailClient->SMTPSecure = 'tls'; $this->mailClient->Host = $aws['cklein.qc.aws.ses.host']; $this->mailClient->Port = $aws['cklein.qc.aws.ses.port']; $this->mailClient->setFrom("*****@*****.**"); $this->mailClient->FromName = "Operations SP-eCommerce"; $profile = $aws['cklein.qc.aws.ses.profile']; $this->mailClient->Username = $credConfig->get($profile)['aws_access_key_id']; $this->mailClient->Password = $credConfig->get($profile)['aws_secret_access_key']; }
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]; }
public function __construct() { $this->config = QCConfig::getInstance(); $this->logger = QCLogger::getInstance(); $this->logger->info('Constructing meedoo db connection object'); }
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')); }
public function __construct() { $this->logger = QCLogger::getInstance(); $this->config = QCConfig::getInstance(); }