0
Hi Support,
Please we have errors in the stock quantity of different product. Every minute of each day the stock quantity keep changing. I believe this is a bug.
Please see attached images for details
What could be the course and how can it be resolved please.
Thank you
0
0
Hello @Enyinnaya Gift and @Michael Nwuzor,
I have update the demo with fixed. Can you guys help me check now.
Thank you
0
Mian Saleem This is ok, but it will call resetSaleActions()
function each time a sale status update button is clicked and I don't see a need for that. Having it as a condition that resetSaleActions()
function is only called when there is a change in the current sale status is better.
0
Mian Saleem Well done, I have checked the fix on the demo for both issues, and it is working fine now. But still, consider my suggestion on only calling the resetSaleActions()
function when there is a change in the current sale status.
0
Enyinnaya Gift Yes, you are right. I have reset the updateStatus
as you suggested.
Methods looks like this now
public function updateStatus($id, $status, $note)
{
$this->db->trans_start();
$sale = $this->getInvoiceByID($id);
$items = $this->getAllInvoiceItems($id);
$cost = [];
if ($status == 'completed' && $sale->sale_status != 'completed') {
foreach ($items as $item) {
$items_array[] = (array) $item;
}
$cost = $this->site->costing($items_array);
}
if ($status != 'completed' && $sale->sale_status == 'completed') {
$this->resetSaleActions($id);
}
if ($this->db->update('sales', ['sale_status' => $status, 'note' => $note], ['id' => $id])) {
if ($status == 'completed' && $sale->sale_status != 'completed') {
$this->db->delete('costing', ['sale_id' => $id]);
foreach ($items as $item) {
$item = (array) $item;
if ($this->site->getProductByID($item['product_id'])) {
$item_costs = $this->site->item_costing($item);
foreach ($item_costs as $item_cost) {
if (isset($item_cost['date']) || isset($item_cost['pi_overselling'])) {
$item_cost['sale_item_id'] = $item['id'];
$item_cost['sale_id'] = $id;
$item_cost['date'] = date('Y-m-d', strtotime($sale->date));
if (!isset($item_cost['pi_overselling'])) {
$this->db->insert('costing', $item_cost);
}
} else {
foreach ($item_cost as $ic) {
$ic['sale_item_id'] = $item['id'];
$ic['sale_id'] = $id;
$ic['date'] = date('Y-m-d', strtotime($sale->date));
if (!isset($ic['pi_overselling'])) {
$this->db->insert('costing', $ic);
}
}
}
}
}
}
if (!empty($cost)) {
$this->site->syncPurchaseItems($cost);
}
$this->site->syncQuantity($id);
}
}
$this->db->trans_complete();
if ($this->db->trans_status() === false) {
log_message('error', 'An errors has been occurred while adding the sale (UpdataStatus:Sales_model.php)');
} else {
return true;
}
return false;
}
Thank you for help
0
Mian Saleem Great! Well done.
Please, let me know when you push the update, I told some customers that contacted me on this issue to hold on for the update.
0
Hello,
I have released the update with fixes.
Thank you
Showing 11 to 17 of total 17 records
We use Cookies
We use cookies to ensure that we give you the best experience on our website. By continuing to browse the site you are agreeing to our use of cookies.