add: inventaris item coa mapping API

This commit is contained in:
2026-07-09 16:30:53 +07:00
committed by sasadib
parent 17445d9534
commit 34fb944e6e
2 changed files with 229 additions and 0 deletions

View File

@@ -56,3 +56,58 @@ Content-Type: application/json
"token": {{token}}, "token": {{token}},
"M_InventarisCoaMappingID": 1 "M_InventarisCoaMappingID": 1
} }
###
// create inventaris item coa mapping
POST https://{{host}}/map/InventarisCoaMapping/createInvItemCoaMapping/
Content-Type: application/json
{
"token": {{token}},
"M_ItemID": 10,
"CoaInventarisID": 201,
"CoaHutangID": 202,
"CoaPembelianID": 203,
"CoaBebanPenyusutanID": 204,
"CoaAkumulasiPenyusutanID": 205,
"CoaLabaPelepasanID": 206,
"CoaRugiPelepasanID": 207
}
###
// get inventaris item coa mapping by ID
POST https://{{host}}/map/InventarisCoaMapping/getInvItemCoaMapping/
Content-Type: application/json
{
"token": {{token}},
"M_InventarisItemCoaMappingID": 1
}
###
// edit inventaris item coa mapping
POST https://{{host}}/map/InventarisCoaMapping/editInvItemCoaMapping/
Content-Type: application/json
{
"token": {{token}},
"M_InventarisItemCoaMappingID": 1,
"M_ItemID": 11,
"CoaInventarisID": 301,
"CoaHutangID": 302,
"CoaPembelianID": 303,
"CoaBebanPenyusutanID": 304,
"CoaAkumulasiPenyusutanID": 305,
"CoaLabaPelepasanID": 306,
"CoaRugiPelepasanID": 307
}
###
// delete inventaris item coa mapping
POST https://{{host}}/map/InventarisCoaMapping/deleteInvItemCoaMapping/
Content-Type: application/json
{
"token": {{token}},
"M_InventarisItemCoaMappingID": 1
}

View File

@@ -184,4 +184,178 @@ class InventarisCoaMapping extends MY_Controller {
$this->sys_error($msg); $this->sys_error($msg);
} }
} }
## MUTATIONS ITEM ##
public function createInvItemCoaMapping() {
try {
if (!$this->isLogin) {
$this->sys_error("invalid token");
exit;
}
$this->db->trans_begin();
$para = $this->sys_input;
$user = $this->sys_user;
$sql = "INSERT INTO m_inventaris_item_coa_mapping (
M_InventarisItemCoaMappingM_ItemID,
M_InventarisItemCoaMappingCoaInventarisID,
M_InventarisItemCoaMappingCoaHutangID,
M_InventarisItemCoaMappingCoaPembelianID,
M_InventarisItemCoaMappingCoaBebanPenyusutanID,
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID,
M_InventarisItemCoaMappingCoaLabaPelepasanID,
M_InventarisItemCoaMappingCoaRugiPelepasanID,
M_InventarisItemCoaMappingCreatedUserID,
M_InventarisItemCoaMappingCreated,
M_InventarisItemCoaMappingLastUpdated
) VALUES (?,?,?,?,?,?,?,?,?,NOW(),NOW())";
$query = $this->db->query($sql, [
$para['M_ItemID'],
$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_item_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 ITEM ##
public function getInvItemCoaMapping() {
try {
if (!$this->isLogin) {
$this->sys_error("invalid token");
exit;
}
$para = $this->sys_input;
$sql = "SELECT
M_InventarisItemCoaMappingID,
M_InventarisItemCoaMappingM_ItemID,
M_InventarisItemCoaMappingCoaInventarisID,
M_InventarisItemCoaMappingCoaHutangID,
M_InventarisItemCoaMappingCoaPembelianID,
M_InventarisItemCoaMappingCoaBebanPenyusutanID,
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID,
M_InventarisItemCoaMappingCoaLabaPelepasanID,
M_InventarisItemCoaMappingCoaRugiPelepasanID,
M_InventarisItemCoaMappingCreatedUserID,
M_InventarisItemCoaMappingCreated,
M_InventarisItemCoaMappingLastUpdated
FROM m_inventaris_item_coa_mapping
WHERE M_InventarisItemCoaMappingIsActive = 'Y'
AND M_InventarisItemCoaMappingID = ?";
$query = $this->db->query($sql, [$para['M_InventarisItemCoaMappingID']]);
if (!$query) {
$this->sys_error_db("[Error] get data m_inventaris_item_coa_mapping");
exit;
}
$data = $query->row_array();
$this->sys_ok($data);
} catch (Exception $exc) {
$msg = $exc->getMessage();
$this->sys_error($msg);
}
}
## MUTATIONS ITEM ##
public function editInvItemCoaMapping() {
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_item_coa_mapping SET
M_InventarisItemCoaMappingM_ItemID = ?,
M_InventarisItemCoaMappingCoaInventarisID = ?,
M_InventarisItemCoaMappingCoaHutangID = ?,
M_InventarisItemCoaMappingCoaPembelianID = ?,
M_InventarisItemCoaMappingCoaBebanPenyusutanID = ?,
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID = ?,
M_InventarisItemCoaMappingCoaLabaPelepasanID = ?,
M_InventarisItemCoaMappingCoaRugiPelepasanID = ?,
M_InventarisItemCoaMappingLastUpdated = NOW()
WHERE M_InventarisItemCoaMappingIsActive = 'Y'
AND M_InventarisItemCoaMappingID = ?";
$query = $this->db->query($sql, [
$para['M_ItemID'],
$para['CoaInventarisID'],
$para['CoaHutangID'],
$para['CoaPembelianID'],
$para['CoaBebanPenyusutanID'],
$para['CoaAkumulasiPenyusutanID'],
$para['CoaLabaPelepasanID'],
$para['CoaRugiPelepasanID'],
$para['M_InventarisItemCoaMappingID']
]);
if (!$query) {
$this->db->trans_rollback();
$this->sys_error_db("[Error] update table m_inventaris_item_coa_mapping");
exit;
}
$this->db->trans_commit();
$this->sys_ok("[Success] update data inventaris item coa mapping");
} catch (Exception $exc) {
$msg = $exc->getMessage();
$this->sys_error($msg);
}
}
public function deleteInvItemCoaMapping() {
try {
if (!$this->isLogin) {
$this->sys_error("invalid token");
exit;
}
$this->db->trans_begin();
$para = $this->sys_input;
$sql = "UPDATE m_inventaris_item_coa_mapping SET
M_InventarisItemCoaMappingIsActive = 'N',
M_InventarisItemCoaMappingLastUpdated = NOW()
WHERE M_InventarisItemCoaMappingIsActive = 'Y'
AND M_InventarisItemCoaMappingID = ?";
$query = $this->db->query($sql, [$para['M_InventarisItemCoaMappingID']]);
if (!$query) {
$this->db->trans_rollback();
$this->sys_error_db("[Error] soft delete data m_inventaris_item_coa_mapping");
exit;
}
$this->db->trans_commit();
$this->sys_ok("[Success] delete data inventaris item coa mapping");
} catch (Exception $exc) {
$msg = $exc->getMessage();
$this->sys_error($msg);
}
}
} }