Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task #160337 chore: Getting Fatal Error while using vendorList field #82

Open
wants to merge 8 commits into
base: release-1.4.4
Choose a base branch
from
81 changes: 1 addition & 80 deletions src/com_tjvendors/admin/models/payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function loadFormData()
*
* @param Array $data Data
*
* @return id
* @return boolean
*/
public function save($data)
{
Expand Down Expand Up @@ -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
*
Expand Down
69 changes: 0 additions & 69 deletions src/com_tjvendors/site/helpers/fronthelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Loading