mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-07-27 15:17:09 -04:00
Refactor save_customer method to saveCustomer for PSR compliance
Signed-off-by: objec <objecttothis@gmail.com>
This commit is contained in:
@@ -231,7 +231,7 @@ class Customers extends Persons
|
||||
'sales_tax_code_id' => $this->request->getPost('sales_tax_code_id') == '' ? null : $this->request->getPost('sales_tax_code_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
if ($this->customer->save_customer($personData, $customerData, $customerId)) {
|
||||
if ($this->customer->saveCustomer($personData, $customerData, $customerId)) {
|
||||
Events::trigger('customer_saved', $customerData);
|
||||
|
||||
// New customer
|
||||
@@ -400,7 +400,7 @@ class Customers extends Persons
|
||||
if ($invalidated) {
|
||||
$failCodes[] = $rowNumber;
|
||||
log_message('error', "Row $rowNumber was not imported: Either email or account number already exist or data was invalid.");
|
||||
} elseif ($this->customer->save_customer($person_data, $customer_data)) {
|
||||
} elseif ($this->customer->saveCustomer($person_data, $customer_data)) {
|
||||
Events::trigger('customer_saved', $person_data);
|
||||
} else {
|
||||
$failCodes[] = $rowNumber;
|
||||
|
||||
@@ -210,28 +210,26 @@ class Customer extends Person
|
||||
/**
|
||||
* Inserts or updates a customer
|
||||
*/
|
||||
public function save_customer(array &$person_data, array &$customer_data, int $customer_id = NEW_ENTRY): bool
|
||||
public function saveCustomer(array &$personData, array &$customerData, int $customerId = NEW_ENTRY): bool
|
||||
{
|
||||
$success = false;
|
||||
$this->db->transStart();
|
||||
|
||||
if (parent::save_value($person_data, $customer_id)) {
|
||||
if (parent::save_value($personData, $customerId)) {
|
||||
$builder = $this->db->table('customers');
|
||||
if ($customer_id == NEW_ENTRY || !$customer_id || !$this->exists($customer_id)) {
|
||||
$customer_data['person_id'] = $person_data['person_id'];
|
||||
$success = $builder->insert($customer_data);
|
||||
if ($customerId == NEW_ENTRY || !$customerId || !$this->exists($customerId)) {
|
||||
$customerData['person_id'] = $personData['person_id'];
|
||||
$success = $builder->insert($customerData);
|
||||
} else {
|
||||
$builder->where('person_id', $customer_id);
|
||||
$success = $builder->update($customer_data);
|
||||
$customer_data['person_id'] = $customer_id;
|
||||
$builder->where('person_id', $customerId);
|
||||
$success = $builder->update($customerData);
|
||||
$customerData['person_id'] = $customerId;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
$success &= $this->db->transStatus();
|
||||
|
||||
return $success;
|
||||
return $success && $this->db->transStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user