diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/SystemLogger.php b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/SystemLogger.php
similarity index 73%
rename from Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/SystemLogger.php
rename to Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/SystemLogger.php
index 586c74f..bf34a2f 100644
--- a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/SystemLogger.php
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/SystemLogger.php
@@ -35,7 +35,7 @@ class SystemLogger
var $passed_param;
var $result_string;
- function SystemLogger()
+ function __construct()
{
// constructor definition
$this->when = '';
@@ -107,30 +107,30 @@ function metric($type,$linecount,$docno,$connectortime,$latency)
*/
function writeConfigLog($account,$license,$serviceurl,$companyCode,$environment,$client,$isAvataxEnabled,$isUPCOption,$isSaveTransaction,$isLogEnabled,$isAddressValidation)
- {
- $logging_folder = $this->createLogPath();
- $log_file_name = $logging_folder . "/Ava-Connector-Configuration-Log-" . date('d-m-Y') . ".txt";
- $log_file = fopen($log_file_name, "a") or die("Unable to open $log_file_name ");
+ {
+ $logging_folder = $this->createLogPath();
+ $log_file_name = $logging_folder . "/Ava-Connector-Configuration-Log-" . date('d-m-Y') . ".txt";
+ $log_file = fopen($log_file_name, "a") or die("Unable to open $log_file_name ");
- fprintf($log_file, "%s", "Connector Configuration : ");
- fprintf($log_file, "%s%s", "Account ID : ", $account);
- fprintf($log_file, "%s%s", " License Key : ", $license);
- fprintf($log_file, "%s%s", ",ServiceURL : ", $serviceurl);
- fprintf($log_file, "%s%s\r", ",Company Code: ", $companyCode);
- fprintf($log_file, "%s%s", "Environment : ", $environment);
- fprintf($log_file, "%s%s", ",Client : ", $client);
- fprintf($log_file, "%s%s", ",Is Avatax Enabled : ", $isAvataxEnabled);
- fprintf($log_file, "%s%s", ",Is UPC Option Enabled: ", $isUPCOption);
- fprintf($log_file, "%s%s", ",Is Save Transaction Enabled: ", $isSaveTransaction);
- fprintf($log_file, "%s%s", ",Is Log Enabled: ", $isLogEnabled);
- fprintf($log_file, "%s%s\r\n", ",Is Address Validation Enabled: ", $isAddressValidation);
- //fprintf($log_file, "%s%s\r\n", "------------", "------------");
+ fprintf($log_file, "%s", "Connector Configuration : ");
+ fprintf($log_file, "%s%s", "Account ID : ", $account);
+ fprintf($log_file, "%s%s", " License Key : ", $license);
+ fprintf($log_file, "%s%s", ",ServiceURL : ", $serviceurl);
+ fprintf($log_file, "%s%s\r", ",Company Code: ", $companyCode);
+ fprintf($log_file, "%s%s", "Environment : ", $environment);
+ fprintf($log_file, "%s%s", ",Client : ", $client);
+ fprintf($log_file, "%s%s", ",Is Avatax Enabled : ", $isAvataxEnabled);
+ fprintf($log_file, "%s%s", ",Is UPC Option Enabled: ", $isUPCOption);
+ fprintf($log_file, "%s%s", ",Is Save Transaction Enabled: ", $isSaveTransaction);
+ fprintf($log_file, "%s%s", ",Is Log Enabled: ", $isLogEnabled);
+ fprintf($log_file, "%s%s\r\n", ",Is Address Validation Enabled: ", $isAddressValidation);
+ //fprintf($log_file, "%s%s\r\n", "------------", "------------");
- fclose($log_file);
- }
+ fclose($log_file);
+ }
function serviceLog($performance_metrics)
- {
+ {
$resp = array();
foreach ($performance_metrics as $entry) {
$row = array();
@@ -140,48 +140,48 @@ function serviceLog($performance_metrics)
array_push($resp, implode(',', $row));
}
- $csv_data = implode("\r\n", $resp);
+ $csv_data = implode("\r\n", $resp);
$url = 'https://qa.cphforavatax.com/Ava_Post_C_Log';
//$url = 'https://avataxforcph.connectorsdev.avatax.com/Ava_Post_C_Log';
$ch = curl_init($url);
$options = array(
- CURLOPT_RETURNTRANSFER => true, // return web page
- CURLOPT_HEADER => false, // don't return headers
- CURLOPT_FOLLOWLOCATION => false, // follow redirects
- // CURLOPT_ENCODING => "utf-8", // handle all encodings
- CURLOPT_AUTOREFERER => true, // set referer on redirect
- CURLOPT_CONNECTTIMEOUT => 20, // timeout on connect
- CURLOPT_TIMEOUT => 20, // timeout on response
- CURLOPT_POST => 1, // i am sending post data
- CURLOPT_POSTFIELDS => $csv_data, // this are my post vars
- CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
- CURLOPT_SSL_VERIFYPEER => false, //
- CURLOPT_VERBOSE => 1
+ CURLOPT_RETURNTRANSFER => true, // return web page
+ CURLOPT_HEADER => false, // don't return headers
+ CURLOPT_FOLLOWLOCATION => false, // follow redirects
+ // CURLOPT_ENCODING => "utf-8", // handle all encodings
+ CURLOPT_AUTOREFERER => true, // set referer on redirect
+ CURLOPT_CONNECTTIMEOUT => 20, // timeout on connect
+ CURLOPT_TIMEOUT => 20, // timeout on response
+ CURLOPT_POST => 1, // i am sending post data
+ CURLOPT_POSTFIELDS => $csv_data, // this are my post vars
+ CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
+ CURLOPT_SSL_VERIFYPEER => false, //
+ CURLOPT_VERBOSE => 1
);
curl_setopt_array($ch,$options);
$data = curl_exec($ch);
$curl_errno = curl_errno($ch);
- $curl_error = curl_error($ch);
+ $curl_error = curl_error($ch);
curl_close($ch);
- return $data;
+ return $data;
//echo "
CURL Response
"; */
}
function createLogPath()
{
// If does not exist, create a folder named ava-sys-logs - under the given path
- // $curr_dir = getcwd();
+ // $curr_dir = getcwd();
// Check if a folder named ava-logs exist below CWD
//$dir_name = 'ava-logs';
- $dir_name = dirname ( __FILE__ ).'/ava-logs'; // For now this is hard-coded
- if (is_dir($dir_name)) // Checking if the sub-folder ava-logs exists under current folder
- {
+ $dir_name = dirname ( __FILE__ ).'/ava-logs'; // For now this is hard-coded
+ // Checking if the sub-folder ava-logs exists under current folder
+ if (is_dir($dir_name)) {
if ($dh = opendir($dir_name))
{
@@ -197,17 +197,15 @@ function createLogPath()
mkdir($dir_name, 0777, true);
}
- }
- else
- {
+ } else {
mkdir($dir_name, 0777, true);
}
$log_folder = $dir_name;
return $log_folder;
-
}
+
/* Writes the current system log to designated log file */
function WriteSystemLogToFile()
{
@@ -226,7 +224,6 @@ function WriteSystemLogToFile()
fprintf($log_file, "%s%s\r\n", "------------", "------------");
fclose($log_file);
-
}
function WriteSystemLogToDB()
@@ -240,12 +237,9 @@ function WriteSystemLogToDB()
$con = mysqli_connect($dbhost_name, $username, $password, $database);
// Check connection
- if (mysqli_connect_errno())
- {
+ if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- else
- {
+ } else {
; // connection successful
}
@@ -282,7 +276,7 @@ function WriteSystemLogToDB()
mysqli_query($con, $query);
// fetch the record no of last inserted record
- $rec_no = mysqli_insert_id($con);
+ $rec_no = mysqli_insert_id($con);
// close the database
mysqli_close($con);
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/addon.xml b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/addon.xml
similarity index 82%
rename from Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/addon.xml
rename to Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/addon.xml
index 6d7170e..bdab74f 100644
--- a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/addon.xml
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/addon.xml
@@ -1,23 +1,25 @@
avatax_tax_calculation
- 1.0
+ 1.1enAvalara AvaTaxAvalara AvaTax100502active
+ Avalara
+ https://www.avalara.com
+
Sign in
-
- info
- fn_avatax_tax_gen_info
-
-
-
+
+ info
+ fn_avatax_tax_gen_info
+
+ inputAccount ID generated by AvaTaxAccount ID*
@@ -43,12 +45,12 @@
- AvaTax Service
- info
- fn_avatax_tax_calculation_testconnection
+ AvaTax Service
+ info
+ fn_avatax_tax_calculation_testconnection
-
- Company Name*
+
+ Company Name*selectbox
@@ -68,8 +70,8 @@
No
-
-
+
+ Send UPC code to AvaTaxradiogroup
@@ -97,7 +99,7 @@
-
+ Enable AvaTax address validationradiogroup0
@@ -108,7 +110,7 @@
No
-
+
Enable Log
@@ -137,8 +139,11 @@
-
-
+
+
+
+
+
ALTER TABLE `?:status_descriptions` ADD status VARCHAR(1) NOT NULL;ALTER TABLE `?:status_descriptions` ADD type VARCHAR(1) NOT NULL;UPDATE `?:status_descriptions` SET status = 'A' , type = 'G' where description ='Active';
@@ -155,7 +160,6 @@
UPDATE `?:status_descriptions` SET status = 'P' , type = 'O' where description ='Processed';UPDATE `?:status_descriptions` SET status = 'R' , type = 'R' where description ='Requested';UPDATE `?:status_descriptions` SET status = 'U' , type = 'G' where description ='Used';
-
ALTER TABLE `?:orders` ADD `avatax_paytax_document_id` INT NOT NULL DEFAULT '0', ADD `avatax_paytax_transaction_id` INT NOT NULL DEFAULT '0', ADD `avatax_paytax_document_code` VARCHAR( 40 ) NOT NULL, ADD `avatax_paytax_error_message` TEXT NOT NULL;ALTER TABLE `?:status_descriptions` ADD `avatax_document_status` VARCHAR( 30 ) NOT NULL;UPDATE `?:status_descriptions` SET avatax_document_status = 'Committed' where status ='C' and type = 'O';
@@ -170,7 +174,6 @@
UPDATE `?:status_descriptions` SET avatax_document_status = 'Voided' where status ='D' and type = 'R';UPDATE `?:status_descriptions` SET avatax_document_status = 'Committed' where status ='C' and type = 'R';ALTER TABLE ?:rma_returns ADD `avatax_return_document_code` VARCHAR( 10 ) NOT NULL;
- ALTER TABLE ?:users ADD `tax_exempt_number` VARCHAR( 30 ) NOT NULL;ALTER TABLE ?:users ADD `tax_entity_usecode` CHAR( 1 ) NOT NULL;DROP TABLE IF EXISTS ?:avatax_entity_usecode;
@@ -184,7 +187,7 @@
ALTER TABLE ?:products ADD `tax_code` VARCHAR( 11 ) DEFAULT 'none';UPDATE ?:products SET `tax_code`= 'none' WHERE `tax_code` = 'none';
-
+
ALTER TABLE ?:products ADD `upc_code` VARCHAR( 20 ) DEFAULT 'none';UPDATE ?:products SET `upc_code`= 'none' WHERE `upc_code` = 'none';
@@ -193,7 +196,27 @@
ALTER TABLE ?:users ADD `tax_exempt_number` VARCHAR( 25 ) NOT NULL DEFAULT 'Tax Exempt';UPDATE ?:users SET `tax_exempt_number`= 'none' WHERE `tax_exempt_number` = 'Tax Exempt';
-
- DROP TABLE IF EXISTS ?:avatax_entity_usecode;
+
+
+
+ ALTER TABLE `?:status_descriptions` DROP COLUMN status;
+ ALTER TABLE `?:status_descriptions` DROP COLUMN type;
+
+ ALTER TABLE `?:orders` DROP COLUMN `avatax_paytax_document_id`;
+ ALTER TABLE `?:orders` DROP COLUMN `avatax_paytax_transaction_id`;
+ ALTER TABLE `?:orders` DROP COLUMN `avatax_paytax_document_code`;
+ ALTER TABLE `?:orders` DROP COLUMN `avatax_paytax_error_message`;
+
+ ALTER TABLE `?:status_descriptions` DROP COLUMN `avatax_document_status`;
+
+ ALTER TABLE ?:rma_returns DROP COLUMN `avatax_return_document_code`;
+ ALTER TABLE ?:users DROP COLUMN `tax_exempt_number`;
+ ALTER TABLE ?:users DROP COLUMN `tax_entity_usecode`;
+
+ DROP TABLE IF EXISTS ?:avatax_entity_usecode;
+
+ ALTER TABLE ?:products DROP COLUMN `tax_code`;
+ ALTER TABLE ?:products DROP COLUMN `upc_code`;
+ ALTER TABLE ?:shippings DROP COLUMN `tax_code`;
-
+
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/controllers/backend/avatax_tax_calculation.php b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/controllers/backend/avatax_tax_calculation.php
new file mode 100644
index 0000000..418e1bb
--- /dev/null
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/controllers/backend/avatax_tax_calculation.php
@@ -0,0 +1,96 @@
+format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
+ $performance_metrics[] = array($connectorstart,$msgString,$account,"","Connector Configuration",$serviceurl,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+
+ //Call serviceLog function
+ $returnServiceLog = $config_log->serviceLog($performance_metrics);
+ //$config_log->writeConfigLog($account,$license,$serviceurl,$companyCode,$environment,$client,$isAvataxEnabled,$isUPCOption,$isSaveTransaction,$isLogEnabled,$isAddressValidation);
+ exit;
+ }
+
+ if ($mode == 'create_account') {
+ $lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
+ $addon_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation';
+ $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
+ include_once($lib_path."AvaTax4PHP/avatax_create_account.php");
+ exit;
+ }
+
+ if ($mode == 'tpa') {
+ $lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
+ $addon_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation';
+ $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
+ include_once($lib_path."AvaTax4PHP/tpa.php");
+ exit;
+ }
+
+ if ($mode == 'validate_account') {
+ $lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
+ $addon_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation';
+ $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
+ include_once($lib_path."AvaTax4PHP/avatax_validate_account.php");
+ exit;
+ }
+}
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/controllers/backend/profiles_pre.php b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/controllers/backend/profiles_pre.php
similarity index 97%
rename from Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/controllers/backend/profiles_pre.php
rename to Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/controllers/backend/profiles_pre.php
index 2938a5b..6773d38 100644
--- a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/controllers/backend/profiles_pre.php
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/controllers/backend/profiles_pre.php
@@ -18,9 +18,6 @@
if (!defined('BOOTSTRAP')) { die('Access denied'); }
if ($mode == 'update') {
-
$content .= "Product Original Price *** \n";
- file_put_contents("usage_log.txt", $content, FILE_APPEND | LOCK_EX);
-
-
+ file_put_contents("usage_log.txt", $content, FILE_APPEND | LOCK_EX);
}
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/func.php b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/func.php
similarity index 55%
rename from Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/func.php
rename to Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/func.php
index d77df79..db84c17 100644
--- a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/func.php
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/app/addons/avatax_tax_calculation/func.php
@@ -15,9 +15,9 @@
/***************************************************************************
* *
* This source file was cleaned-up to meet the requirements for release *
- * done by Avalara - on 02/20/2015 *
- * File Version : *
- * Last Updated On : 05/27/2016 *
+ * done by Avalara - on 02/20/2015 *
+ * File Version : *
+ * Last Updated On : 03/02/2021 *
***************************************************************************/
@@ -36,532 +36,225 @@
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/20/2015 *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 03/02/2021 *
* Description : This function allow user to test the connection *
* between CS Cart and Avalara Admin Console. This *
* action is performed after installing the AvaTax *
* Addon from CS Cart Admin Console *
- **********************************************e*****************************/
+ ****************************************************************************/
function fn_avatax_tax_calculation_testconnection()
{
- $curPageURL = explode("?", curPageURL());
+ $curPageURL = explode("?", curPageURL());
$text = '
-
-
Click here for AvaTax Tax Profile Assistant Note: Nexus recommendations are based on the analysis of either your last 1000 transactions or your last 1 year\'s transactional data.
';
return $text;
}
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/20/2015 *
- * Description : This function displays the link to Avalara *
- * Nexus help. *
- * To be accessed from Avatax ->Setting *
- **********************************************e*****************************/
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 03/02/2021 *
+ * Description : This function displays the link to Avalara *
+ * Nexus help. *
+ * To be accessed from Avatax ->Setting *
+ ****************************************************************************/
function fn_avatax_tax_calculation_admin_nexus_link()
{
$text = '
@@ -571,19 +264,19 @@ function fn_avatax_tax_calculation_admin_nexus_link()
}
/***************************************************************************
- * *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/20/2015 *
- * Description : This function returns the Page URL via *
- * curl library. *
- * *
- **********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 03/02/2021 *
+ * Description : This function returns the Page URL via *
+ * curl library. *
+ * *
+ ****************************************************************************/
function curPageURL()
{
$pageURL = 'http';
- if (isset($_SERVER["HTTPS"])&& $_SERVER["HTTPS"] == "on") {
+ if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
@@ -593,95 +286,80 @@ function curPageURL()
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
-
}
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/20/2015 *
- * Description : This function returns the original price of *
- * product by product ID *
- * *
- **********************************************e*****************************/
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 03/02/2021 *
+ * Description : This function returns the original price of *
+ * product by product ID *
+ * *
+ ****************************************************************************/
function fn_product_real_price($product_id)
{
-
- $product_original_price = 0;
-
- $product_original_price = db_get_field("SELECT price FROM ?:product_prices WHERE product_id = ?i AND lower_limit = 1", $product_id);
-
- return $product_original_price;
+ return db_get_field("SELECT price FROM ?:product_prices WHERE product_id = ?i AND lower_limit = 1", $product_id);
}
- /***************************************************************************
- * *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/20/2015 *
- * Description : This function updates the AvaTax fields in order*
- * *
- **********************************************e*****************************/
+ /****************************************************************************
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 03/02/2021 *
+ * Description : This function updates the AvaTax fields in order*
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_update_order_with_avatax_fields($avatax_document_id, $avatax_transaction_id, $avatax_document_code, $avatax_error_message, $order_id)
{
-
db_query("UPDATE `?:orders` SET avatax_paytax_document_id = '" . (int)$avatax_document_id . "', avatax_paytax_transaction_id = '" . (int)$avatax_transaction_id . "', avatax_paytax_document_code = '" . (int)$avatax_document_code . "', avatax_paytax_error_message = '" . $avatax_error_message . "' WHERE order_id = '" . (int)$order_id . "'");
-
}
- /***************************************************************************
- * *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
- * Description : This function returns Doc Code from Return Order*
- * *
- **********************************************e*****************************/
+ /****************************************************************************
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/22/2015 *
+ * Description : This function returns Doc Code from Return Order*
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_get_return_order_doc_code($order_id)
{
- $return_order_doc_code = db_get_field("SELECT count(*) as total FROM ?:rma_returns WHERE order_id = ?i", $order_id);
-
- return $return_order_doc_code;
+ return db_get_field("SELECT count(*) as total FROM ?:rma_returns WHERE order_id = ?i", $order_id);
}
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
* Description : This function returns the ID of Return Reason *
- * *
- **********************************************e*****************************/
+ * *
+ ****************************************************************************/
function fn_return_reason($return_reason_id)
{
-
- $return_reason = "";
-
- $return_reason = db_get_field("SELECT property FROM ?:rma_property_descriptions WHERE property_id = ?i", $return_reason_id);
-
- return $return_reason;
+ return db_get_field("SELECT property FROM ?:rma_property_descriptions WHERE property_id = ?i", $return_reason_id);
}
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
* Description : This function returns the ID of Return Reason *
- * *
- **********************************************e*****************************/
+ * *
+ ****************************************************************************/
function fn_edit_return_with_avatax_doccode($avatax_return_document_code, $return_id)
{
@@ -699,33 +377,29 @@ function fn_edit_return_with_avatax_doccode($avatax_return_document_code, $retur
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
* Description : This function fetches the tax exemption details *
- * from the database table *
- **********************************************e*****************************/
-
-
+ * from the database table *
+ ****************************************************************************/
+
function fn_get_tax_exemption_details($user_id)
{
$tax_exemption_details = db_get_row("SELECT tax_exempt, tax_exempt_number, tax_entity_usecode FROM ?:users WHERE user_id = ?i", $user_id);
- if ($tax_exemption_details["tax_exempt"] == 'Y') {
- if($tax_exemption_details['tax_exempt_number'] == "")
- {
- $tax_exemption_details['tax_exempt_number'] = "Exempt";
- }
- $tax_exemption_details['tax_entity_usecode'] = "";
- }
-
+ if ($tax_exemption_details["tax_exempt"] == 'Y') {
+ if ($tax_exemption_details['tax_exempt_number'] == "") {
+ $tax_exemption_details['tax_exempt_number'] = "Exempt";
+ }
+ $tax_exemption_details['tax_entity_usecode'] = "";
+ }
if ($tax_exemption_details["tax_exempt"] == 'N') {
- if($tax_exemption_details['tax_entity_usecode'] == "-")
- {
- $tax_exemption_details['tax_entity_usecode'] = "";
- }
+ if ($tax_exemption_details['tax_entity_usecode'] == "-") {
+ $tax_exemption_details['tax_entity_usecode'] = "";
+ }
$tax_exemption_details['tax_exempt_number'] = "";
// $tax_exemption_details['tax_entity_usecode'] = "";
}
@@ -736,20 +410,17 @@ function fn_get_tax_exemption_details($user_id)
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
* Description : This function fetches the timestamp when the *
- * tax was computed for given Order ID *
- **********************************************e*****************************/
+ * tax was computed for given Order ID *
+ ****************************************************************************/
- function fn_avatax_tax_calculation_get_order_timestamp($order_id)
+function fn_avatax_tax_calculation_get_order_timestamp($order_id)
{
-
- $order_timestamp = db_get_field("SELECT timestamp FROM ?:orders WHERE order_id = ?i", $order_id);
-
- return $order_timestamp;
+ return db_get_field("SELECT timestamp FROM ?:orders WHERE order_id = ?i", $order_id);
}
#}
@@ -758,19 +429,17 @@ function fn_avatax_tax_calculation_get_order_timestamp($order_id)
/** [ORDER STATUS CHANGES FUNCTIONS] **/
#{ Region STARTS
-
- /***************************************************************************
+/****************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
- * Description : This function fetches document Status *
- **********************************************e*****************************/
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function fetches document Status *
+ ****************************************************************************/
function fn_get_avatax_document_status()
{
-
- $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true);
+ $order_statuses = fn_get_statuses();
$avatax_document_status = array();
foreach ($order_statuses as $key => $value) {
@@ -784,15 +453,14 @@ function fn_get_avatax_document_status()
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
- * Description : This function fetches document Status *
- **********************************************e*****************************/
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function fetches document Status *
+ ****************************************************************************/
function fn_get_avatax_return_status()
{
-
$order_statuses = fn_get_statuses(STATUSES_RETURN, array(), true);
$avatax_document_status = array();
@@ -807,15 +475,14 @@ function fn_get_avatax_return_status()
/***************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
- * Description : This function sets Document State = void *
- **********************************************e*****************************/
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function sets Document State = void *
+ ****************************************************************************/
function fn_document_state_voided($order_info, $status_from)
{
-
$AvaTaxDocumentStatus = fn_get_avatax_document_status();
if (trim($AvaTaxDocumentStatus[$status_from]) == "Committed") {
@@ -825,7 +492,7 @@ function fn_document_state_voided($order_info, $status_from)
//1. Call CancelTax with CancelCode = DocDeleted
$DocDeletedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocDeleted");
- if($DocDeletedReturn == 'Success'){
+ if ($DocDeletedReturn == 'Success') {
//2. Call GetTax with Commit = False
$DocCommittedReturn = fn_avatax_tax_calculation_avatax_gettax_commit($order_info, 0);
@@ -839,27 +506,25 @@ function fn_document_state_voided($order_info, $status_from)
}
}
-
- /***************************************************************************
+/****************************************************************************
* *
- * Function Header *
- * *
- * File Version : *
- * Last Updated On : 02/22/2015 *
- * Description : This function changes *
-* Document State = Uncommitted *
- **********************************************e*****************************/
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function changes *
+ * Document State = Uncommitted *
+ ****************************************************************************/
function fn_document_state_uncommitted($order_info, $status_from)
{
-
$AvaTaxDocumentStatus = fn_get_avatax_document_status();
if (trim($AvaTaxDocumentStatus[$status_from]) == "Committed") {
//1. Call CancelTax with CancelCode = Voided
$DocVoidedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocVoided");
//2. Call CancelTax with CancelCode = DocDeleted
- if($DocVoidedReturn == 'Success'){
+ if ($DocVoidedReturn == 'Success') {
$DocDeletedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocDeleted");
//3. Call GetTax with Commit = False
$DocCommittedReturn = fn_avatax_tax_calculation_avatax_gettax_commit($order_info, 0);
@@ -869,7 +534,7 @@ function fn_document_state_uncommitted($order_info, $status_from)
$DocDeletedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocDeleted");
//2. Call GetTax with Commit = False
- if($DocDeletedReturn == 'Success'){
+ if ($DocDeletedReturn == 'Success') {
$DocCommittedReturn = fn_avatax_tax_calculation_avatax_gettax_commit($order_info, 0);
}
} else if (trim($AvaTaxDocumentStatus[$status_from]) == "Uncommitted") {
@@ -879,36 +544,32 @@ function fn_document_state_uncommitted($order_info, $status_from)
}
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function changes *
-* Document State = Committed *
-****************************************************************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function changes *
+ * Document State = Committed *
+ ****************************************************************************/
function fn_document_state_committed($order_info, $status_from)
{
-
- $AvaTaxDocumentStatus = fn_get_avatax_document_status();
+ $AvaTaxDocumentStatus = fn_get_avatax_document_status();
if (trim($AvaTaxDocumentStatus[$status_from]) == "Committed") {
//1. Call CancelTax with CancelCode = Voided
$DocVoidedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocVoided");
- if($DocVoidedReturn == 'Success'){
+ if ($DocVoidedReturn == 'Success') {
//2. Call CancelTax with CancelCode = DocDeleted
$DocDeletedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocDeleted");
//3. Call GetTax with Commit = False
$DocCommittedReturn = fn_avatax_tax_calculation_avatax_gettax_commit($order_info, 1);
}
-
-
-
} else if (trim($AvaTaxDocumentStatus[$status_from]) == "Voided") {
//1. Call CancelTax with CancelCode = DocDeleted
$DocDeletedReturn = fn_avatax_tax_calculation_avatax_canceltax($order_info["avatax_paytax_document_code"], "DocDeleted");
//2. Call GetTax with Commit = False
- if($DocDeletedReturn == 'Success'){
+ if ($DocDeletedReturn == 'Success') {
$DocCommittedReturn = fn_avatax_tax_calculation_avatax_gettax_commit($order_info, 1);
}
} else if (trim($AvaTaxDocumentStatus[$status_from]) == "Uncommitted") {
@@ -917,23 +578,26 @@ function fn_document_state_committed($order_info, $status_from)
}
}
-
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function changes *
-* Document State to the desired state as per the *
-* passed second parameter *
-**********************************************e*****************************/
-
-function fn_avatax_change_document_status($order_info,$status_to, $status_from, $order_id = 0)
+* *
+* Function Header *
+* *
+* File Version : *
+* Last Updated On : 02/03/2021 *
+* Description : This function changes *
+* Document State to the desired state as per the *
+* passed second parameter *
+****************************************************************************/
+
+function fn_avatax_change_document_status($order_info, $status_to, $status_from, $order_id = 0)
{
-
-
-
+ $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
+ if ($log_mode == 1) {
+ $e = new Exception();
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, '', $status_to, $e->getTraceAsString());
+ $application_log->WriteSystemLogToFile();
+ }
+
Switch ($status_to) {
case 'P': //Processed
fn_document_state_committed($order_info, $status_from);
@@ -956,7 +620,6 @@ function fn_avatax_change_document_status($order_info,$status_to, $status_from,
case 'I': //Canceled
fn_document_state_voided($order_info, $status_from);
break;
-
default: //Default
//fn_document_state_committed($order_info, $status_from);
break;
@@ -969,33 +632,26 @@ function fn_avatax_change_document_status($order_info,$status_to, $status_from,
/** [AVATAX API CALLS FUNCTIONS] **/
#{
-
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function calculate the Taxable Amount *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
-
-function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rates, $company_id, $cart, $auth)
-{
-
-
- $timeStamp = new DateTime(); // Create Time Stamp
- $connectorstart=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+* *
+* Function Header *
+* *
+* File Version : *
+* Last Updated On : 02/03/2021 *
+* Description : This function calculate the Taxable Amount *
+* *
+* Important (on Feb25): Removed all commented code from this function *
+* *
+****************************************************************************/
+
+function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rates, $company_id, $cart, $auth, $order_info)
+{
+ $timeStamp = new DateTime();
+ $connectorstart = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$time_start = round(microtime(true) * 1000);
$lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
require_once($lib_path . "AvaTax4PHP/AvaTax.php");
- spl_autoload_register('__autoload');
-
- $environment = 'Development';
-
$company_details = fn_get_company_placement_info($company_id);
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
@@ -1004,9 +660,7 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
$client = CLIENT_NAME;
$CompanyCode = Registry::get('addons.avatax_tax_calculation.avatax_company_code');
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = (strpos($service_url, "development") === false) ? 'Production' : 'Development';
new ATConfig($environment, array('url' => $service_url, 'account' => $account, 'license' => $license, 'client' => $client, 'trace' => TRUE));
@@ -1033,17 +687,11 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
$DestCountry = $user_info['s_country'];
}
-
$DocType = "SalesOrder";
$a = session_id();
if (empty($a)) session_start();
-
- $DocCode=$order_info['order_id'];
- if($DocCode=="")
- {
- $DocCode = session_id();
- }
+ $DocCode = array_key_exists('order_id', $order_info) && $order_info['order_id'] != "" ? $order_info['order_id'] : session_id();
$SalesPersonCode = "";
$EntityUseCode = "";
$Discount = $cart['subtotal_discount'];
@@ -1078,7 +726,6 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
$request->setCurrencyCode(CART_PRIMARY_CURRENCY);
$request->setCommit(FALSE);
-
//Add Origin Address
$origin = new Address();
$origin->setLine1($OrigAddress);
@@ -1123,29 +770,19 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
/////////////////////// UPC Implementation - Start /////////////////////////
// Receiving UPC Code if Set
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
+ if (Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
{
$UpcCode = $product['product_id'];
$UpcCode = db_get_field("SELECT `upc_code` FROM ?:products WHERE `product_id` = $UpcCode");
- if ( ($UpcCode == "") || ($UpcCode == "none") ){
- if($product["product_code"] == ""){
- $itemCode = substr($product["product"], 0, 50);
- }
- else{
- $itemCode = $product["product_code"];
- }
- }
- else
- {
+ if ( ($UpcCode == "") || ($UpcCode == "none") ) {
+ $itemCode = $product["product_code"] == "" ? substr($product["product"], 0, 50) : $product["product_code"];
+ } else {
// UPC Code validation logic will come here : (Future)
$itemCode = 'UPC:' . $UpcCode;
}
- }
- else if($product["product_code"] == "")
- {
+ } else if ($product["product_code"] == "") {
$itemCode = substr($product["product"], 0, 50);
- }
- else {
+ } else {
$itemCode = $product["product_code"];
}
/////////////////////// UPC Implementation - End /////////////////////////
@@ -1170,7 +807,6 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
}
$shipping_id = $cart['chosen_shipping'][0];
if (isset($shipping_id[0]) || isset($shipping_id)) {
-
$TaxCode = db_get_field("SELECT `tax_code` FROM ?:shippings WHERE `shipping_id` = $shipping_id");
if ($TaxCode == "none") {
$TaxCode = 'FR';
@@ -1195,31 +831,30 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
$returnMessage = "";
try {
-
if (!empty($DestPostalCode)) {
- $connectortime = round(microtime(true) * 1000)-$time_start;
+ $connectortime = round(microtime(true) * 1000) - $time_start;
$latency = round(microtime(true) * 1000);
- $connectorcalling=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $connectorcalling = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$getTaxResult = $client->getTax($request);
- $connectorcomplete=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $latency = round(microtime(true) * 1000)-$latency;
+ $connectorcomplete = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $latency = round(microtime(true) * 1000) - $latency;
// Error Trapping
if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
/***
* Place holder for logs
* getLastRequest
* getLastResponse
- $client->__getLastRequest()
- $client->__getLastRes()
-
- ******/
-
- /************* Logging code snippet (optional) starts here *******************/
- // System Logger starts here:
+ $client->__getLastRequest()
+ $client->__getLastRes()
+
+ ******/
+
+ /************* Logging code snippet (optional) starts here *******************/
+ // System Logger starts here:
require_once "SystemLogger.php";
// Creating the System Logger Object
- $application_log = new SystemLogger;
- $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $application_log = new SystemLogger;
+ $connectorend = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
$performance_metrics[] = array($connectorstart,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax Start Time-\"".$connectorstart,$account,$getTaxResult->getDocCode(),"GetTax",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
$performance_metrics[] = array($connectorcalling,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax End Time-\"".$connectorcalling,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
@@ -1229,30 +864,24 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
$returnServiceLog = $application_log->serviceLog($performance_metrics);
$log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
- if($log_mode==1){
- $params = '[Input: ' . ']'; // Create Param List
- $u_name = ''; // Eventually will come from $_SESSION[] object
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
-
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
+ if ($log_mode == 1) {
+ $params = '[Input: ' . ']'; // Create Param List
+ $u_name = ''; // Eventually will come from $_SESSION[] object
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
+
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
//$application_log->metric('GetTax '.$getTaxResult->getDocType(),count($getTaxResult->getTaxLines()),$getTaxResult->getDocCode(),$connectortime,$latency);
- // $application_log->WriteSystemLogToDB(); // Log info goes to DB
- // System Logger ends here
- // Logging code snippet (optional) ends here
- }
- else{}
-
-
-
-
+ // $application_log->WriteSystemLogToDB(); // Log info goes to DB
+ // System Logger ends here
+ // Logging code snippet (optional) ends here
+ }
// If NOT success - display error messages to console
// it is important to iterate through the entire message class
return $getTaxResult;
-
} else {
foreach ($getTaxResult->getMessages() as $msg) {
$returnMessage .= $msg->getName() . ": " . $msg->getSummary() . "\n";
@@ -1270,34 +899,33 @@ function fn_avatax_tax_calculation_avatax_amount($group_products, $shipping_rate
$avatax_tax_error = '
' . $return_message . '
';
fn_set_notification('E', __('error'), $avatax_tax_error);
return 0;
-
} //Comment this line to return SOAP XML
}
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function validates the give address *
-* Description : along with order info *
-* *
-* Important (on Feb25): To be removed *
-* all commented code from this function *
-* *
-**********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function validates the give address *
+ * Description : along with order info *
+ * *
+ * Important (on Feb25): To be removed *
+ * all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_address_validation($user_data)
{
- /*
+ /*
$company_details = fn_get_company_placement_info($user_data['company_id']);
$environment = 'Development';
- //if(Registry::get('addons.avatax_tax_calculation.avatax_development_mode')==1) $environment = 'Development';
+ //if (Registry::get('addons.avatax_tax_calculation.avatax_development_mode')==1) $environment = 'Development';
//else $environment = 'Production';
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
@@ -1321,8 +949,8 @@ function fn_avatax_tax_calculation_avatax_address_validation($user_data)
$return_message = "";
$lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
require_once($lib_path . "AvaTax4PHP/address_validation.php");
- $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
- $addon_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/';
+ $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
+ $addon_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/';
//$return_message = AddressValidation($address_data);
@@ -1330,34 +958,32 @@ function fn_avatax_tax_calculation_avatax_address_validation($user_data)
if (trim($return_message) != "") {
$avatax_address_validation = '
' . $return_message . '
';
} */
- $avatax_address_validation = "";
+ $avatax_address_validation = "";
return $avatax_address_validation;
}
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function serves as the wrapper function *
-* for AvaTax GetTax() Call *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function serves as the wrapper function *
+ * for AvaTax GetTax() Call *
+ * *
+ * Important (on Feb25): Removed all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
{
- $timeStamp = new DateTime(); // Create Time Stamp
- $connectorstart=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $timeStamp = new DateTime(); // Create Time Stamp
+ $connectorstart = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$time_start = round(microtime(true) * 1000);
$lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
require_once($lib_path . "AvaTax4PHP/AvaTax.php");
- spl_autoload_register('__autoload');
- $environment = 'Development';
$company_details = fn_get_company_placement_info($order_info['company_id']);
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
@@ -1366,9 +992,7 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
$client = CLIENT_NAME;
$CompanyCode = Registry::get('addons.avatax_tax_calculation.avatax_company_code');
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = strpos($service_url, "development") === false ? 'Production' : 'Development';
new ATConfig($environment, array('url' => $service_url, 'account' => $account, 'license' => $license, 'client' => $client, 'trace' => TRUE));
@@ -1387,16 +1011,9 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
$DestRegion = $order_info["s_state"];
$DestPostalCode = $order_info["s_zipcode"];
$DestCountry = $order_info["s_country"];
-
+
//Code Added for Implementation of Doc Sav Feature in CS Cart 4.2.4 Build
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_savedoc') == 1)
- {
- $DocType = "SalesInvoice";
- }
- else
- {
- $DocType = "SalesOrder";
- }
+ $DocType = Registry::get('addons.avatax_tax_calculation.avatax_tax_savedoc') == 1 ? "SalesInvoice" : "SalesOrder";
$DocCode = $order_info['order_id'];
$SalesPersonCode = "";
$EntityUseCode = "";
@@ -1486,30 +1103,19 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
/////////////////////// UPC Implementation - Start /////////////////////////
// Receiving UPC Code if set
- // Implementation of UPC Code Implementation Feature in CS Cart 4.2.4
+ // Implementation of UPC Code Implementation Feature in CS Cart 4.2.4
$UpcCode = $product_data['upc_code'];
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
+ if (Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
{
- if ( ($UpcCode == "") || ($UpcCode == "none") ) {
- if($v["product_code"] == ""){
- $itemCode = substr($v["product"], 0, 50);
-
- }
- else{
- $itemCode = $v["product_code"];
- }
- }
- else
- {
+ if ( ($UpcCode == "") || ($UpcCode == "none") ) {
+ $itemCode = $v["product_code"] == "" ? substr($v["product"], 0, 50) : $v["product_code"];
+ } else {
// UPC Code validation logic will come here : Future
$itemCode = 'UPC:' . $UpcCode;
}
- }
- else if($v["product_code"] == "")
- {
+ } else if ($v["product_code"] == "") {
$itemCode = substr($v["product"], 0, 50);
- }
- else{
+ } else {
$itemCode = $v["product_code"];
}
@@ -1545,7 +1151,7 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
$product_total += $v['amount'];
}
- //Shipping Line Item
+ // Shipping Line Item
// Order Totals
$shipping_count = 0;
@@ -1609,8 +1215,8 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
require_once "SystemLogger.php";
// Creating the System Logger Object
- $application_log = new SystemLogger;
- $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $application_log = new SystemLogger;
+ $connectorend = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
$performance_metrics[] = array($connectorstart,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax Start Time-\"".$connectorstart,$account,$getTaxResult->getDocCode(),"GetTax",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
$performance_metrics[] = array($connectorcalling,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax End Time-\"".$connectorcalling,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
@@ -1622,28 +1228,26 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
// System Logger starts here:
$log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
- if($log_mode==1){
+ if ($log_mode == 1) {
- $params = '[Input: ' . ']'; // Create Param List
- $u_name = ''; // Eventually will come from $_SESSION[] object
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
+ $params = '[Input: ' . ']'; // Create Param List
+ $u_name = ''; // Eventually will come from $_SESSION[] object
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
// $application_log->metric('GetTax '.$getTaxResult->getDocType(),count($getTaxResult->getTaxLines()),$getTaxResult->getDocCode(),$connectortime,$latency);
- // $application_log->WriteSystemLogToDB(); // Log info goes to DB
- // System Logger ends here
- // Logging code snippet (optional) ends here
+ // $application_log->WriteSystemLogToDB(); // Log info goes to DB
+ // System Logger ends here
+ // Logging code snippet (optional) ends here
}
- else{}
-
+
return $GetTaxData;
} else {
-
foreach ($getTaxResult->getMessages() as $msg) {
$returnMessage .= $msg->getName() . ": " . $msg->getSummary() . "\n";
@@ -1668,29 +1272,27 @@ function fn_avatax_tax_calculation_avatax_gettax($order_info, $auth)
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function serves as the wrapper function *
-* for AvaTax GetTax() Call *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function serves as the wrapper function *
+ * for AvaTax GetTax() Call *
+ * *
+ * Important (on Feb25): Removed all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_status)
{
- $timeStamp = new DateTime(); // Create Time Stamp
+ $timeStamp = new DateTime(); // Create Time Stamp
$connectorstart=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$time_start = round(microtime(true) * 1000);
$lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
require_once($lib_path . "AvaTax4PHP/AvaTax.php");
- spl_autoload_register('__autoload');
- $environment = 'Development';
$company_details = fn_get_company_placement_info($order_info['company_id']);
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
@@ -1698,16 +1300,13 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
$license = Registry::get('addons.avatax_tax_calculation.avatax_license_key');
$client = CLIENT_NAME;
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = strpos($service_url, "development") === false ? 'Production' : 'Development';
new ATConfig($environment, array('url' => $service_url, 'account' => $account, 'license' => $license, 'client' => $client, 'trace' => TRUE));
//Variable Mapping
$CustomerCode = $order_info["user_id"];
-
$OrigAddress = $company_details["company_address"];
$OrigCity = $company_details["company_city"];
$OrigRegion = $company_details["company_state"];
@@ -1721,14 +1320,7 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
$DestCountry = $order_info["s_country"];
$CompanyCode = Registry::get('addons.avatax_tax_calculation.avatax_company_code');
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_savedoc') == 1)
- {
- $DocType = "SalesInvoice";
- }
- else
- {
- $DocType = "SalesOrder";
- }
+ $DocType = Registry::get('addons.avatax_tax_calculation.avatax_tax_savedoc') == 1 ? "SalesInvoice" : "SalesOrder";
$DocCode = $order_info["order_id"];
$SalesPersonCode = "";
$EntityUseCode = "";
@@ -1803,51 +1395,36 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
$avatax_discount_amount = 0;
$auth = & $_SESSION['auth'];
foreach ($order_info['products'] as $k => $v) {
-
-
$product_original_amount = fn_product_real_price($v["product_id"]);
-
- $total_amount = ($v["price"] * $v["amount"]);
-
+ $total_amount = ($v["price"] * $v["amount"]);
$product_data = fn_get_product_data($v["product_id"], $auth);
-
$product_categories = "";
foreach ($product_data['category_ids'] as $pck => $pcv) {
$product_categories .= fn_get_category_name($pcv) . ",";
}
$Description = $product_categories;
-
$TaxCode = $product_data["tax_code"];
-
if ($TaxCode == "none") {
$TaxCode = 'P0000000';
}
-
/////////////////////// UPC Implementation - Start /////////////////////////
// Receiving UPC Code if set
$UpcCode = $product_data['upc_code'];
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
- {
+ if (Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1) {
if ( ($UpcCode == "") || ($UpcCode == "none") ) {
- if($v["product_code"] == ""){
+ if ($v["product_code"] == "") {
$itemCode = substr($v["product"], 0, 50);
- }
- else{
+ } else{
$itemCode = $v["product_code"];
}
- }
- else
- {
+ } else {
// UPC Code validation logic will come here : Future
$itemCode = 'UPC:' . $UpcCode;
}
- }
- else if($v["product_code"] == "")
- {
+ } else if ($v["product_code"] == "") {
$itemCode = substr($v["product"], 0, 50);
- }
- else{
+ } else{
$itemCode = $v["product_code"];
}
/////////////////////// UPC Implementation - End /////////////////////////
@@ -1861,17 +1438,13 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
$line1 = new Line();
-
$line1->setNo($i + 1);
-
$line1->setItemCode($itemCode);
$line1->setDescription($v["product"]);
$line1->setTaxCode($TaxCode);
$line1->setQty($v["amount"]);
-
$line1->setAmount($total_amount);
$line1->setDiscounted(true);
-
$line1->setRevAcct($RevAcct);
$line1->setRef1($Ref1);
$line1->setRef2($Ref2);
@@ -1898,7 +1471,6 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
}
$line1 = new Line();
$line1->setNo($i + 1);
-
$line1->setItemCode("Shipping");
$line1->setDescription($order_shipment['shipping']);
$line1->setTaxCode($TaxCode);
@@ -1918,23 +1490,19 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
$shipping_count++;
}
-
$request->setLines($lines);
-
$GetTaxData = array();
$returnMessage = "";
try {
-
$connectortime = round(microtime(true) * 1000)-$time_start;
$latency = round(microtime(true) * 1000);
- $connectorcalling=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $connectorcalling = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$getTaxResult = $client->getTax($request);
- $connectorcomplete=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $connectorcomplete = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$latency = round(microtime(true) * 1000)-$latency;
// Error Trapping
if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
-
$GetTaxData['GetTaxDocCode'] = $getTaxResult->getDocCode();
$GetTaxData['GetTaxDocDate'] = $getTaxResult->getDocDate();
$GetTaxData['GetTaxTotalAmount'] = $getTaxResult->getTotalAmount();
@@ -1944,46 +1512,42 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
* getLastRequest
* getLastResponse
*/
- /************* Logging code snippet (optional) starts here *******************/
- // System Logger starts here:
- require_once "SystemLogger.php";
- // Creating the System Logger Object
- $application_log = new SystemLogger;
- $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
- $performance_metrics[] = array($connectorstart,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax Start Time-\"".$connectorstart,$account,$getTaxResult->getDocCode(),"GetTax",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorcalling,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax End Time-\"".$connectorcalling,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorcomplete,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax Start Time-\"".$connectorcomplete,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorend,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax End Time-\"".$connectorend,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- //Call serviceLog function
- $returnServiceLog = $application_log->serviceLog($performance_metrics);
-
- $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
- if($log_mode==1){
- $params = '[Input: ' . ']'; // Create Param List
- $u_name = ''; // Eventually will come from $_SESSION[] object
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
+ /************* Logging code snippet (optional) starts here *******************/
+ // System Logger starts here:
+ require_once "SystemLogger.php";
+ // Creating the System Logger Object
+ $application_log = new SystemLogger;
+ $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
+ $performance_metrics[] = array($connectorstart,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax Start Time-\"".$connectorstart,$account,$getTaxResult->getDocCode(),"GetTax",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ $performance_metrics[] = array($connectorcalling,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax End Time-\"".$connectorcalling,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ $performance_metrics[] = array($connectorcomplete,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax Start Time-\"".$connectorcomplete,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ $performance_metrics[] = array($connectorend,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax End Time-\"".$connectorend,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ //Call serviceLog function
+ $returnServiceLog = $application_log->serviceLog($performance_metrics);
+
+ if (Registry::get('addons.avatax_tax_calculation.avatax_log_mode') == 1) {
+ $params = '[Input: ' . ']'; // Create Param List
+ $u_name = ''; // Eventually will come from $_SESSION[] object
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
//$application_log->metric('GetTax '.$getTaxResult->getDocType(),count($getTaxResult->getTaxLines()),$getTaxResult->getDocCode(),$connectortime,$latency);
- // $application_log->WriteSystemLogToDB(); // Log info goes to DB
- // System Logger ends here
- // Logging code snippet (optional) ends here
+ // $application_log->WriteSystemLogToDB(); // Log info goes to DB
+ // System Logger ends here
+ // Logging code snippet (optional) ends here
}
- else{}
-
+
return $GetTaxData;
} else {
-
- if($getTaxResult->getResultCode() == SeverityLevel::$Error){
+ if ($getTaxResult->getResultCode() == SeverityLevel::$Error) {
$return_message = "AvaTax - Error Message ";
- foreach($getTaxResult->getMessages() as $msg)
- {
+ foreach($getTaxResult->getMessages() as $msg) {
$return_message .= $msg->getSummary()." ";
}
$avatax_tax_error = '
' . $return_message . '
';
@@ -2018,27 +1582,22 @@ function fn_avatax_tax_calculation_avatax_gettax_commit($order_info, $commit_sta
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function serves as the wrapper function *
-* for AvaTax PostTax() Call *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
-
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function serves as the wrapper function *
+ * for AvaTax PostTax() Call *
+ * *
+ * Important (on Feb25): Removed all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_posttax($GetTaxReturnValue)
{
- $environment = 'Development';
-
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = strpos($service_url, "development") === false ? 'Production' : 'Development';
$order_data = array();
$dateTime = new DateTime();
@@ -2069,28 +1628,24 @@ function fn_avatax_tax_calculation_avatax_posttax($GetTaxReturnValue)
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function serves as the wrapper function *
-* for AvaTax CancelTax() Call *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function serves as the wrapper function *
+ * for AvaTax CancelTax() Call *
+ * *
+ * Important (on Feb25): Removed all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_canceltax($AvaTaxDocumentCode, $CancelCode, $DocType = "SalesInvoice")
{
//echo $AvaTaxDocumentCode;
- $environment = 'Development';
-
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = strpos($service_url, "development") === false ? 'Production' : 'Development';
$order_data = array();
$dateTime = new DateTime();
@@ -2116,28 +1671,23 @@ function fn_avatax_tax_calculation_avatax_canceltax($AvaTaxDocumentCode, $Cancel
}
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function fetches gettax history for the *
-* sent order details *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function fetches gettax history for the *
+ * sent order details *
+ * *
+ * Important (on Feb25): Removed all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_gettax_history($order_info)
{
-
- $environment = 'Development';
-
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = strpos($service_url, "development") === false ? 'Production' : 'Development';
$company_details = fn_get_company_placement_info($order_info['company_id']);
@@ -2165,29 +1715,27 @@ function fn_avatax_tax_calculation_avatax_gettax_history($order_info)
/****************************************************************************
-* *
-* Function Header *
-* *
-* File Version : *
-* Last Updated On : 02/22/2015 *
-* Description : This function does tax computation on *
-* sent return invoice details *
-* *
-* Important (on Feb25): Removed all commented code from this function *
-* *
-**********************************************e*****************************/
+ * *
+ * Function Header *
+ * *
+ * File Version : *
+ * Last Updated On : 02/03/2021 *
+ * Description : This function does tax computation on *
+ * sent return invoice details *
+ * *
+ * Important (on Feb25): Removed all commented code from this function *
+ * *
+ ****************************************************************************/
function fn_avatax_tax_calculation_avatax_return_invoice($return_info, $order_info, $tax_history_data)
{
- $timeStamp = new DateTime(); // Create Time Stamp
- $connectorstart=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $timeStamp = new DateTime(); // Create Time Stamp
+ $connectorstart = $timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
$time_start = round(microtime(true) * 1000);
$lib_path = Registry::get('config.dir.addons') . 'avatax_tax_calculation/lib/';
require_once($lib_path . "AvaTax4PHP/AvaTax.php");
- spl_autoload_register('__autoload');
- $environment = 'Development';
$company_details = fn_get_company_placement_info($order_info['company_id']);
$service_url = Registry::get('addons.avatax_tax_calculation.avatax_service_url');
@@ -2195,10 +1743,7 @@ function fn_avatax_tax_calculation_avatax_return_invoice($return_info, $order_in
$license = Registry::get('addons.avatax_tax_calculation.avatax_license_key');
$client = CLIENT_NAME;
$CompanyCode = Registry::get('addons.avatax_tax_calculation.avatax_company_code');
-
- $pos = strpos($service_url, "development");
- if ($pos === false) $environment = 'Production';
- else $environment = 'Development';
+ $environment = strpos($service_url, "development") === false ? 'Production' : 'Development';
new ATConfig($environment, array('url' => $service_url, 'account' => $account, 'license' => $license, 'client' => $client, 'trace' => TRUE));
@@ -2216,21 +1761,14 @@ function fn_avatax_tax_calculation_avatax_return_invoice($return_info, $order_in
$DestRegion = $order_info["s_state"];
$DestPostalCode = $order_info["s_zipcode"];
$DestCountry = $order_info["s_country"];
-
- //Code Added to implement Doc Type Feature in CS Cart 4.2.4 build)
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_savedoc') == 1)
- {
- $DocType = "ReturnInvoice";
- }
- else
- {
- $DocType = "ReturnOrder";
- }
+
+ //Code Added to implement Doc Type Feature in CS Cart 4.2.4 build)
+ $DocType = Registry::get('addons.avatax_tax_calculation.avatax_tax_savedoc') == 1 ? "ReturnInvoice" : "ReturnOrder";
$DocCode = $return_info["avatax_return_document_code"];
$SalesPersonCode = "";
$EntityUseCode = "";
- $Discount = 0;//$order_info['subtotal_discount'];
+ $Discount = 0; //$order_info['subtotal_discount'];
$PurchaseOrderNo = '';
$ExemptionNo = "";
$LocationCode = '';
@@ -2303,200 +1841,187 @@ function fn_avatax_tax_calculation_avatax_return_invoice($return_info, $order_in
$return_order_array = $return_info['items'];
$accepted_items = $return_order_array['A'];
- if(count($accepted_items)>0){
- foreach ($accepted_items as $key_inner => $value_inner) {
+ if (count($accepted_items) > 0) {
+ foreach ($accepted_items as $key_inner => $value_inner) {
- $v = $order_info["products"][$key_inner];
+ $v = $order_info["products"][$key_inner];
- $return_reason = fn_return_reason($value_inner["reason"]);
- $product_original_amount = fn_product_real_price($value_inner["product_id"]);
-
- $total_amount = ($value_inner["price"] * $value_inner["amount"]);
+ $return_reason = fn_return_reason($value_inner["reason"]);
+ $product_original_amount = fn_product_real_price($value_inner["product_id"]);
+
+ $total_amount = ($value_inner["price"] * $value_inner["amount"]);
- $product_data = fn_get_product_data($value_inner["product_id"], $auth);
- $product_categories = "";
- foreach ($product_data['category_ids'] as $pck => $pcv) {
- $product_categories .= fn_get_category_name($pcv) . ",";
- }
- $Description = $product_categories;
+ $product_data = fn_get_product_data($value_inner["product_id"], $auth);
+ $product_categories = "";
+ foreach ($product_data['category_ids'] as $pck => $pcv) {
+ $product_categories .= fn_get_category_name($pcv) . ",";
+ }
+ $Description = $product_categories;
- $TaxCode = $product_data["tax_code"];
+ $TaxCode = $product_data["tax_code"];
- if ($TaxCode == "none") {
- $TaxCode = 'P0000000';
- }
+ if ($TaxCode == "none") {
+ $TaxCode = 'P0000000';
+ }
- /////////////////////// UPC Implementation - Start /////////////////////////
- // Receiving UPC Code if set
- $UpcCode = $product_data['upc_code'];
- if(Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
- {
- if ( ($UpcCode == "") || ($UpcCode == "none") ) {
- if($product_data["product_code"] == ""){
- $itemCode = substr($product_data["product"], 0, 50);
- }
- else{
- $itemCode = $product_data["product_code"];
- }
+ /////////////////////// UPC Implementation - Start /////////////////////////
+ // Receiving UPC Code if set
+ $UpcCode = $product_data['upc_code'];
+ if (Registry::get('addons.avatax_tax_calculation.avatax_tax_upc') == 1)
+ {
+ if ( ($UpcCode == "") || ($UpcCode == "none") ) {
+ if ($product_data["product_code"] == "") {
+ $itemCode = substr($product_data["product"], 0, 50);
}
- else
- {
- // UPC Code validation logic will come here : Future
- $itemCode = 'UPC:' . $UpcCode;
+ else{
+ $itemCode = $product_data["product_code"];
}
}
- else if($product_data["product_code"] == "")
+ else
{
- $itemCode = substr($product_data["product"], 0, 50);
- }
- else{
- $itemCode = $product_data["product_code"];
- }
- /////////////////////// UPC Implementation - End /////////////////////////
-
-
- $discount_count = 0;
- $temp_discount_amount = $product_original_amount - $value_inner["price"];
- if ($temp_discount_amount > 0) {
- $discount_count = 1;
- $discount_amount = $value_inner["price"];
+ // UPC Code validation logic will come here : Future
+ $itemCode = 'UPC:' . $UpcCode;
}
+ }
+ else if ($product_data["product_code"] == "")
+ {
+ $itemCode = substr($product_data["product"], 0, 50);
+ }
+ else{
+ $itemCode = $product_data["product_code"];
+ }
+ /////////////////////// UPC Implementation - End /////////////////////////
- $line1 = new Line();
- $line1->setNo($i+1);//$product["product_id"]
-
- $line1->setItemCode($itemCode);
- $line1->setDescription($value_inner["product"]);
- $line1->setTaxCode($TaxCode);
-
- $line1->setQty($value_inner["amount"]);
-
- $line1->setAmount(-$total_amount);
- $line1->setDiscounted(true);
-
- $line1->setRevAcct($RevAcct);
- $line1->setRef1($Ref1);
- $line1->setRef2($Ref2);
- $line1->setExemptionNo($ExemptionNo);
- $line1->setCustomerUsageType($EntityUseCode);
- $line1->setOriginAddress($origin);
- $line1->setDestinationAddress($destination);
-
- $lines[$i] = $line1;
- $i++;
-
- $product_total += $value_inner['amount'];
+ $discount_count = 0;
+ $temp_discount_amount = $product_original_amount - $value_inner["price"];
+ if ($temp_discount_amount > 0) {
+ $discount_count = 1;
+ $discount_amount = $value_inner["price"];
}
+ $line1 = new Line();
+ $line1->setNo($i+1);//$product["product_id"]
+
+ $line1->setItemCode($itemCode);
+ $line1->setDescription($value_inner["product"]);
+ $line1->setTaxCode($TaxCode);
+
+ $line1->setQty($value_inner["amount"]);
+
+ $line1->setAmount(-$total_amount);
+ $line1->setDiscounted(true);
+
+ $line1->setRevAcct($RevAcct);
+ $line1->setRef1($Ref1);
+ $line1->setRef2($Ref2);
+ $line1->setExemptionNo($ExemptionNo);
+ $line1->setCustomerUsageType($EntityUseCode);
+ $line1->setOriginAddress($origin);
+ $line1->setDestinationAddress($destination);
+
+ $lines[$i] = $line1;
+ $i++;
+
+ $product_total += $value_inner['amount'];
+ }
//}
-
- $request->setLines($lines);
-
- $TaxOverride = new TaxOverride();
-
- $TaxOverride->setTaxOverrideType("TaxDate");
- $TaxOverride->setTaxDate($tax_history_data["DocDate"]);
- $TaxOverride->setReason($return_reason);
- $request->setTaxOverride($TaxOverride);
+ $request->setLines($lines);
+
+ $TaxOverride = new TaxOverride();
+
+ $TaxOverride->setTaxOverrideType("TaxDate");
+ $TaxOverride->setTaxDate($tax_history_data["DocDate"]);
+ $TaxOverride->setReason($return_reason);
+ $request->setTaxOverride($TaxOverride);
- $GetTaxData = array();
- $returnMessage = "";
+ $GetTaxData = array();
+ $returnMessage = "";
- try {
- $connectortime = round(microtime(true) * 1000)-$time_start;
- $latency = round(microtime(true) * 1000);
- $connectorcalling=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $getTaxResult = $client->getTax($request);
- $connectorcomplete=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $latency = round(microtime(true) * 1000)-$latency;
+ try {
+ $connectortime = round(microtime(true) * 1000) - $time_start;
+ $latency = round(microtime(true) * 1000);
+ $connectorcalling=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $getTaxResult = $client->getTax($request);
+ $connectorcomplete=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $latency = round(microtime(true) * 1000)-$latency;
- // Error Trapping
- if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
+ // Error Trapping
+ if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
+ $GetTaxData['GetTaxDocCode'] = $getTaxResult->getDocCode();
+ $GetTaxData['GetTaxDocDate'] = $getTaxResult->getDocDate();
+ $GetTaxData['GetTaxTotalAmount'] = $getTaxResult->getTotalAmount();
+ $GetTaxData['GetTaxTotalTax'] = $getTaxResult->getTotalTax();
+ /***
+ * Place holder for logs
+ * getLastRequest
+ * getLastResponse
+ */
+
+ /************* Logging code snippet (optional) starts here *******************/
+ // System Logger starts here:
+ include_once "SystemLogger.php";
+ // Creating the System Logger Object
+ $application_log = new SystemLogger;
+
+ $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
+ $performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
+ $performance_metrics[] = array($connectorstart,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax Start Time-\"".$connectorstart,$account,$getTaxResult->getDocCode(),"GetTax",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ $performance_metrics[] = array($connectorcalling,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax End Time-\"".$connectorcalling,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ $performance_metrics[] = array($connectorcomplete,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax Start Time-\"".$connectorcomplete,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ $performance_metrics[] = array($connectorend,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax End Time\"".$connectorend,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
+ //Call serviceLog function
+ $returnServiceLog = $application_log->serviceLog($performance_metrics);
+
+ if (Registry::get('addons.avatax_tax_calculation.avatax_log_mode') == 1) {
+ $params = '[Input: ' . ']'; // Create Param List
+ $u_name = ''; // Eventually will come from $_SESSION[] object
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
+
+ $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
+ $application_log->WriteSystemLogToFile(); // Log info goes to log file
+ // $application_log->metric('GetTax '.$getTaxResult->getDocType(),count($getTaxResult->getTaxLines()),$getTaxResult->getDocCode(),$connectortime,$latency);
+ // $application_log->WriteSystemLogToDB(); // Log info goes to DB
+ // System Logger ends here
+ // Logging code snippet (optional) ends here
+ }
- $GetTaxData['GetTaxDocCode'] = $getTaxResult->getDocCode();
- $GetTaxData['GetTaxDocDate'] = $getTaxResult->getDocDate();
- $GetTaxData['GetTaxTotalAmount'] = $getTaxResult->getTotalAmount();
- $GetTaxData['GetTaxTotalTax'] = $getTaxResult->getTotalTax();
- /***
- * Place holder for logs
- * getLastRequest
- * getLastResponse
- */
-
- /************* Logging code snippet (optional) starts here *******************/
- // System Logger starts here:
- include_once "SystemLogger.php";
- // Creating the System Logger Object
- $application_log = new SystemLogger;
-
- $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
- $performance_metrics[] = array($connectorstart,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax Start Time-\"".$connectorstart,$account,$getTaxResult->getDocCode(),"GetTax",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorcalling,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PreGetTax End Time-\"".$connectorcalling,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorcomplete,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax Start Time-\"".$connectorcomplete,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorend,"\"LINECOUNT -".count($getTaxResult->getTaxLines())."PostGetTax End Time\"".$connectorend,$account,$getTaxResult->getDocCode(),"GetTax ",$service_url,"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- //Call serviceLog function
- $returnServiceLog = $application_log->serviceLog($performance_metrics);
-
- $log_mode = Registry::get('addons.avatax_tax_calculation.avatax_log_mode');
- if($log_mode==1){
- $params = '[Input: ' . ']'; // Create Param List
- $u_name = ''; // Eventually will come from $_SESSION[] object
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
-
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
- // $application_log->metric('GetTax '.$getTaxResult->getDocType(),count($getTaxResult->getTaxLines()),$getTaxResult->getDocCode(),$connectortime,$latency);
+ return $GetTaxData;
+ } else {
+ $return_message = "AvaTax - Error Message ";
+ foreach ($getTaxResult->getMessages() as $msg) {
+ $return_message .= $msg->getName() . ": " . $msg->getSummary() . "\n";
+ }
- // $application_log->WriteSystemLogToDB(); // Log info goes to DB
- // System Logger ends here
- // Logging code snippet (optional) ends here
+ $avatax_tax_error = '
';
- fn_set_notification('E', __('error'), $avatax_tax_error);
- $returnMessage = SeverityLevel::$Error;
- }
-
- }
- else
- {
- $returnMessage = $result->getResultCode();
- }
- // If NOT success - display error or warning messages to console
- // it is important to itterate through the entire message class
- }
- catch (SoapFault $exception)
- {
- $msg = "Exception: ";
- if ($exception)
- $msg .= $exception->faultstring;
- $return_message = "AvaTax - Error Message ";
- $return_message .= $msg;
- $avatax_tax_error = '
' . $return_message . '
';
- fn_set_notification('E', __('error'), $avatax_tax_error);
-
- // If you desire to retrieve SOAP IN / OUT XML
- // - Follow directions below
- // - if not, leave as is
- // } //UN-comment this line to return SOAP XML
- $returnMessage = SeverityLevel::$Error;
-
- //echo $client->__getLastRequest() . "\n";
- //echo $client->__getLastResponse() . "\n";
- } //Comment this line to return SOAP XML
-//}
-?>
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/lib/AvaTax4PHP/get_tax_history.php b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/lib/AvaTax4PHP/get_tax_history.php
deleted file mode 100644
index 6a64adb..0000000
--- a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/app/addons/avatax_tax_calculation/lib/AvaTax4PHP/get_tax_history.php
+++ /dev/null
@@ -1,108 +0,0 @@
-format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
-
- new ATConfig($order_data["environment"], array('url'=>$order_data["service_url"], 'account'=>$order_data["account"],'license'=>$order_data["license"],'client'=>$order_data["client"], 'trace'=> TRUE));
-
- $client = new TaxServiceSoap($order_data["environment"]);
- $request = new GetTaxHistoryRequest();
-
- $request->setCompanyCode($order_data["CompanyCode"]);
- $request->setDocType($order_data["DocType"]);
- $request->setDocCode($order_data["DocCode"]);
-
- //$returnMessage = "";
- $GetTaxHistoryReturnValue = array();
-
- // Get Tax History and Results
- try
- {
- $connectorcalling=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $result = $client->getTaxHistory($request);
- $connectorcomplete=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- // Creating the System Logger Object
- $application_log = new SystemLogger;
- $connectorend=$timeStamp->format('Y-m-d\TH:i:s').".".substr((string)microtime(), 2, 3)." ".$timeStamp->format("P");
- $performance_metrics[] = array("CallerTimeStamp","MessageString","CallerAcctNum","DocCode","Operation","ServiceURL","LogType","LogLevel","ERPName","ERPVersion","ConnectorVersion");
- $performance_metrics[] = array($connectorstart,"PreGetTaxHistory Start Time-\"".$connectorstart,$order_data["account"],$order_data["DocCode"],"TaxHistory",$order_data["service_url"],"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorcalling,"PreGetTaxHistory End Time-\"".$connectorcalling,$order_data["account"],$order_data["DocCode"],"TaxHistory",$order_data["service_url"],"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorcomplete,"PostGetTaxHistory Start Time-\"".$connectorcomplete,$order_data["account"],$order_data["DocCode"],"TaxHistory",$order_data["service_url"],"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- $performance_metrics[] = array($connectorend,"PostGetTaxHistory End Time-\"".$connectorend,$order_data["account"],$order_data["DocCode"],"TaxHistory",$order_data["service_url"],"Performance","Informational","CS-Cart",PRODUCT_VERSION,AVALARA_VERSION);
- //Call serviceLog function
- $returnServiceLog = $application_log->serviceLog($performance_metrics);
-
-
-
- /***
- * Place holder for logs
- * getLastRequest
- * getLastResponse
- */
-
- /************* Logging code snippet (optional) starts here *******************/
- // System Logger starts here:
-
-
- if($log_mode==1){
-
- $timeStamp = new DateTime(); // Create Time Stamp
- $params = '[Input: ' . ']'; // Create Param List
- $u_name = ''; // Eventually will come from $_SESSION[] object
-
-
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastRequest()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
-
- $application_log->AddSystemLog($timeStamp->format('Y-m-d H:i:s'), __FUNCTION__, __CLASS__, __METHOD__, __FILE__, $u_name, $params, $client->__getLastResponse()); // Create System Log
- $application_log->WriteSystemLogToFile(); // Log info goes to log file
-
- // $application_log->WriteSystemLogToDB(); // Log info goes to DB
- // System Logger ends here
- // Logging code snippet (optional) ends here
- }
- else{}
-
- // Success - Display GetTaxResults to console
- if ($result->getResultCode() != SeverityLevel::$Success) {
- foreach ($result->getMessages() as $msg) {
- $returnMessage .= $msg->getName() . ": " . $msg->getSummary() . "\n";
- }
- return "Error :".$returnMessage;
- }
- else
- {
- $GetTaxHistoryReturnValue["DocDate"] = $result->getGetTaxResult()->getDocDate();
- $GetTaxHistoryReturnValue["TaxDate"] = $result->getGetTaxResult()->getTaxDate();
- $GetTaxHistoryReturnValue["DocCode"] = $result->getGetTaxResult()->getDocCode();
- //return $GetTaxHistoryReturnValue;
- }
- // If NOT success - display error or warning messages to console
- // it is important to itterate through the entire message class
- }
- catch (SoapFault $exception)
- {
- $msg = "Exception: ";
- if ($exception)
- $msg .= $exception->faultstring;
-
- // If you desire to retrieve SOAP IN / OUT XML
- // - Follow directions below
- // - if not, leave as is
- // } //UN-comment this line to return SOAP XML
- $returnMessage .= $msg . "\n";
- $returnMessage .= $client->__getLastRequest() . "\n";
- $returnMessage .= $client->__getLastResponse() . "\n";
- return $returnMessage;
-
- //echo $client->__getLastRequest() . "\n";
- //echo $client->__getLastResponse() . "\n";
- } //Comment this line to return SOAP XML
-//}
-?>
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/media/images/Thumbs.db b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/media/images/Thumbs.db
deleted file mode 100644
index f2bf748..0000000
Binary files a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/media/images/Thumbs.db and /dev/null differ
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/index/scripts.post.tpl b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/index/scripts.post.tpl
new file mode 100644
index 0000000..1936499
--- /dev/null
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/index/scripts.post.tpl
@@ -0,0 +1,3 @@
+{if ($runtime.controller == "addons" && $runtime.mode == "update")}
+ {script src="js/addons/avatax_tax_calculation/index.js"}
+{/if}
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/products/tax_code.pre.tpl b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/products/update_product_tax_ids.pre.tpl
similarity index 100%
rename from Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/products/tax_code.pre.tpl
rename to Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/products/update_product_tax_ids.pre.tpl
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/profiles/detailed_content.post.tpl b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/profiles/detailed_content.post.tpl
new file mode 100644
index 0000000..f6050d7
--- /dev/null
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/profiles/detailed_content.post.tpl
@@ -0,0 +1,20 @@
+ {include file="common/subheader.tpl" title="AvaTax"}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/profiles/tax_exempt_number.pre.tpl b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/profiles/tax_exempt_number.pre.tpl
deleted file mode 100644
index 26891fb..0000000
--- a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/profiles/tax_exempt_number.pre.tpl
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/shippings/tax_code.pre.tpl b/Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/shippings/update.pre.tpl
similarity index 100%
rename from Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/shippings/tax_code.pre.tpl
rename to Avalara AvaTax for CS Cart version 00.00.11.00/design/backend/templates/addons/avatax_tax_calculation/hooks/shippings/update.pre.tpl
diff --git a/Avalara AvaTax for CS Cart version 00.00.11.00/js/addons/avatax_tax_calculation/index.js b/Avalara AvaTax for CS Cart version 00.00.11.00/js/addons/avatax_tax_calculation/index.js
new file mode 100644
index 0000000..d1614a4
--- /dev/null
+++ b/Avalara AvaTax for CS Cart version 00.00.11.00/js/addons/avatax_tax_calculation/index.js
@@ -0,0 +1,238 @@
+$( document ).ready(function() {
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value != "") {
+ $("#avatax_tax_calculation_section2").hide();
+ $("#signinInfo").hide();
+ }
+
+ $(".cm-dialog-closer").click(function() {
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value != "") {
+ $("[id^=\'container_addon_option_avatax_tax_calculation_select_codes\']").hide();
+ }
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value != ""
+ && document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value == "") {
+ alert("AvaTax Company Code should not be empty.\n Click On Test Connection to get Company Codes");
+ return false;
+ }
+ });
+
+ $(".btn-primary").click(function() {
+ if (!validateFields()) { return false; }
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value == "") {
+ alert("AvaTax Company Code should not be empty.\n Click On Test Connection to get Company Codes");
+ return false;
+ } else {
+ var accountVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value;
+ var licenseVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value;
+ var serviceURLVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").value;
+ var isAvataxEnabled = $("[id^=\'addon_option_avatax_tax_calculation_avatax_tax_calculation\'] input[type=radio]:checked").val();
+ var isUPCOption = $("[id^=\'addon_option_avatax_tax_calculation_avatax_tax_upc\'] input[type=radio]:checked").val();
+ var isSaveTransaction = $("[id^=\'addon_option_avatax_tax_calculation_avatax_tax_savedoc\'] input[type=radio]:checked").val();
+ var isAddressValidation = $("[id^=\'addon_option_avatax_tax_calculation_avatax_tax_address_validation\'] input[type=radio]:checked").val();
+ var isLogEnabled = $("[id^=\'addon_option_avatax_tax_calculation_avatax_log_mode input\'][type=radio]:checked").val();
+ var companyCode = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value;
+ var environment = serviceURLVal.indexOf("development") > 0 ? "Development" : "Production";
+
+ $.ajax({
+ url:"?dispatch=avatax_tax_calculation.config_log&security_hash="+Tygh.security_hash+"&acc="+accountVal+"&license="+licenseVal+"&serviceurl="+serviceURLVal+"&environment="+environment+"&client=" + AVATAX_CLIENT + "&isAvataxEnabled="+isAvataxEnabled+"&isUPCOption="+isUPCOption+"&isSaveTransaction="+isSaveTransaction+"&isLogEnabled="+isLogEnabled+"&companyCode="+companyCode+"&isAddressValidation="+isAddressValidation,
+ success: function(result) {
+ //alert(result);
+ },
+ async: false,
+ type : "POST"
+ });
+ }
+ });
+
+ //Hide the company name and and code fields if it is not added
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value == "") {
+ $("[id^=\'container_addon_option_avatax_tax_calculation_avatax_company_code\']").hide();
+ }
+ $("[id^=\'container_addon_option_avatax_tax_calculation_select_codes\']").hide();
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").attr("readonly", "true");
+});
+
+if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value != "") {
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").on("input", function() {
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").val("");
+ $("[id^=\'container_addon_option_avatax_tax_calculation_avatax_company_code\']").hide();
+ $("[id^=\'container_addon_option_avatax_tax_calculation_select_codes\']").hide();
+ });
+}
+
+$("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").on("input", function() {
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").val("");
+ $("[id^=\'container_addon_option_avatax_tax_calculation_avatax_company_code\']").hide();
+ $("[id^=\'container_addon_option_avatax_tax_calculation_select_codes\']").hide();
+}) ;
+
+document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").addEventListener("change", function () {
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value = "";
+ $("[id^=\'container_addon_option_avatax_tax_calculation_avatax_company_code\']").hide();
+ $("[id^=\'container_addon_option_avatax_tax_calculation_select_codes\']").hide();
+});
+
+$("[id^=\'addon_option_avatax_tax_calculation_select_codes\']").change( function() {
+ $(this).find(":selected").each(function () {
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").val($(this).val());
+ });
+});
+
+document.getElementById("variant_avatax_tax_calculation_1").addEventListener("click", function() {
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value == "") {
+ alert("AvaTax Account ID should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").focus();
+ }
+ else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value == "") {
+ alert("AvaTax License Key should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").focus();
+ }
+ else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").value == "") {
+ alert("AvaTax Service URL should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").focus();
+ }
+ else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value == "") {
+ alert("AvaTax Company Code should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").focus();
+ }
+});
+
+document.getElementById("variant_avatax_tax_address_validation_1").addEventListener("click", function() {
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value == "") {
+ alert("AvaTax Account ID should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").focus();
+ }
+ else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value == "") {
+ alert("AvaTax License Key should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").focus();
+ }
+ else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").value == "") {
+ alert("AvaTax Service URL should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").focus();
+ }
+ else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").value == "") {
+ alert("AvaTax Company Name should not empty.");
+ document.getElementById("variant_avatax_tax_calculation_0").checked = true;
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").focus();
+ }
+});
+
+var devMode = document.getElementById("addon_option_avatax_tax_calculation_avatax_development_mode");
+if(devMode !== null) {
+ devMode.addEventListener("click", function() {
+ var selectedVal = "";
+ var selected = $('input[type="radio"][id="variant_avatax_development_mode_1"]:checked');
+ if (selected.length > 0) {
+ selectedValue = selected.val();
+ } else {
+ selected = $('input[type="radio"][id="variant_avatax_development_mode_0"]:checked');
+ if (selected.length > 0)
+ selectedValue = selected.val();
+ }
+
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").removeAttr("disabled");
+
+ if (selectedValue == 1)
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").val("https://development.avalara.net/");
+ else if (selectedValue == 0)
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").val("https://avatax.avalara.net");
+ });
+}
+
+document.getElementById("AvaTaxTestConnection").addEventListener("click", function() {
+ if (validateFields()) {
+ $("#AvaTaxTestConnectionDialog").html('
Work In Progress...
');
+ $("#AvaTaxTestConnectionDialog").dialog({
+ width:350,
+ height:200,
+ buttons: {
+ "OK": function() {
+ $( this ).dialog( "close" );
+ }
+ },
+ open: function( event, ui ) {
+ if (!$("#AvaTaxTestConnectionDialog").parent().hasClass("ui-dailog-inner"))
+ $("#AvaTaxTestConnectionDialog").parent().addClass("ui-dailog-inner");
+ }
+ });
+ var accountVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value;
+ var licenseVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value;
+ var serviceURLVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").value;
+
+ var environment = serviceURLVal.indexOf("development") > 0 ? "Development" : "Production";
+
+ $.post("?dispatch=avatax_tax_calculation.connection_test&security_hash="+Tygh.security_hash+"&from=AvaTaxConnectionTest&acc="+accountVal+"&license="+licenseVal+"&serviceurl="+serviceURLVal+"&environment="+environment+"&client=" + AVATAX_CLIENT, {q: ""}, function(data) {
+ if (data.length > 0) {
+ $("#AvaTaxTestConnectionDialog").html(data);
+ if (!data.match(/Failed/gi)) {
+ showCompanyFields();
+ validateCompany();
+ } else {
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").val("");
+ $("[id^=\'container_addon_option_avatax_tax_calculation_avatax_company_code\']").hide();
+ }
+ }
+ });
+ }
+});
+
+function validateFields() {
+ if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value == "") {
+ alert("Please enter AvaTax Account ID!");
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").focus();
+ return false;
+ } else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value.length!=10) {
+ alert("AvaTax Account ID should not be less than or greater than 10 digits!");
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").focus();
+ return false;
+ } else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value == "") {
+ alert("Please enter AvaTax License Key");
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").focus();
+ return false;
+ } else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value.length!=16) {
+ alert("AvaTax License Key should not be less than or greater than 16 chars");
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").focus();
+ return false;
+ } else if (document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").value == "") {
+ alert("Please enter AvaTax Service URL");
+ document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").focus();
+ return false;
+ }
+
+ return true;
+}
+
+function showCompanyFields() {
+ $("[id^=\'addon_option_avatax_tax_calculation_avatax_company_code\']").attr("readonly", "true");
+ $("[id^=\'container_addon_option_avatax_tax_calculation_avatax_company_code\']").show();
+ $("[id^=\'container_addon_option_avatax_tax_calculation_select_codes\']").show();
+}
+
+function validateCompany() {
+
+ var accountVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_account_number\']").value;
+ var licenseVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_license_key\']").value;
+ var serviceURLVal = document.querySelector("[id^=\'addon_option_avatax_tax_calculation_avatax_service_url\']").value;
+
+ var environment = serviceURLVal.indexOf("development") ? "Development" : "Production";
+
+ $.post("?dispatch=avatax_tax_calculation.setup_assistant&security_hash="+Tygh.security_hash+"&from=AvaTaxFetchCompanies&acc="+accountVal+"&license="+licenseVal+"&serviceurl="+serviceURLVal+"&environment="+environment+"&client=" + AVATAX_CLIENT, {q: ""}, function(data) {
+ if (data.length > 0) {
+ var accountsData = JSON.parse(data);
+ $("[id^=\'addon_option_avatax_tax_calculation_select_codes\']").find("option").remove();
+ var _select="";
+ _select = $("
+Avalara AvaTax for CS-Cart Version 00.00.12.00 is compatible with CS-Cart versions:
+
+
4.12.2
+
4.12.1
+
4.11.5
+
4.11.4
+
4.11.3
+
4.11.2
+
4.11.1
+
Documentation
Release notes can be accessed here
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000..c861bff
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,19 @@
+trigger:
+- master
+
+pool:
+ vmImage: ubuntu-latest
+
+steps:
+- task: ArchiveFiles@1
+ inputs:
+ rootFolderOrFile: '$(Build.BinariesDirectory)'
+ includeRootFolder: false
+ archiveType: 'zip'
+ archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
+ replaceExistingArchive: true
+- task: PublishBuildArtifacts@1
+ inputs:
+ PathtoPublish: '$(Build.ArtifactStagingDirectory)'
+ ArtifactName: 'AvaTax'
+ publishLocation: 'Container'
\ No newline at end of file