add sql collection and update endpoint mapping service coa

This commit is contained in:
2026-09-03 16:51:54 +07:00
parent 93dc515be1
commit 48a5c43cd8
9 changed files with 517 additions and 9 deletions

View File

@@ -47,6 +47,7 @@ class ServiceCoaMapping extends MY_Controller
} else { } else {
$this->sys_error_db($mssg); $this->sys_error_db($mssg);
} }
exit();
} }
} }
@@ -55,16 +56,61 @@ class ServiceCoaMapping extends MY_Controller
try { try {
if (!$this->isLogin) { if (!$this->isLogin) {
throw new Exception('invalid token'); throw new Exception('invalid token');
$sql = "";
$que = $this->db->query($sql);
if (!$que) {
throw new Exception('failed to query service coa mapping', 1);
}
$data = $que->result_array();
$this->sys_ok($data);
} }
$para = $this->sys_input;
$keyword = "%" . $para['search'] . "%";
$offset = 0;
$limit = 10;
if ($para['pages'] > 0) {
$offset = ($para['pages'] - 1) * $limit;
}
$sql = "SELECT
ServiceCoaMappingID,
ServiceCoaMappingM_ItemID,
M_ItemDesc,
ServiceCoaMappingCoaJasaID,
coaJasa.coaAccountNo,
coaJasa.coaDescription,
ServiceCoaMappingCoaHutangID
coaDebt.coaAccountNo,
coaDebt.coaDescription
FROM service_coa_mapping
JOIN m_item ON M_ItemID = ServiceCoaMappingM_ItemID
AND M_ItemDesc LIKE ?
AND M_ItemIsActive = 'Y'
LEFT JOIN coa AS coaJasa
ON coaJasa.coaID = ServiceCoaMappingCoaJasaID
LEFT JOIN coa AS coaDebt
ON coaDebt.coaID = ServiceCoaMappingCoaHutangID
WHERE ServiceCoaMappingIsActive = 'Y'";
$sql_total = "SELECT COUNT(*) AS total FROM ($sql) AS x";
$que_total = $this->db->query($sql_total, [$keyword]);
if (!$que_total) {
throw new Exception('failed query total data', 1);
}
$total = $que_total->row_array()['total'];
$sql_data = $sql . " LIMIT ? OFFSET ? ";
$que_data = $this->db->query($sql_data, [
$keyword,
$limit,
$offset
]);
if (!$que_data) {
throw new Exception('failed to query data', 1);
}
$data = $que_data->result_array();
$output = [
'records' => $data,
'total' => $total
];
$this->sys_ok($output);
} catch (Exception $e) { } catch (Exception $e) {
$mssg = "[Error] " . $e->getMessage(); $mssg = "[Error] " . $e->getMessage();
$code = $e->getCode(); $code = $e->getCode();
@@ -73,6 +119,136 @@ class ServiceCoaMapping extends MY_Controller
} else { } else {
$this->sys_error_db($mssg); $this->sys_error_db($mssg);
} }
exit();
}
}
public function insertJasaCoaMapping()
{
try {
if (!$this->sys_input) {
throw new Exception("Invalid token");
}
$para = $this->sys_input;
$user = $this->sys_user;
$this->db->trans_begin();
$sql = "INSERT INTO service_coa_mapping (
ServiceCoaMappingM_ItemID,
ServiceCoaMappingCoaJasaID,
ServiceCoaMappingCoaHutangID,
ServiceCoaMappingIsActive,
ServiceCoaMappingUserID
) VALUES (?, ?, ?, 'Y', ?)";
$que = $this->db->query($sql, [
$para['M_ItemID'],
$para['CoaJasaID'],
$para['CoaHutangID'],
$user['M_UserID']
]);
if (!$que) {
throw new Exception('failed insert coa mapping jasa', 1);
}
$this->db->trans_commit();
$this->sys_ok("[Success] insert coa mapping jasa");
} catch (Exception $e) {
$this->db->trans_rollback();
$mssg = "[Error] " . $e->getMessage();
$code = $e->getCode();
if ($code == 0) {
$this->sys_error($mssg);
} else {
$this->sys_error_db($mssg);
}
exit();
}
}
public function updateJasaCoaMapping()
{
try {
if (!$this->isLogin) {
throw new Exception('invalid token');
}
$para = $this->sys_input;
$user = $this->sys_user;
$this->db->trans_begin();
$sql = "UPDATE service_coa_mapping
SET
ServiceCoaMappingM_ItemID = ?,
ServiceCoaMappingCoaJasaID = ?,
ServiceCoaMappingCoaHutangID = ?,
ServiceCoaMappingUserID = ?
WHERE ServiceCoaMappingID = ?";
$que = $this->db->query($sql, [
$para['M_ItemID'],
$para['CoaJasaID'],
$para['CoaHutangID'],
$user['M_UserID'],
$para['ServiceCoaMappingID']
]);
if (!$que) {
throw new Exception('failed update coa mapping jasa', 1);
}
$this->db->trans_commit();
$this->sys_ok("[success] update coa mapping jasa");
} catch (Exception $e) {
$this->db->trans_rollback();
$mssg = "[Error] " . $e->getMessage();
$code = $e->getCode();
if ($code == 0) {
$this->sys_error($mssg);
} else {
$this->sys_error_db($mssg);
}
exit();
}
}
public function deleteJasaCoaMapping()
{
try {
if (!$this->isLogin) {
throw new Exception('invalid token', 1);
}
$para = $this->sys_input;
$user = $this->sys_user;
$this->db->trans_begin();
$sql = "UPDATE service_coa_mapping
SET
ServiceCoaMappingIsActive = 'N',
ServiceCoaMappingUserID = ?
WHERE ServiceCoaMappingID = ?";
$que = $this->db->query($sql, [
$user['M_UserID'],
$para['ServiceCoaMappingID']
]);
if (!$que) {
throw new Exception('failed soft delete coa mapping jasa', 1);
}
$this->db->trans_commit();
$this->sys_ok("[success] soft delete coa mapping jasa");
} catch (Exception $e) {
$this->db->trans_rollback();
$mssg = "[Error] " . $e->getMessage();
$code = $e->getCode();
if ($code == 0) {
$this->sys_error($mssg);
} else {
$this->sys_error_db($mssg);
}
exit();
} }
} }
} }

