add currency_id & rate_snapshot to document APIs (Phase 3)
- budgetadapter: list/detail queries JOIN tbl_currency; create/update budget and requestbudget store currency_id + rate_snapshot via subquery - justificationadapter: create/update store currency_id + rate_snapshot - pradapter: create/update store currency_id + rate_snapshot; list/detail JOIN tbl_currency - poadapter: insert stores currency_id + rate_snapshot; list/detail queries JOIN tbl_currency All currency_id fields are nullable - existing records unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -99,6 +99,11 @@ class PrAdapter extends Adapter {
|
||||
let nik = req.body.nik;
|
||||
let status = -1;
|
||||
let statusdescription = "draft";
|
||||
let currency_id = req.body.currency_id ?? null;
|
||||
|
||||
let currencyFieldsPr = currency_id
|
||||
? ",currency_id='"+currency_id+"',rate_snapshot=(select rate from tbl_currency where _idx='"+currency_id+"' and isdeleted=0 limit 1)"
|
||||
: ",currency_id=NULL,rate_snapshot=NULL";
|
||||
|
||||
let qry = "insert into tbl_pr ";
|
||||
qry =
|
||||
@ -146,7 +151,7 @@ class PrAdapter extends Adapter {
|
||||
idxapproval +
|
||||
"',nikapproval='" +
|
||||
nikapproval +
|
||||
"',iby='" +
|
||||
"'" + currencyFieldsPr + ",iby='" +
|
||||
nik +
|
||||
"',idt=now()";
|
||||
console.log(qry);
|
||||
@ -193,6 +198,11 @@ class PrAdapter extends Adapter {
|
||||
let nik = req.body.nik;
|
||||
let status = -1;
|
||||
let statusdescription = "draft";
|
||||
let currency_id_upd = req.body.currency_id ?? null;
|
||||
|
||||
let currencyFieldsPrUpd = currency_id_upd
|
||||
? ",currency_id='"+currency_id_upd+"',rate_snapshot=(select rate from tbl_currency where _idx='"+currency_id_upd+"' and isdeleted=0 limit 1)"
|
||||
: ",currency_id=NULL,rate_snapshot=NULL";
|
||||
|
||||
let qry = "update tbl_pr ";
|
||||
qry =
|
||||
@ -237,7 +247,7 @@ class PrAdapter extends Adapter {
|
||||
status +
|
||||
"',statusdescription='" +
|
||||
statusdescription +
|
||||
"',uby='" +
|
||||
"'" + currencyFieldsPrUpd + ",uby='" +
|
||||
nik +
|
||||
"',udt=now() ";
|
||||
qry = qry + "where _idx='" + idxpr + "'";
|
||||
@ -357,7 +367,11 @@ class PrAdapter extends Adapter {
|
||||
try {
|
||||
let _idx = req.query.id;
|
||||
|
||||
let qry = "select * from vw_pr where id='" + _idx + "'";
|
||||
let qry = "select v.*, p.currency_id, p.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol ";
|
||||
qry += "from vw_pr v ";
|
||||
qry += "left join tbl_pr p on p._idx = v.id ";
|
||||
qry += "left join tbl_currency c on c._idx = p.currency_id ";
|
||||
qry += "where v.id='" + _idx + "'";
|
||||
|
||||
// console.log(qry);
|
||||
db.query(qry, [], function (err, result, fields) {
|
||||
@ -406,7 +420,11 @@ class PrAdapter extends Adapter {
|
||||
}
|
||||
}
|
||||
|
||||
let qry = "select * from vw_pr ";
|
||||
let qryBase = "select v.*, p.currency_id, p.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol ";
|
||||
qryBase += "from vw_pr v ";
|
||||
qryBase += "left join tbl_pr p on p._idx = v.id ";
|
||||
qryBase += "left join tbl_currency c on c._idx = p.currency_id ";
|
||||
let qry = qryBase;
|
||||
qry +=
|
||||
"where (trim(trxidpr) like '%" +
|
||||
keyword +
|
||||
@ -434,7 +452,7 @@ class PrAdapter extends Adapter {
|
||||
"totalpage": pagination,
|
||||
"totalrows": result.length,
|
||||
});
|
||||
qry = "select * from vw_pr ";
|
||||
qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where (trim(trxidpr) like '%" +
|
||||
|
||||
Reference in New Issue
Block a user