Compare commits
2 Commits
b03ae67f75
...
8d8a5e48d5
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d8a5e48d5 | |||
| 805cb44530 |
@@ -1635,55 +1635,12 @@ class Fakturv4 extends MY_Controller
|
|||||||
0,
|
0,
|
||||||
$kredit
|
$kredit
|
||||||
);
|
);
|
||||||
if (!$status) {
|
if (!$status['status']) {
|
||||||
$this->sys_error_db($status['msg']);
|
$this->sys_error_db($status['msg']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
} else if ($item['M_ItemItem_CategoryID'] == '2') {
|
} else if ($item['M_ItemItem_CategoryID'] == '2') {
|
||||||
if (empty($item['M_ItemM_InventarisGolID'])) {
|
$this->InsertJurnalTxInventaris($jurnalID, $item, $inv, $user['M_UserID']);
|
||||||
$this->db->trans_rollback();
|
|
||||||
$this->sys_error_db("[Error] item golongan inventaris belum ditentukan");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_coainv = "SELECT
|
|
||||||
CoaMapInventarisHutangCoaID,
|
|
||||||
CoaMapInventarisHutangCoaNo,
|
|
||||||
CoaMapInventarisHutangCoaDesc
|
|
||||||
FROM coa_map_inventaris
|
|
||||||
WHERE CoaMapInventarisM_InventarisGolID = ?
|
|
||||||
AND CoaMapInventarisIsActive = 'Y'";
|
|
||||||
$que_coainv = $this->db->query($sql_coainv, [$item['M_ItemM_InventarisGolID']]);
|
|
||||||
if (!$que_coainv) {
|
|
||||||
$this->db->trans_rollback();
|
|
||||||
$this->sys_error_db("[Error] failed to get coa inventaris gol");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$item_coainv = $que_coainv->row_array();
|
|
||||||
if (empty($item_coainv)) {
|
|
||||||
$this->db->trans_rollback();
|
|
||||||
$this->sys_error_db("[Error] item inventaris coa not found");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$price = (doubleval($inv['SupplierInvoiceDetailTotal']) - doubleval($inv['SupplierInvoiceDetailDiscountPoProrata']));
|
|
||||||
// $taxPPH = doubleval($inv['SupplierInvoiceTaxPercentPph']) * $price / 100;
|
|
||||||
$taxPPN = doubleval($inv['SupplierInvoiceTaxPercentPpn']) * $price / 100;
|
|
||||||
|
|
||||||
$kredit = round($price + $taxPPN, 2);
|
|
||||||
|
|
||||||
$status = $this->InsertJurnalTx(
|
|
||||||
$jurnalID,
|
|
||||||
$item_coainv['CoaMapInventarisHutangCoaID'],
|
|
||||||
$item_coainv['CoaMapInventarisHutangCoaDesc'],
|
|
||||||
$user['M_UserID'],
|
|
||||||
0,
|
|
||||||
$kredit
|
|
||||||
);
|
|
||||||
if (!$status) {
|
|
||||||
$this->sys_error_db($status['msg']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
} else if ($item['M_ItemItem_CategoryID'] == '3') {
|
} else if ($item['M_ItemItem_CategoryID'] == '3') {
|
||||||
$this->InsertJurnalTxAsset($jurnalID, $item['M_ItemID'], $inv, $user['M_UserID']);
|
$this->InsertJurnalTxAsset($jurnalID, $item['M_ItemID'], $inv, $user['M_UserID']);
|
||||||
} else if ($item['M_ItemItem_CategoryID'] == '4') {
|
} else if ($item['M_ItemItem_CategoryID'] == '4') {
|
||||||
@@ -1720,6 +1677,71 @@ class Fakturv4 extends MY_Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function InsertJurnalTxInventaris($jurnalID, $items, $invoice, $userid)
|
||||||
|
{
|
||||||
|
if (empty($items['M_ItemM_InventarisGolID'])) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db("[Error] item golongan inventaris belum ditentukan");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_coa = "SELECT
|
||||||
|
COALESCE(
|
||||||
|
i.M_InventarisItemCoaMappingID,
|
||||||
|
g.M_InventarisCoaMappingID
|
||||||
|
) AS MappingID,
|
||||||
|
COALESCE(
|
||||||
|
i.M_InventarisItemCoaMappingCoaHutangID,
|
||||||
|
g.M_InventarisCoaMappingCoaHutangID
|
||||||
|
) AS CoaHutangID,
|
||||||
|
c.coaDescription AS CoaHutangDesc
|
||||||
|
FROM (SELECT 1) AS inventory
|
||||||
|
LEFT JOIN m_inventaris_item_coa_mapping i
|
||||||
|
ON i.M_InventarisItemCoaMappingM_ItemID = ?
|
||||||
|
AND i.M_InventarisItemCoaMappingIsActive = 'Y'
|
||||||
|
LEFT JOIN m_inventaris_coa_mapping g
|
||||||
|
ON g.M_InventarisCoaMappingM_InventarisGolID = ?
|
||||||
|
AND g.M_InventarisCoaMappingIsActive = 'Y'
|
||||||
|
LEFT JOIN coa c
|
||||||
|
ON c.coaID = COALESCE(i.M_InventarisItemCoaMappingCoaHutangID, g.M_InventarisCoaMappingCoaHutangID)
|
||||||
|
AND c.coaIsActive = 'Y'";
|
||||||
|
$que_coa = $this->db->query($sql_coa, [
|
||||||
|
$items['M_ItemID'],
|
||||||
|
$items['M_ItemM_InventarisGolID'],
|
||||||
|
]);
|
||||||
|
if (!$que_coa) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db("[Error] failed query coa hutang inventaris");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$item_coainv = $que_coa->row_array();
|
||||||
|
if (empty($item_coainv['CoaHutangID'])) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db("[Error] coa ivnentory item {$items['M_ItemDesc']} not found");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invtotal = doubleval($invoice['SupplierInvoiceDetailTotal']);
|
||||||
|
$disprorata = doubleval($invoice['SupplierInvoiceDetailDiscountPoProrata']);
|
||||||
|
$price = $invtotal - $disprorata;
|
||||||
|
$taxPPN = doubleval($invoice['SupplierInvoiceTaxPercentPpn']) * $price / 100;
|
||||||
|
$kredit = round($price + $taxPPN, 2);
|
||||||
|
|
||||||
|
$insert = $this->InsertJurnalTx(
|
||||||
|
$jurnalID,
|
||||||
|
$item_coainv['CoaHutangID'],
|
||||||
|
$item_coainv['CoaHutangDesc'],
|
||||||
|
$userid,
|
||||||
|
0,
|
||||||
|
$kredit
|
||||||
|
);
|
||||||
|
if (!$insert['status']) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db($insert['msg']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function InsertJurnalTxJasa($jurnalID, $itemid, $invoice, $userid)
|
private function InsertJurnalTxJasa($jurnalID, $itemid, $invoice, $userid)
|
||||||
{
|
{
|
||||||
$sql_coa = "SELECT
|
$sql_coa = "SELECT
|
||||||
@@ -1759,7 +1781,7 @@ class Fakturv4 extends MY_Controller
|
|||||||
0,
|
0,
|
||||||
$kredit
|
$kredit
|
||||||
);
|
);
|
||||||
if (!$insert) {
|
if (!$insert['status']) {
|
||||||
$this->db->trans_rollback();
|
$this->db->trans_rollback();
|
||||||
$this->sys_error_db($insert['msg']);
|
$this->sys_error_db($insert['msg']);
|
||||||
exit;
|
exit;
|
||||||
@@ -1804,7 +1826,7 @@ class Fakturv4 extends MY_Controller
|
|||||||
0,
|
0,
|
||||||
$finalValue
|
$finalValue
|
||||||
);
|
);
|
||||||
if (!$insert) {
|
if (!$insert['status']) {
|
||||||
$this->db->trans_rollback();
|
$this->db->trans_rollback();
|
||||||
$this->sys_error_db($insert['msg']);
|
$this->sys_error_db($insert['msg']);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -73,7 +73,7 @@ class ReceiveItemPoInventaris extends MY_Controller
|
|||||||
$qry = $this->db->query($sql, [$user['M_BranchID'], $search]);
|
$qry = $this->db->query($sql, [$user['M_BranchID'], $search]);
|
||||||
|
|
||||||
if (!$qry) {
|
if (!$qry) {
|
||||||
$this->sys_error_db("[Error] query listing ruangan");;
|
$this->sys_error_db("[Error] query listing ruangan");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user