View File

@@ -0,0 +1,131 @@
# Inventaris COA Mapping Notes
## Existing Table Purposes
`coa` is the Chart of Account master. It stores the real account identity:
- `coaID`: primary key, use this for mapping.
- `coaAccountNo`: account number for display/reporting.
- `coaDescription`: account name/description.
- `coaIsInput`: marks accounts that can be posted to.
- `coaIsActive`: active account flag.
- `coaLevel`: account hierarchy level.
`coa_group`, `coa_subgroup`, and `coa_mapgroup` organize COA rows for reporting or account selection:
```text
coa_group
-> coa_subgroup
-> coa_mapgroup
-> coa
```
Relationship:
```text
coa_group.CoaGroupID
= coa_subgroup.CoaSubGroupCoa_GroupID
coa_subgroup.CoaSubGroupID
= coa_mapgroup.CoaMapGroupCoaSubGroupID
coa.coaID
= coa_mapgroup.CoaMapGroupCoaID
```
These tables should not be changed for inventaris mapping. They can be used only to filter or help select valid COA rows in the UI.
`nat_group` and `nat_subgroup` classify normal item nature/type. They are mainly used by non-inventaris item flows, especially item category `1`.
```text
nat_group
-> nat_subgroup
-> m_item
```
Relationship:
```text
nat_group.Nat_GroupID
= nat_subgroup.Nat_SubGroupNat_GroupID
m_item.M_ItemNat_GroupID
= nat_group.Nat_GroupID
m_item.M_ItemNat_SubGroupID
= nat_subgroup.Nat_SubGroupID
```
`nat_subgroup_map`, `map_nat_group`, and `map_nat_subgroup` connect NAT classification to COA for normal item accounting:
- `nat_subgroup_map`: maps NAT subgroup to pendapatan, diskon, and retur COA.
- `map_nat_group`: maps NAT group to diskon, retur, DP, and debt/hutang COA.
- `map_nat_subgroup`: maps NAT group/subgroup to pendapatan, biaya, and persediaan COA.
Typical normal item accounting flow:
```text
m_item
-> M_ItemNat_GroupID + M_ItemNat_SubGroupID
-> map_nat_subgroup / map_nat_group / nat_subgroup_map
-> coa.coaID
```
## Relationship To `m_item`
`m_item` has multiple classification fields:
```text
M_ItemItem_CategoryID
M_ItemNat_GroupID
M_ItemNat_SubGroupID
M_ItemFa_ClassID
M_ItemM_InventarisGolID
```
For item category `1`, NAT group/subgroup is the main accounting classification.
For inventaris item category `2`, `M_ItemM_InventarisGolID` should be the main accounting classification. Do not add COA fields to `m_item`.
## New Inventaris COA Mapping
Use `m_inventaris_coa_mapping` as the default COA mapping source for inventaris items based on golongan inventaris:
```text
m_item.M_ItemM_InventarisGolID
-> m_inventaris_coa_mapping.M_InventarisCoaMappingM_InventarisGolID
-> coa.coaID fields
```
The mapping table stores `coa.coaID`, not account number text. Account number and description should be read from `coa` when displaying or posting journals.
Recommended lookup rule:
```text
1. Check active item-level override in m_inventaris_item_coa_mapping.
2. If no override exists, use active gol-level default in m_inventaris_coa_mapping.
3. If no mapping exists, stop the transaction and show an incomplete COA mapping error.
```
`m_inventaris_item_coa_mapping` is optional and only for specific item exceptions. Its COA fields are nullable so one item can override only one account and inherit the rest from the gol-level default.
## COA Fields For Inventaris
The default gol-level mapping should provide:
- `CoaAsetID`: asset/inventaris account.
- `CoaHutangID`: payable account.
- `CoaPembelianID`: purchase or acquisition account.
- `CoaBebanPenyusutanID`: depreciation expense account.
- `CoaAkumulasiPenyusutanID`: accumulated depreciation account.
- `CoaLabaPelepasanID`: gain on disposal account.
- `CoaRugiPelepasanID`: loss on disposal account.
Use active, postable COA rows where possible:
```sql
coa.coaIsActive = 'Y'
AND coa.coaIsInput = 'Y'
```
`coa_group` and `coa_subgroup` may help filter dropdown options, but the saved mapping should still point directly to `coa.coaID`.

