From b29ba9f2250795c8ce4298800480ed48a2e9973b Mon Sep 17 00:00:00 2001 From: bintanghr Date: Thu, 9 Jul 2026 15:47:24 +0700 Subject: [PATCH] add: inventaris coa mapping API --- .../controllers/map/InventarisCoaMapping.http | 58 ++++++ .../controllers/map/InventarisCoaMapping.php | 187 ++++++++++++++++++ 2 files changed, 245 insertions(+) create mode 100644 application/controllers/map/InventarisCoaMapping.http create mode 100644 application/controllers/map/InventarisCoaMapping.php diff --git a/application/controllers/map/InventarisCoaMapping.http b/application/controllers/map/InventarisCoaMapping.http new file mode 100644 index 0000000..1fff8f6 --- /dev/null +++ b/application/controllers/map/InventarisCoaMapping.http @@ -0,0 +1,58 @@ +@token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM4MCIsIk1fVXNlclVzZXJuYW1lIjoicmVnc2J5IiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL2FjYy1vbmUtanVybmFsXC8iLCJNX1VzZXJEZWZhdWx0VF9TYW1wbGVTdGF0aW9uSUQiOiIwIiwiTV9TdGFmZk5hbWUiOiJTdGFmZiBSZWdpb25hbCIsImlzX2NvdXJpZXIiOiJOIiwidGltZV9hdXRvbG9nb3V0IjoiMTIwIiwiTV9Vc2VyTG9jYXRpb25JRCI6IjM3IiwiTV9Vc2VyTG9jYXRpb25GbGFnIjoiUiIsIlNfUmVnaW9uYWxOYW1lIjoiU3VyYWJheWEgUmF5YSIsIlNfUmVnaW9uYWxJRCI6IjYiLCJNX0JyYW5jaE5hbWUiOiIiLCJNX0JyYW5jaENvZGUiOiIiLCJNX0JyYW5jaElEIjoiMCIsImxvZ2luTGV2ZWwiOiJyZWdpb25hbCIsIk1fQnJhbmNoQ29tcGFueUlEIjoiMSIsIk1fQnJhbmNoQ29tcGFueU5hbWUiOiJQVCBQUkFNSVRBIiwiaXAiOiIxMzkuMTk1LjEyMi4yMzUiLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoWDExOyBMaW51eCB4ODZfNjQ7IHJ2OjEzNy4wKSBHZWNrb1wvMjAxMDAxMDEgRmlyZWZveFwvMTM3LjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNS0wNi0wNCAxMzoyMDowNSIsIk1fU2F0ZWxsaXRlSUQiOjB9.hm6JtstjaQOzb7oDSXQ-oMWuX_jFQZH-HDr3r3OzPac" + +@host = accone.aplikasi.web.id/one-api + +### +// create inventaris coa mapping +POST https://{{host}}/map/InventarisCoaMapping/createInvCoaMapping/ +Content-Type: application/json + +{ + "token": {{token}}, + "M_InventarisGolID": 1, + "CoaInventarisID": 101, + "CoaHutangID": 102, + "CoaPembelianID": 103, + "CoaBebanPenyusutanID": 104, + "CoaAkumulasiPenyusutanID": 105, + "CoaLabaPelepasanID": 106, + "CoaRugiPelepasanID": 107 +} + +### +// get inventaris coa mapping by ID +POST https://{{host}}/map/InventarisCoaMapping/getInvCoaMapping/ +Content-Type: application/json + +{ + "token": {{token}}, + "M_InventarisCoaMappingID": 1 +} + +### +// edit inventaris coa mapping +POST https://{{host}}/map/InventarisCoaMapping/editInvCoaMapping/ +Content-Type: application/json + +{ + "token": {{token}}, + "M_InventarisCoaMappingID": 1, + "M_InventarisGolID": 2, + "CoaInventarisID": 201, + "CoaHutangID": 202, + "CoaPembelianID": 203, + "CoaBebanPenyusutanID": 204, + "CoaAkumulasiPenyusutanID": 205, + "CoaLabaPelepasanID": 206, + "CoaRugiPelepasanID": 207 +} + +### +// delete inventaris coa mapping +POST https://{{host}}/map/InventarisCoaMapping/deleteInvCoaMapping/ +Content-Type: application/json + +{ + "token": {{token}}, + "M_InventarisCoaMappingID": 1 +} diff --git a/application/controllers/map/InventarisCoaMapping.php b/application/controllers/map/InventarisCoaMapping.php new file mode 100644 index 0000000..84b3ad3 --- /dev/null +++ b/application/controllers/map/InventarisCoaMapping.php @@ -0,0 +1,187 @@ +isLogin) { + $this->sys_error("invalid token"); + exit; + } + + $this->db->trans_begin(); + + $para = $this->sys_input; + $user = $this->sys_user; + + $sql = "INSERT INTO m_inventaris_coa_mapping ( + M_InventarisCoaMappingM_InventarisGolID, + M_InventarisCoaMappingCoaInventarisID, + M_InventarisCoaMappingCoaHutangID, + M_InventarisCoaMappingCoaPembelianID, + M_InventarisCoaMappingCoaBebanPenyusutanID, + M_InventarisCoaMappingCoaAkumulasiPenyusutanID, + M_InventarisCoaMappingCoaLabaPelepasanID, + M_InventarisCoaMappingCoaRugiPelepasanID, + M_InventarisCoaMappingCreatedUserID, + M_InventarisCoaMappingCreated, + M_InventarisCoaMappingLastUpdated + ) VALUES (?,?,?,?,?,?,?,?,?,NOW(),NOW())"; + $query = $this->db->query($sql, [ + $para['M_InventarisGolID'], + $para['CoaInventarisID'], + $para['CoaHutangID'], + $para['CoaPembelianID'], + $para['CoaBebanPenyusutanID'], + $para['CoaAkumulasiPenyusutanID'], + $para['CoaLabaPelepasanID'], + $para['CoaRugiPelepasanID'], + $user['M_UserID'] + ]); + if (!$query) { + $this->db->trans_rollback(); + $this->sys_error_db("[Error] insert into table m_inventaris_coa_mapping"); + exit; + } + + $insertID = $this->db->insert_id(); + + $this->db->trans_commit(); + $this->sys_ok($insertID); + } catch (Exception $exc) { + $msg = $exc->getMessage(); + $this->sys_error($msg); + } + } + + ## QUERY ## + public function getInvCoaMapping() { + try { + if (!$this->isLogin) { + $this->sys_error("invalid token"); + exit; + } + + $para = $this->sys_input; + + $sql = "SELECT + M_InventarisCoaMappingID, + M_InventarisCoaMappingM_InventarisGolID, + M_InventarisCoaMappingCoaInventarisID, + M_InventarisCoaMappingCoaHutangID, + M_InventarisCoaMappingCoaPembelianID, + M_InventarisCoaMappingCoaBebanPenyusutanID, + M_InventarisCoaMappingCoaAkumulasiPenyusutanID, + M_InventarisCoaMappingCoaLabaPelepasanID, + M_InventarisCoaMappingCoaRugiPelepasanID, + M_InventarisCoaMappingCreatedUserID, + M_InventarisCoaMappingCreated, + M_InventarisCoaMappingLastUpdated + FROM m_inventaris_coa_mapping + WHERE M_InventarisCoaMappingIsActive = 'Y' + AND M_InventarisCoaMappingID = ?"; + $query = $this->db->query($sql, [$para['M_InventarisCoaMappingID']]); + if (!$query) { + $this->sys_error_db("[Error] get data m_inventaris_coa_mapping"); + exit; + } + $data = $query->row_array(); + + $this->sys_ok($data); + } catch (Exception $exc) { + $msg = $exc->getMessage(); + $this->sys_error($msg); + } + } + + ## MUTATIONS ## + public function editInvCoaMapping() { + try { + if (!$this->isLogin) { + $this->sys_error("invalid token"); + exit; + } + + $this->db->trans_begin(); + + $para = $this->sys_input; + $user = $this->sys_user; + + $sql = "UPDATE m_inventaris_coa_mapping SET + M_InventarisCoaMappingM_InventarisGolID = ?, + M_InventarisCoaMappingCoaInventarisID = ?, + M_InventarisCoaMappingCoaHutangID = ?, + M_InventarisCoaMappingCoaPembelianID = ?, + M_InventarisCoaMappingCoaBebanPenyusutanID = ?, + M_InventarisCoaMappingCoaAkumulasiPenyusutanID = ?, + M_InventarisCoaMappingCoaLabaPelepasanID = ?, + M_InventarisCoaMappingCoaRugiPelepasanID = ?, + M_InventarisCoaMappingLastUpdated = NOW() + WHERE M_InventarisCoaMappingIsActive = 'Y' + AND M_InventarisCoaMappingID = ?"; + $query = $this->db->query($sql, [ + $para['M_InventarisGolID'], + $para['CoaInventarisID'], + $para['CoaHutangID'], + $para['CoaPembelianID'], + $para['CoaBebanPenyusutanID'], + $para['CoaAkumulasiPenyusutanID'], + $para['CoaLabaPelepasanID'], + $para['CoaRugiPelepasanID'], + $para['M_InventarisCoaMappingID'] + ]); + if (!$query) { + $this->db->trans_rollback(); + $this->sys_error_db("[Error] update table m_inventaris_coa_mapping"); + exit; + } + + $this->db->trans_commit(); + $this->sys_ok("[Success] update data inventaris coa mapping"); + } catch (Exception $exc) { + $msg = $exc->getMessage(); + $this->sys_error($msg); + } + } + + public function deleteInvCoaMapping() { + try { + if (!$this->isLogin) { + $this->sys_error("invalid token"); + exit; + } + + $this->db->trans_begin(); + + $para = $this->sys_input; + + $sql = "UPDATE m_inventaris_coa_mapping SET + M_InventarisCoaMappingIsActive = 'N', + M_InventarisCoaMappingLastUpdated = NOW() + WHERE M_InventarisCoaMappingIsActive = 'Y' + AND M_InventarisCoaMappingID = ?"; + $query = $this->db->query($sql, [$para['M_InventarisCoaMappingID']]); + if (!$query) { + $this->db->trans_rollback(); + $this->sys_error_db("[Error] soft delete data m_inventaris_coa_mapping"); + exit; + } + + $this->db->trans_commit(); + $this->sys_ok("[Success] delete data inventaris coa mapping"); + } catch (Exception $exc) { + $msg = $exc->getMessage(); + $this->sys_error($msg); + } + } +}