mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-20 07:14:33 -04:00
Make the payment type change a unique transaction in the model (#314)
This commit is contained in:
1 parent
9f808dafde
commit
ae5d23f77d
1 file changed
+7
@@ -248,6 +248,9 @@ class Sale extends CI_Model
|
||||
// touch payment only if update sale is successful and there is a payments object otherwise the result would be to delete all the payments associated to the sale
|
||||
if($success && !empty($payments))
|
||||
{
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->trans_start();
|
||||
|
||||
// first delete all payments
|
||||
$this->db->delete('sales_payments', array('sale_id'=>$sale_id));
|
||||
|
||||
@@ -262,6 +265,10 @@ class Sale extends CI_Model
|
||||
|
||||
$success = $this->db->insert('sales_payments', $sales_payments_data);
|
||||
}
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
$success = $this->db->trans_status();
|
||||
}
|
||||
|
||||
return $success;
|
||||
|
||||
Reference in new issue
Block a user