View File

@@ -0,0 +1,53 @@
CREATE TABLE m_inventaris_coa_mapping (
M_InventarisCoaMappingID int(11) NOT NULL AUTO_INCREMENT,
M_InventarisCoaMappingM_InventarisGolID int(11) NOT NULL,
M_InventarisCoaMappingCoaInventarisID int(11) NOT NULL,
M_InventarisCoaMappingCoaHutangID int(11) NOT NULL,
M_InventarisCoaMappingCoaPembelianID int(11) NOT NULL,
M_InventarisCoaMappingCoaBebanPenyusutanID int(11) DEFAULT NULL,
M_InventarisCoaMappingCoaAkumulasiPenyusutanID int(11) DEFAULT NULL,
M_InventarisCoaMappingCoaLabaPelepasanID int(11) DEFAULT NULL,
M_InventarisCoaMappingCoaRugiPelepasanID int(11) DEFAULT NULL,
M_InventarisCoaMappingCreatedUserID int(11) NOT NULL,
M_InventarisCoaMappingCreated datetime NOT NULL DEFAULT current_timestamp(),
M_InventarisCoaMappingLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
M_InventarisCoaMappingIsActive char(1) NOT NULL DEFAULT 'Y',
PRIMARY KEY (M_InventarisCoaMappingID),
KEY M_InventarisCoaMappingM_InventarisGolID (M_InventarisCoaMappingM_InventarisGolID),
KEY M_InventarisCoaMappingCoaInventarisID (M_InventarisCoaMappingCoaInventarisID),
KEY M_InventarisCoaMappingCoaHutangID (M_InventarisCoaMappingCoaHutangID),
KEY M_InventarisCoaMappingCoaPembelianID (M_InventarisCoaMappingCoaPembelianID),
KEY M_InventarisCoaMappingCoaBebanPenyusutanID (M_InventarisCoaMappingCoaBebanPenyusutanID),
KEY M_InventarisCoaMappingCoaAkumulasiPenyusutanID (M_InventarisCoaMappingCoaAkumulasiPenyusutanID),
KEY M_InventarisCoaMappingCoaLabaPelepasanID (M_InventarisCoaMappingCoaLabaPelepasanID),
KEY M_InventarisCoaMappingCoaRugiPelepasanID (M_InventarisCoaMappingCoaRugiPelepasanID),
KEY M_InventarisCoaMappingCreatedUserID (M_InventarisCoaMappingCreatedUserID),
KEY M_InventarisCoaMappingIsActive (M_InventarisCoaMappingIsActive)
);
CREATE TABLE m_inventaris_item_coa_mapping (
M_InventarisItemCoaMappingID int(11) NOT NULL AUTO_INCREMENT,
M_InventarisItemCoaMappingM_ItemID int(11) NOT NULL,
M_InventarisItemCoaMappingCoaInventarisID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCoaHutangID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCoaPembelianID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCoaBebanPenyusutanID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCoaLabaPelepasanID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCoaRugiPelepasanID int(11) DEFAULT NULL,
M_InventarisItemCoaMappingCreatedUserID int(11) NOT NULL,
M_InventarisItemCoaMappingCreated datetime NOT NULL DEFAULT current_timestamp(),
M_InventarisItemCoaMappingLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
M_InventarisItemCoaMappingIsActive char(1) NOT NULL DEFAULT 'Y',
PRIMARY KEY (M_InventarisItemCoaMappingID),
KEY M_InventarisItemCoaMappingM_ItemID (M_InventarisItemCoaMappingM_ItemID),
KEY M_InventarisItemCoaMappingCoaInventarisID (M_InventarisItemCoaMappingCoaInventarisID),
KEY M_InventarisItemCoaMappingCoaHutangID (M_InventarisItemCoaMappingCoaHutangID),
KEY M_InventarisItemCoaMappingCoaPembelianID (M_InventarisItemCoaMappingCoaPembelianID),
KEY M_InventarisItemCoaMappingCoaBebanPenyusutanID (M_InventarisItemCoaMappingCoaBebanPenyusutanID),
KEY M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID (M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID),
KEY M_InventarisItemCoaMappingCoaLabaPelepasanID (M_InventarisItemCoaMappingCoaLabaPelepasanID),
KEY M_InventarisItemCoaMappingCoaRugiPelepasanID (M_InventarisItemCoaMappingCoaRugiPelepasanID),
KEY M_InventarisItemCoaMappingCreatedUserID (M_InventarisItemCoaMappingCreatedUserID),
KEY M_InventarisItemCoaMappingIsActive (M_InventarisItemCoaMappingIsActive)
);

