From f22b5917e4c7b6d5489037d1beea03cb1b2557c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDeepa?= <“deepgawade89@gmail.com”> Date: Thu, 23 Apr 2020 17:54:58 +0530 Subject: [PATCH 1/6] Task #160337 chore: Moving isClientExist() function helper to class file --- .../admin/models/fields/vendorslist.php | 3 +- .../site/helpers/fronthelper.php | 32 ------------------- src/com_tjvendors/site/includes/vendor.php | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/com_tjvendors/admin/models/fields/vendorslist.php b/src/com_tjvendors/admin/models/fields/vendorslist.php index facbab78..ec1b31b0 100644 --- a/src/com_tjvendors/admin/models/fields/vendorslist.php +++ b/src/com_tjvendors/admin/models/fields/vendorslist.php @@ -13,9 +13,10 @@ use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; jimport('joomla.form.helper'); -\FormHelper::loadFieldClass('list'); +FormHelper::loadFieldClass('list'); /** * Supports an HTML select list of vendors diff --git a/src/com_tjvendors/site/helpers/fronthelper.php b/src/com_tjvendors/site/helpers/fronthelper.php index 1e905ac6..722ae65c 100644 --- a/src/com_tjvendors/site/helpers/fronthelper.php +++ b/src/com_tjvendors/site/helpers/fronthelper.php @@ -633,36 +633,4 @@ public function getPaymentGatewayConfig($vendorId, $client = "", $global = true) Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); } } - - /** - * Get client name - * - * @param string $client client - * @param integer $vendorId Venodor ID - * - * @return Boolean Client exist or not - * - * @since 1.3.0 - */ - public function isClientExist($client, $vendorId) - { - $db = Factory::getDbo(); - $query = $db->getQuery(true); - $query->select('client'); - $query->from($db->quoteName('#__vendor_client_xref')); - $query->where($db->quoteName('client') . ' = ' . $db->quote($client)); - $query->where($db->quoteName('vendor_id') . ' = ' . (int) $vendorId); - $db->setQuery($query); - - $return = $db->loadResult(); - - if ($return) - { - return true; - } - else - { - return false; - } - } } diff --git a/src/com_tjvendors/site/includes/vendor.php b/src/com_tjvendors/site/includes/vendor.php index b00f1f8d..873e44dc 100644 --- a/src/com_tjvendors/site/includes/vendor.php +++ b/src/com_tjvendors/site/includes/vendor.php @@ -615,4 +615,36 @@ public function getVendorProfileStatus($userId, $client) return $total; } + + /** + * Get client name + * + * @param string $client client + * @param integer $vendorId Venodor ID + * + * @return Boolean Client exist or not + * + * @since 1.3.0 + */ + public function isClientExist($client, $vendorId) + { + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $query->select('client'); + $query->from($db->quoteName('#__vendor_client_xref')); + $query->where($db->quoteName('client') . ' = ' . $db->quote($client)); + $query->where($db->quoteName('vendor_id') . ' = ' . (int) $vendorId); + $db->setQuery($query); + + $return = $db->loadResult(); + + if ($return) + { + return true; + } + else + { + return false; + } + } } From a8c48c2a169aaef67618b3d5d263dd818e6e8bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDeepa?= <“deepgawade89@gmail.com”> Date: Tue, 28 Apr 2020 12:09:00 +0530 Subject: [PATCH 2/6] Task #160337 chore: No More helper : Moving isClientExist() function from helper to class file --- .../site/helpers/fronthelper.php | 32 +++++++++++++++++++ src/com_tjvendors/site/includes/vendor.php | 32 ------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/com_tjvendors/site/helpers/fronthelper.php b/src/com_tjvendors/site/helpers/fronthelper.php index 722ae65c..1e905ac6 100644 --- a/src/com_tjvendors/site/helpers/fronthelper.php +++ b/src/com_tjvendors/site/helpers/fronthelper.php @@ -633,4 +633,36 @@ public function getPaymentGatewayConfig($vendorId, $client = "", $global = true) Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); } } + + /** + * Get client name + * + * @param string $client client + * @param integer $vendorId Venodor ID + * + * @return Boolean Client exist or not + * + * @since 1.3.0 + */ + public function isClientExist($client, $vendorId) + { + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $query->select('client'); + $query->from($db->quoteName('#__vendor_client_xref')); + $query->where($db->quoteName('client') . ' = ' . $db->quote($client)); + $query->where($db->quoteName('vendor_id') . ' = ' . (int) $vendorId); + $db->setQuery($query); + + $return = $db->loadResult(); + + if ($return) + { + return true; + } + else + { + return false; + } + } } diff --git a/src/com_tjvendors/site/includes/vendor.php b/src/com_tjvendors/site/includes/vendor.php index 873e44dc..b00f1f8d 100644 --- a/src/com_tjvendors/site/includes/vendor.php +++ b/src/com_tjvendors/site/includes/vendor.php @@ -615,36 +615,4 @@ public function getVendorProfileStatus($userId, $client) return $total; } - - /** - * Get client name - * - * @param string $client client - * @param integer $vendorId Venodor ID - * - * @return Boolean Client exist or not - * - * @since 1.3.0 - */ - public function isClientExist($client, $vendorId) - { - $db = Factory::getDbo(); - $query = $db->getQuery(true); - $query->select('client'); - $query->from($db->quoteName('#__vendor_client_xref')); - $query->where($db->quoteName('client') . ' = ' . $db->quote($client)); - $query->where($db->quoteName('vendor_id') . ' = ' . (int) $vendorId); - $db->setQuery($query); - - $return = $db->loadResult(); - - if ($return) - { - return true; - } - else - { - return false; - } - } } From fe508c466b8e6395cf5af3203c2c422ee0aa6c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDeepa?= <“deepgawade89@gmail.com”> Date: Wed, 29 Apr 2020 12:11:14 +0530 Subject: [PATCH 3/6] Bug #158772 chore: On after donation from admin side the payout entry didn't received --- .../site/helpers/fronthelper.php | 69 --- src/com_tjvendors/site/includes/payout.php | 427 ++++++++++++++++++ 2 files changed, 427 insertions(+), 69 deletions(-) create mode 100644 src/com_tjvendors/site/includes/payout.php diff --git a/src/com_tjvendors/site/helpers/fronthelper.php b/src/com_tjvendors/site/helpers/fronthelper.php index 1e905ac6..342a5878 100644 --- a/src/com_tjvendors/site/helpers/fronthelper.php +++ b/src/com_tjvendors/site/helpers/fronthelper.php @@ -387,75 +387,6 @@ public function checkGatewayDetails($userId, $client) } } - /** - * function for adding credit entry - * - * @param integer $order_data integer - * - * @return void - * - * @since 1.0 - */ - public function addEntry($order_data) - { - $com_params = ComponentHelper::getParams($order_data['client']); - $vendorParams = ComponentHelper::getParams('com_tjvendors'); - $payout_day_limit = $vendorParams->get('payout_limit_days', '0', 'INT'); - $date = Factory::getDate(); - $payout_date_limit = $date->modify("-" . $payout_day_limit . " day"); - $currency = $com_params->get('currency'); - - $payoutTable = Table::getInstance('payout', 'TjvendorsTable', array()); - $payoutTable->load(array('reference_order_id' => $order_data['order_id'])); - - if ($payoutTable->debit > 0) - { - $checkOrderPayout = $payoutTable->order_id; - } - else - { - $checkOrderPayout = false; - } - - $entry_data['vendor_id'] = $order_data['vendor_id']; - $totalAmount = TjvendorsHelper::getTotalAmount($entry_data['vendor_id'], $currency, $order_data['client']); - $entry_data['reference_order_id'] = $order_data['order_id']; - $entry_data['transaction_id'] = $order_data['client_name'] . '-' . $currency . '-' . $entry_data['vendor_id'] . '-'; - $entry_data['transaction_time'] = Factory::getDate()->toSql(); - - if ($order_data['status'] != "C") - { - if ($order_data['status'] == "RF") - { - $entry_status = "debit_refund"; - } - elseif ($order_data['status'] == "P") - { - $entry_status = "debit_pending"; - } - - $entry_data['debit'] = $order_data['amount'] - $order_data['fee_amount']; - $entry_data['credit'] = '0.00'; - $entry_data['total'] = $totalAmount['total'] - $entry_data['debit']; - } - - elseif ($order_data['status'] == "C") - { - $entry_data['credit'] = $order_data['amount'] - $order_data['fee_amount']; - $entry_data['debit'] = 0; - $entry_data['total'] = $totalAmount['total'] + $entry_data['credit']; - $entry_status = "credit_for_ticket_buy"; - } - - $params = array("customer_note" => $order_data['customer_note'], "entry_status" => $entry_status); - $entry_data['params'] = json_encode($params); - $entry_data['currency'] = $currency; - $entry_data['client'] = $order_data['client']; - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjvendors/models', 'payout'); - $tjvendorsModelPayout = BaseDatabaseModel::getInstance('Payout', 'TjvendorsModel'); - $vendorDetail = $tjvendorsModelPayout->addCreditEntry($entry_data); - } - /** * Get paid amount * diff --git a/src/com_tjvendors/site/includes/payout.php b/src/com_tjvendors/site/includes/payout.php new file mode 100644 index 00000000..d5f7e777 --- /dev/null +++ b/src/com_tjvendors/site/includes/payout.php @@ -0,0 +1,427 @@ + + * @copyright Copyright (C) 2009 - 2020 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die(); + +use Joomla\CMS\Factory; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; + +/** + * Payout class. + * + * This class hold the property of the vendor entity and perform the appropriate operations + * + * @since __DEPLOY_VERSION__ + */ +class TjvendorsPayout extends CMSObject +{ + /** + * primary key of the payout record. + * + * @var int + * @since __DEPLOY_VERSION__ + */ + public $id = 0; + + /** + * primary key of the vendor table + * + * @var int + * @since __DEPLOY_VERSION__ + */ + private $vendor_id = 0; + + /** + * Currency. + * + * @var String + * @since __DEPLOY_VERSION__ + */ + private $currency = ''; + + /** + * Total amount. + * + * @since __DEPLOY_VERSION__ + */ + private $total = 0; + + /** + * Credit amount. + * + * @since __DEPLOY_VERSION__ + */ + private $credit = 0; + + /** + * Debited amount + * + * @since __DEPLOY_VERSION__ + */ + private $debit = 0; + + /** + * Reference order id after payout given. + * + * @var String + * @since __DEPLOY_VERSION__ + */ + private $reference_order_id = ''; + + /** + * The other_city of the vendor. + * + * @var String + * @since __DEPLOY_VERSION__ + */ + private $transaction_time = ''; + + /** + * Integrated component client name eg. com_tjlms, com_jticketing + * + * @var string + * @since __DEPLOY_VERSION__ + */ + private $client = ''; + + /** + * Transaction Id after payout processed. + * + * @var String + * @since __DEPLOY_VERSION__ + */ + private $transaction_id = ''; + + /** + * Status of the passbook record + * + * @var int + * @since __DEPLOY_VERSION__ + */ + private $status = 1; + + /** + * Hold the other required information in the JSON format + * + * @var string + * @since __DEPLOY_VERSION__ + */ + private $params = ''; + + /** + * Holds the already loaded instances of the passbook + * + * @var array + * @since __DEPLOY_VERSION__ + */ + protected static $payoutObj = array(); + + /** + * Constructor activating the default information of the payout + * + * @param int $id The unique passbook id to load. + * + * @since __DEPLOY_VERSION__ + */ + public function __construct($id = 0) + { + if (!empty($id)) + { + $this->load($id); + } + } + + /** + * Returns the global passbook object + * + * @param integer $id The primary key of the passbook to load (optional). + * + * @return TjvendorsVendor The vendor object. + * + * @since __DEPLOY_VERSION__ + */ + public static function getInstance($id = 0) + { + if (!$id) + { + return new TjvendorsPayout; + } + + if (empty(self::$payoutObj[$id])) + { + self::$payoutObj[$id] = new TjvendorsPayout($id); + } + + return self::$payoutObj[$id]; + } + + /** + * Method to load a passbook properties + * + * @param int $id The Passbook id whose properties need to load while creating object + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function load($id) + { + $table = TJVendors::table("payout"); + + if (!$table->load($id)) + { + return false; + } + + $this->id = (int) $table->get('id'); + $this->vendor_id = (int) $table->get('vendor_id'); + $this->currency = $table->get('currency'); + $this->total = $table->get('total'); + $this->credit = $table->get('credit'); + $this->debit = $table->get('debit'); + $this->reference_order_id = $table->get('reference_order_id'); + $this->transaction_time = $table->get('transaction_time'); + $this->client = $table->get('client'); + $this->transaction_id = $table->get('transaction_id'); + $this->status = $table->get('status'); + $this->params = $table->get('params'); + + $this->setClient($client); + + return true; + } + + /** + * Method to return all the key and values of all properties + * + * @param boolean $public If true, returns only the public properties. + * + * @return array + * + * @since __DEPLOY_VERSION__ + */ + public function getProperties($public = true) + { + return get_object_vars($this); + } + + /** + * Method to get the id + * + * @return integer return the id. + * + * @since __DEPLOY_VERSION__ + */ + public function getId() + { + return $this->id; + } + + /** + * Method to get the vendor id + * + * @return integer return the vendor id. + * + * @since __DEPLOY_VERSION__ + */ + public function getVendorId() + { + return $this->vendor_id; + } + + /** + * Method to get the currency + * + * @return string return the currency + * + * @since __DEPLOY_VERSION__ + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Method to get the total amount + * + * @return double return the total + * + * @since __DEPLOY_VERSION__ + */ + public function getTotal() + { + return $this->total; + } + + /** + * Method to get the credit amount + * + * @return double return the credit + * + * @since __DEPLOY_VERSION__ + */ + public function getCredit() + { + return $this->credit; + } + + /** + * Method to get the debit amount + * + * @return double return the debit + * + * @since __DEPLOY_VERSION__ + */ + public function getDebit() + { + return $this->debit; + } + + /** + * Method to get the reference order id + * + * @return string return the reference order id + * + * @since __DEPLOY_VERSION__ + */ + public function getReferenceOrderId() + { + return $this->reference_order_id; + } + + /** + * Method to get the transaction time + * + * @return string return the transaction time + * + * @since __DEPLOY_VERSION__ + */ + public function getTransactionTime() + { + return $this->transaction_time; + } + + /** + * Method to get the client + * + * @return string return the client + * + * @since __DEPLOY_VERSION__ + */ + public function getClient() + { + return $this->client; + } + + /** + * Method to get the transaction_id + * + * @return string return the transaction_id + * + * @since __DEPLOY_VERSION__ + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * Method to get the status + * + * @return integer return the status + * + * @since __DEPLOY_VERSION__ + */ + public function getStatus() + { + return $this->status; + } + + /** + * Method to get the params + * + * @return string return the params + * + * @since __DEPLOY_VERSION__ + */ + public function getParams() + { + return $this->params; + } + + /** + * Function for adding credit entry + * + * @param array $orderData Order data + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function addEntry($orderData) + { + $com_params = ComponentHelper::getParams($orderData['client']); + $currency = $com_params->get('currency'); + $vendorParams = TJVendors::config(); + $payoutDayLimit = $vendorParams->get('payout_limit_days', 0, 'INT'); + $date = Factory::getDate(); + $payoutDayLimit = $date->modify("-" . $payoutDayLimit . " day"); + $checkOrderPayout = false; + $payoutTable = Table::getInstance('payout', 'TjvendorsTable', array()); + $payoutTable->load(array('reference_order_id' => $orderData['order_id'])); + + if ($payoutTable->debit > 0) + { + $checkOrderPayout = $payoutTable->order_id; + } + + $entryData['vendor_id'] = $orderData['vendor_id']; + $totalAmount = TjvendorsHelper::getTotalAmount($entryData['vendor_id'], $currency, $orderData['client']); + $entryData['reference_order_id'] = $orderData['order_id']; + $entryData['transaction_id'] = $orderData['client_name'] . '-' . $currency . '-' . $entryData['vendor_id'] . '-'; + $entryData['transaction_time'] = $date->toSql(); + + if ($orderData['status'] != "C") + { + if ($orderData['status'] == "RF") + { + $entry_status = "debit_refund"; + } + elseif ($orderData['status'] == "P") + { + $entry_status = "debit_pending"; + } + + $entryData['debit'] = $orderData['amount'] - $orderData['fee_amount']; + $entryData['credit'] = '0.00'; + $entryData['total'] = $totalAmount['total'] - $entryData['debit']; + } + else + { + $entryData['debit'] = 0; + $entryData['credit'] = $orderData['amount'] - $orderData['fee_amount']; + $entryData['total'] = $totalAmount['total'] + $entryData['credit']; + $entry_status = "credit_for_ticket_buy"; + } + + $params = array("customer_note" => $orderData['customer_note'], "entry_status" => $entry_status); + $entryData['params'] = json_encode($params); + $entryData['currency'] = $currency; + $entryData['client'] = $orderData['client']; + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjvendors/models', 'payout'); + $tjvendorsModelPayout = BaseDatabaseModel::getInstance('Payout', 'TjvendorsModel'); + $vendorDetail = $tjvendorsModelPayout->addCreditEntry($entryData); + } +} From 18548819c72b7ffbc9a059ac1d9d5470ce2d4a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDeepa?= <“deepgawade89@gmail.com”> Date: Thu, 30 Apr 2020 17:30:41 +0530 Subject: [PATCH 4/6] Task #160337 chore: Getting Fatal Error while using vendorList field --- src/com_tjvendors/site/includes/payout.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com_tjvendors/site/includes/payout.php b/src/com_tjvendors/site/includes/payout.php index d5f7e777..e65f2e6b 100644 --- a/src/com_tjvendors/site/includes/payout.php +++ b/src/com_tjvendors/site/includes/payout.php @@ -21,7 +21,7 @@ /** * Payout class. * - * This class hold the property of the vendor entity and perform the appropriate operations + * This class hold the property of the vendor payout entity and perform the appropriate operations * * @since __DEPLOY_VERSION__ */ @@ -81,7 +81,7 @@ class TjvendorsPayout extends CMSObject private $reference_order_id = ''; /** - * The other_city of the vendor. + * Transaction time. * * @var String * @since __DEPLOY_VERSION__ @@ -89,7 +89,7 @@ class TjvendorsPayout extends CMSObject private $transaction_time = ''; /** - * Integrated component client name eg. com_tjlms, com_jticketing + * Integrated component client name eg. com_tjlms, com_jticketing, com_jgive * * @var string * @since __DEPLOY_VERSION__ @@ -372,8 +372,8 @@ public function getParams() */ public function addEntry($orderData) { - $com_params = ComponentHelper::getParams($orderData['client']); - $currency = $com_params->get('currency'); + $clientParams = ComponentHelper::getParams($orderData['client']); + $currency = $clientParams->get('currency'); $vendorParams = TJVendors::config(); $payoutDayLimit = $vendorParams->get('payout_limit_days', 0, 'INT'); $date = Factory::getDate(); From a27883479a8ab39b603a26b206a2c6899ea8f3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDeepa?= <“deepgawade89@gmail.com”> Date: Thu, 30 Apr 2020 22:34:01 +0530 Subject: [PATCH 5/6] Task #160337 chore: Getting Fatal Error while using vendorList field --- src/com_tjvendors/admin/models/payout.php | 79 ---------------------- src/com_tjvendors/site/includes/payout.php | 78 ++++++++++++++++++++- 2 files changed, 75 insertions(+), 82 deletions(-) diff --git a/src/com_tjvendors/admin/models/payout.php b/src/com_tjvendors/admin/models/payout.php index d3e4dcdd..5cd4b013 100644 --- a/src/com_tjvendors/admin/models/payout.php +++ b/src/com_tjvendors/admin/models/payout.php @@ -239,85 +239,6 @@ public function save($data) return false; } - /** - * Method to get the data that should be injected in the form. - * - * @param array $data An optional array of data for the form to interogate. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - public function updatingCreditData($data) - { - $payout_detail = TjvendorsHelper::getTotalAmount($data['vendor_id'], $data['currency'], $data['client']); - $payout_id = $payout_detail['id']; - $object = new stdClass; - - // Must be a valid primary key value. - $object->id = $payout_id; - $object->transaction_id = $data['transaction_id'] . $object->id; - - try - { - // Update their details in the users table using id as the primary key. - $result = Factory::getDbo()->updateObject('#__tjvendors_passbook', $object, 'id'); - } - catch (Exception $e) - { - Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); - } - - if (empty($result)) - { - return false; - } - } - - /** - * Method to add the amount when a product is purchased. - * - * @param array $data data of order - * - * @return boolean - * - * @since 1.6 - */ - public function addCreditEntry($data) - { - $creditEntry = new stdClass; - $creditEntry->vendor_id = $data['vendor_id']; - $creditEntry->currency = $data['currency']; - $creditEntry->total = $data['total']; - $creditEntry->credit = $data['credit']; - $creditEntry->debit = $data['debit']; - $creditEntry->reference_order_id = $data['reference_order_id']; - $creditEntry->transaction_time = $data['transaction_time']; - $creditEntry->client = $data['client']; - $creditEntry->transaction_id = $data['transaction_id']; - $creditEntry->params = $data['params']; - - try - { - // Insert the object into the passbook table. - $result = Factory::getDbo()->insertObject('#__tjvendors_passbook', $creditEntry); - } - catch (Exception $e) - { - Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); - } - - if (empty($result)) - { - return false; - } - - if ($result) - { - $this->updatingCreditData($data); - } - } - /** * Method to change payout status * diff --git a/src/com_tjvendors/site/includes/payout.php b/src/com_tjvendors/site/includes/payout.php index e65f2e6b..3c76f6a1 100644 --- a/src/com_tjvendors/site/includes/payout.php +++ b/src/com_tjvendors/site/includes/payout.php @@ -420,8 +420,80 @@ public function addEntry($orderData) $entryData['params'] = json_encode($params); $entryData['currency'] = $currency; $entryData['client'] = $orderData['client']; - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjvendors/models', 'payout'); - $tjvendorsModelPayout = BaseDatabaseModel::getInstance('Payout', 'TjvendorsModel'); - $vendorDetail = $tjvendorsModelPayout->addCreditEntry($entryData); + $vendorDetail = $this->addCreditEntry($entryData); + } + + /** + * Method to add the amount when a product is purchased. + * + * @param array $data data of order + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function addCreditEntry($data) + { + $creditEntry = new stdClass; + $creditEntry->vendor_id = $data['vendor_id']; + $creditEntry->currency = $data['currency']; + $creditEntry->total = $data['total']; + $creditEntry->credit = $data['credit']; + $creditEntry->debit = $data['debit']; + $creditEntry->reference_order_id = $data['reference_order_id']; + $creditEntry->transaction_time = $data['transaction_time']; + $creditEntry->client = $data['client']; + $creditEntry->transaction_id = $data['transaction_id']; + $creditEntry->params = $data['params']; + + try + { + // Insert the object into the passbook table. + $result = Factory::getDbo()->insertObject('#__tjvendors_passbook', $creditEntry); + } + catch (Exception $e) + { + Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); + } + + if (empty($result)) + { + return false; + } + + $this->updatingCreditData($data); + } + + /** + * Method to get the data that should be injected in the form. + * + * @param array $data An optional array of data for the form to interogate. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + public function updatingCreditData($data) + { + $payout_detail = TjvendorsHelper::getTotalAmount($data['vendor_id'], $data['currency'], $data['client']); + + $object = new stdClass; + $object->id = $payout_detail['id']; + $object->transaction_id = $data['transaction_id'] . $object->id; + + try + { + // Update their details in the users table using id as the primary key. + $result = Factory::getDbo()->updateObject('#__tjvendors_passbook', $object, 'id'); + } + catch (Exception $e) + { + Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); + } + + if (empty($result)) + { + return false; + } } } From 3e7ce1b322d857d30a6dbe843935a5c0d54d9e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDeepa?= <“deepgawade89@gmail.com”> Date: Fri, 1 May 2020 15:25:41 +0530 Subject: [PATCH 6/6] Task #160337 chore: Getting Fatal Error while using vendorList field --- src/com_tjvendors/admin/models/payout.php | 2 +- src/com_tjvendors/site/includes/payout.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com_tjvendors/admin/models/payout.php b/src/com_tjvendors/admin/models/payout.php index 5cd4b013..84e4d056 100644 --- a/src/com_tjvendors/admin/models/payout.php +++ b/src/com_tjvendors/admin/models/payout.php @@ -145,7 +145,7 @@ protected function loadFormData() * * @param Array $data Data * - * @return id + * @return boolean */ public function save($data) { diff --git a/src/com_tjvendors/site/includes/payout.php b/src/com_tjvendors/site/includes/payout.php index 3c76f6a1..d9f209d3 100644 --- a/src/com_tjvendors/site/includes/payout.php +++ b/src/com_tjvendors/site/includes/payout.php @@ -13,6 +13,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; use Joomla\Registry\Registry; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Component\ComponentHelper; @@ -148,7 +149,7 @@ public function __construct($id = 0) * * @param integer $id The primary key of the passbook to load (optional). * - * @return TjvendorsVendor The vendor object. + * @return TjvendorsPayout The payout object. * * @since __DEPLOY_VERSION__ */ @@ -198,8 +199,6 @@ public function load($id) $this->status = $table->get('status'); $this->params = $table->get('params'); - $this->setClient($client); - return true; } @@ -375,18 +374,20 @@ public function addEntry($orderData) $clientParams = ComponentHelper::getParams($orderData['client']); $currency = $clientParams->get('currency'); $vendorParams = TJVendors::config(); - $payoutDayLimit = $vendorParams->get('payout_limit_days', 0, 'INT'); $date = Factory::getDate(); - $payoutDayLimit = $date->modify("-" . $payoutDayLimit . " day"); - $checkOrderPayout = false; + $date->modify("-" . $vendorParams->get('payout_limit_days', 0, 'INT') . " day"); + $payoutTable = Table::getInstance('payout', 'TjvendorsTable', array()); $payoutTable->load(array('reference_order_id' => $orderData['order_id'])); + $checkOrderPayout = false; + if ($payoutTable->debit > 0) { $checkOrderPayout = $payoutTable->order_id; } + $entryData = array(); $entryData['vendor_id'] = $orderData['vendor_id']; $totalAmount = TjvendorsHelper::getTotalAmount($entryData['vendor_id'], $currency, $orderData['client']); $entryData['reference_order_id'] = $orderData['order_id']; @@ -420,7 +421,7 @@ public function addEntry($orderData) $entryData['params'] = json_encode($params); $entryData['currency'] = $currency; $entryData['client'] = $orderData['client']; - $vendorDetail = $this->addCreditEntry($entryData); + $this->addCreditEntry($entryData); } /**