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:
@ -169,6 +169,11 @@ class PoAdapter extends Adapter {
|
||||
let ratepo = req.body.ratepo;
|
||||
let migo = req.body.migo;
|
||||
let idxpoold = req.body.idxpoold;
|
||||
let currency_id = req.body.currency_id ?? null;
|
||||
|
||||
let currencyFieldsPo = 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 = "";
|
||||
if (idxpoold != idxpo && idxpoold != 0) {
|
||||
@ -231,7 +236,7 @@ class PoAdapter extends Adapter {
|
||||
status +
|
||||
"',statusdescription='" +
|
||||
statusdescription +
|
||||
"',iby='" +
|
||||
"'" + currencyFieldsPo + ",iby='" +
|
||||
nik +
|
||||
"',idt=now()";
|
||||
if (result.length > 0) {
|
||||
@ -561,7 +566,10 @@ class PoAdapter extends Adapter {
|
||||
apires.meta["code"] = 500;
|
||||
callback("err", apires);
|
||||
} else {
|
||||
qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
db.query(qry, [], function (err, result1, fields) {
|
||||
if (err) {
|
||||
apires.meta["message"] = err.toString();
|
||||
@ -688,7 +696,10 @@ class PoAdapter extends Adapter {
|
||||
return result3;
|
||||
});
|
||||
});
|
||||
qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
db.query(qry, [], function (err, result1, fields) {
|
||||
if (err) {
|
||||
apires.meta["message"] = err.toString();
|
||||
@ -1053,7 +1064,10 @@ class PoAdapter extends Adapter {
|
||||
apires.meta["code"] = 500;
|
||||
callback("err", apires);
|
||||
} else {
|
||||
qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
db.query(qry, [], function (err, result1, fields) {
|
||||
if (err) {
|
||||
apires.meta["message"] = err.toString();
|
||||
@ -1112,7 +1126,10 @@ class PoAdapter extends Adapter {
|
||||
apires.meta["code"] = 500;
|
||||
callback("err", apires);
|
||||
} else {
|
||||
qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
db.query(qry, [], function (err, result1, fields) {
|
||||
if (err) {
|
||||
apires.meta["message"] = err.toString();
|
||||
@ -1180,7 +1197,10 @@ class PoAdapter extends Adapter {
|
||||
apires.meta["code"] = 500;
|
||||
callback("err", apires);
|
||||
} else {
|
||||
qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
db.query(qry, [], function (err, result1, fields) {
|
||||
if (err) {
|
||||
apires.meta["message"] = err.toString();
|
||||
@ -1657,7 +1677,10 @@ class PoAdapter extends Adapter {
|
||||
let keyword = req.query.keyword;
|
||||
let nik = req.body.nik;
|
||||
|
||||
let qry = "select * from vw_po ";
|
||||
let qryBase = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol ";
|
||||
qryBase += "from vw_po v left join tbl_po po on po._idx = v._idx ";
|
||||
qryBase += "left join tbl_currency c on c._idx = po.currency_id ";
|
||||
let qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where trim(ponumber) like '%" +
|
||||
@ -1689,7 +1712,7 @@ class PoAdapter extends Adapter {
|
||||
"totalpage": pagination,
|
||||
"totalrows": result.length,
|
||||
});
|
||||
qry = "select * from vw_po ";
|
||||
qry = qryBase;
|
||||
qry = qry + "where trim(ponumber) like '%" + keyword + "%' and ponumber<>'000' and status in (2,3,4,5,6)";
|
||||
if (nik) {
|
||||
if (!proc_users.includes(nik)) {
|
||||
@ -1735,7 +1758,10 @@ class PoAdapter extends Adapter {
|
||||
let nik = req.query.nik;
|
||||
// let nik = req.body.nik;
|
||||
|
||||
let qry = "select * from vw_po ";
|
||||
let qryBase = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol ";
|
||||
qryBase += "from vw_po v left join tbl_po po on po._idx = v._idx ";
|
||||
qryBase += "left join tbl_currency c on c._idx = po.currency_id ";
|
||||
let qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where trim(ponumber) like '%" +
|
||||
@ -1765,7 +1791,7 @@ class PoAdapter extends Adapter {
|
||||
"totalpage": pagination,
|
||||
"totalrows": result.length,
|
||||
});
|
||||
qry = "select * from vw_po ";
|
||||
qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where trim(ponumber) like '%" +
|
||||
@ -1869,7 +1895,10 @@ class PoAdapter extends Adapter {
|
||||
let keyword = req.query.keyword;
|
||||
// let nik = req.body.nik;
|
||||
|
||||
let qry = "select * from vw_po ";
|
||||
let qryBase = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol ";
|
||||
qryBase += "from vw_po v left join tbl_po po on po._idx = v._idx ";
|
||||
qryBase += "left join tbl_currency c on c._idx = po.currency_id ";
|
||||
let qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where trim(ponumber) like '%" +
|
||||
@ -1895,7 +1924,7 @@ class PoAdapter extends Adapter {
|
||||
"totalpage": pagination,
|
||||
"totalrows": result.length,
|
||||
});
|
||||
qry = "select * from vw_po ";
|
||||
qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where trim(ponumber) like '%" +
|
||||
@ -2028,7 +2057,10 @@ class PoAdapter extends Adapter {
|
||||
try {
|
||||
let idxpo = req.query.idxpo || req.body.idxpo;
|
||||
|
||||
let qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
let qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
|
||||
// console.log(qry);
|
||||
db.query(qry, [], function (err, result, fields) {
|
||||
@ -2355,7 +2387,10 @@ class PoAdapter extends Adapter {
|
||||
let keyword = req.query.keyword;
|
||||
let nik = req.query.nik;
|
||||
|
||||
let qry = "select * from vw_po ";
|
||||
let qryBase = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol ";
|
||||
qryBase += "from vw_po v left join tbl_po po on po._idx = v._idx ";
|
||||
qryBase += "left join tbl_currency c on c._idx = po.currency_id ";
|
||||
let qry = qryBase;
|
||||
qry =
|
||||
qry +
|
||||
"where (trim(ponumber) like '%" +
|
||||
@ -2711,7 +2746,10 @@ class PoAdapter extends Adapter {
|
||||
apires.meta["code"] = 500;
|
||||
callback("err", apires);
|
||||
} else {
|
||||
qry = "select * from vw_po where _idx='" + idxpo + "'";
|
||||
qry = "select v.*, po.currency_id, po.rate_snapshot, c.currency AS currency_code, c.symbol AS currency_symbol "
|
||||
+ "from vw_po v left join tbl_po po on po._idx = v._idx "
|
||||
+ "left join tbl_currency c on c._idx = po.currency_id "
|
||||
+ "where v._idx='" + idxpo + "'";
|
||||
db.query(qry, [], function (err, result1, fields) {
|
||||
if (err) {
|
||||
apires.meta["message"] = err.toString();
|
||||
|
||||
Reference in New Issue
Block a user