View File

@@ -0,0 +1,14 @@
CREATE TABLE contract_asset_attachment (
ContractAssetAttachmentID int(11) NOT NULL AUTO_INCREMENT,
ContractAssetAttachmentPurchaseOrderID int(11) NOT NULL,
ContractAssetAttachmentPurchaseOrderAssetContractID int(11) NOT NULL,
ContractAssetAttachmentFileName varchar(255) DEFAULT NULL,
ContractAssetAttachmentDate date DEFAULT NULL,
ContractAssetAttachmentIsActive char(1) DEFAULT 'Y',
ContractAssetAttachmentCreated datetime NOT NULL DEFAULT current_timestamp(),
ContractAssetAttachmentLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
ContractAssetAttachmentUserID int(11) DEFAULT 0,
PRIMARY KEY (ContractAssetAttachmentID),
KEY ContractAssetAttachmentPurchaseOrderID (ContractAssetAttachmentPurchaseOrderID),
KEY ContractAssetAttachmentIsActive (ContractAssetAttachmentIsActive)
);

View File

@@ -0,0 +1,24 @@
CREATE TABLE purchase_order_asset_contract (
PurchaseOrderAssetContractID int(11) NOT NULL AUTO_INCREMENT,
PurchaseOrderAssetContractPurchaseOrderID int(11) NOT NULL,
PurchaseOrderAssetContractTAssetAttachmentID int(11) NOT NULL,
PurchaseOrderAssetContractName varchar(128) DEFAULT NULL,
PurchaseOrderAssetContractDate date DEFAULT NULL,
PurchaseOrderAssetContractStartDate date DEFAULT NULL,
PurchaseOrderAssetContractEndDate date DEFAULT NULL,
PurchaseOrderAssetContractDuration int(11) DEFAULT 1,
PurchaseOrderAssetContractInstallmentNumber int(11) DEFAULT 1,
PurchaseOrderAssetContractInstallmentDate int(11) DEFAULT 1,
PurchaseOrderAssetContractInstallmentPayAmount decimal(20,2) DEFAULT 00.0,
PurchaseOrderAssetContractInstallmentDownPaymentType enum('nominal','persen') DEFAULT 'nominal',
PurchaseOrderAssetContractInstallmentDownPayment decimal(20,2) DEFAULT 00.0,
PurchaseOrderAssetContractCreatedUserID int(11) NOT NULL,
PurchaseOrderAssetContractCreated datetime NOT NULL DEFAULT current_timestamp(),
PurchaseOrderAssetContractLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PurchaseOrderAssetContractIsActive char(1) NOT NULL DEFAULT 'Y',
PRIMARY KEY (PurchaseOrderAssetContractID),
KEY PurchaseOrderAssetContractPurchaseOrderID (PurchaseOrderAssetContractPurchaseOrderID),
KEY PurchaseOrderAssetContractTAssetAttachmentID (PurchaseOrderAssetContractTAssetAttachmentID),
KEY PurchaseOrderAssetContractName (PurchaseOrderAssetContractName),
KEY PurchaseOrderAssetContractIsActive (PurchaseOrderAssetContractIsActive)
);

View File

@@ -0,0 +1,15 @@
CREATE TABLE service_coa_mapping (
ServiceCoaMappingID int(11) NOT NULL AUTO_INCREMENT,
ServiceCoaMappingM_ItemID int(11) NOT NULL,
ServiceCoaMappingCoaJasaID int(11) NOT NULL,
ServiceCoaMappingCoaHutangID int(11) NOT NULL,
ServiceCoaMappingIsActive char(1) NOT NULL DEFAULT 'Y',
ServiceCoaMappingCreated datetime NULL DEFAULT current_timestamp(),
ServiceCoaMappingLastUpdated datetime NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
ServiceCoaMappingUserID int(11) NULL DEFAULT 0,
PRIMARY KEY (ServiceCoaMappingID),
KEY ServiceCoaMappingM_ItemID (ServiceCoaMappingM_ItemID),
KEY ServiceCoaMappingCoaJasaID (ServiceCoaMappingCoaJasaID),
KEY ServiceCoaMappingCoaHutangID (ServiceCoaMappingCoaHutangID),
KEY ServiceCoaMappingIsActive (ServiceCoaMappingIsActive)
);

View File

@@ -0,0 +1,13 @@
CREATE TABLE stock_asset (
StockAssetID int(11) NOT NULL AUTO_INCREMENT,
StockAssetStockID int(11) NOT NULL,
StockAssetCabangID int(11) NOT NULL,
StockAssetCreatedUserID int(11) NOT NULL,
StockAssetCreated datetime NOT NULL DEFAULT current_timestamp(),
StockAssetLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
StockAssetIsActive char(1) NOT NULL DEFAULT 'Y',
PRIMARY KEY (StockAssetID),
KEY StockAssetStockID (StockAssetStockID),
KEY StockAssetCabangID (StockAssetCabangID),
KEY StockAssetIsActive (StockAssetIsActive)
);

View File

@@ -0,0 +1,36 @@
CREATE TABLE stock_inventory (
StockInventoryID int(11) NOT NULL AUTO_INCREMENT,
StockInventoryStockID int(11) NOT NULL,
StockInventoryRuanganID int(11) NOT NULL,
StockInventoryBarcode varchar(128) DEFAULT NULL,
StockInventoryCabangID int(11) NOT NULL,
StockInventoryCreatedUserID int(11) NOT NULL,
StockInventoryCreated datetime NOT NULL DEFAULT current_timestamp(),
StockInventoryLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
StockInventoryIsActive char(1) NOT NULL DEFAULT 'Y',
PRIMARY KEY (StockInventoryID),
KEY StockInventoryStockID (StockInventoryStockID),
KEY StockInventoryBarcode (StockInventoryBarcode),
KEY StockInventoryRuanganID (StockInventoryRuanganID),
KEY StockInventoryCabangID (StockInventoryCabangID),
KEY StockInventoryIsActive (StockInventoryIsActive)
);
CREATE TABLE stock_asset (
StockAssetID int(11) NOT NULL AUTO_INCREMENT,
StockAssetStockID int(11) NOT NULL,
StockAssetRuanganID int(11) NOT NULL,
StockAssetBarcode varchar(128) DEFAULT NULL,
StockAssetCabangID int(11) NOT NULL,
StockAssetCreatedUserID int(11) NOT NULL,
StockAssetCreated datetime NOT NULL DEFAULT current_timestamp(),
StockAssetLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
StockAssetIsActive char(1) NOT NULL DEFAULT 'Y',
PRIMARY KEY (StockAssetID),
KEY StockAssetStockID (StockAssetStockID),
KEY StockAssetBarcode (StockAssetBarcode),
KEY StockAssetRuanganID (StockAssetRuanganID),
KEY StockAssetCabangID (StockAssetCabangID),
KEY StockAssetIsActive (StockAssetIsActive)
);

View File

@@ -0,0 +1,46 @@
CREATE TABLE supplier_downpayment (
SupplierDownpaymentID int(11) NOT NULL AUTO_INCREMENT,
SupplierDownpaymentPurchasOrderID int(11) NOT NULL,
SupplierDownpaymentSupplierID int(11) NOT NULL,
SupplierDownpaymentAmount decimal(20,2) DEFAULT 00.0,
SupplierDownpaymentDate date DEFAULT NULL,
SupplierDownpaymentDueDate date DEFAULT NULL,
SupplierDownpaymentStatus ENUM('Draft','Pending','Paid') DEFAULT 'Draft',
SupplierDownpaymentIsLunas ENUM('Y','N') DEFAULT 'N',
SupplierDownpaymentIsActive ENUM('Y','N') DEFAULT 'Y',
SupplierDownpaymentCreated datetime NOT NULL DEFAULT current_timestamp(),
SupplierDownpaymentCreatedUserID int(11) DEFAULT 0,
SupplierDownpaymentLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
SupplierDownpaymentLastUpdatedUserID int(11) DEFAULT 0,
PRIMARY KEY (SupplierDownpaymentID),
KEY SupplierDownpaymentPurchasOrderID (SupplierDownpaymentPurchasOrderID),
KEY SupplierDownpaymentSupplierID (SupplierDownpaymentSupplierID),
KEY SupplierDownpaymentStatus (SupplierDownpaymentStatus),
KEY SupplierDownpaymentIsActive (SupplierDownpaymentIsActive)
);
CREATE TABLE supplier_installment (
SupplierInstallmentID int(11) NOT NULL AUTO_INCREMENT,
SupplierInstallmentPurchaseOrderID int(11) NOT NULL,
SupplierInstallmentSupplierID int(11) NOT NULL,
SupplierInstallmentSupplierInvoiceID int(11) NULL,
SupplierInstallmentAmount decimal(20,2) DEFAULT 00.0,
SupplierInstallmentDate date DEFAULT NULL,
SupplierInstallmentDueDate date DEFAULT NULL,
SupplierInstallmentPaymentID int(11) NOT NULL,
SupplierInstallmentPaidDate date DEFAULT NULL,
SupplierInstallmentStatus ENUM('Pending', 'Paid', 'Overdue') DEFAULT 'Pending',
SupplierInstallmentIsLunas ENUM('Y','N') DEFAULT 'N',
SupplierInstallmentIsActive ENUM('Y'm 'N') DEFAULT 'Y',
SupplierInstallmentCreated datetime NOT NULL DEFAULT current_timestamp(),
SupplierInstallmentCreatedUserID int(11) DEFAULT 0,
SupplierInstallmentLastUpdated datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
SupplierInstallmentLastUpdatedUserID int(11) DEFAULT 0,
PRIMARY KEY (SupplierInstallmentID),
KEY SupplierInstallmentPurchaseOrderID (SupplierInstallmentPurchaseOrderID),
KEY SupplierInstallmentSupplierID (SupplierInstallmentSupplierID),
KEY SupplierInstallmentSupplierInvoiceID (SupplierInstallmentSupplierInvoiceID),
KEY SupplierInstallmentPaymentID (SupplierInstallmentPaymentID),
KEY SupplierInstallmentStatus (SupplierInstallmentStatus),
KEY SupplierInstallmentIsActive (SupplierInstallmentIsActive)
);