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:
@ -114,12 +114,17 @@ class JustificationAdapter extends Adapter{
|
||||
let ttd = JSON.parse(req.body.ttd);
|
||||
let status = -1;
|
||||
let statusdescription = "draft";
|
||||
let currency_id = req.body.currency_id ?? null;
|
||||
|
||||
let currencyFieldsJ = 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_justification ";
|
||||
qry = qry +"set idxrequestbudget='"+idxrequestbudget+"', trxid='"+trxid+"',justificationnumber='"+justificationnumber+"',title='"+title+"',division='"+division+"',";
|
||||
qry = qry +"glacc='"+glacc+"',description='"+description+"',budgettype='"+budgettype+"',amount='"+amount+"',useddate='"+useddate+"',textpurpose='"+textpurpose+"',textintroduce='"+textintroduce+"',";
|
||||
qry = qry +"textstrategic='"+textstrategic+"',textbussiness='"+textbussiness+"',textrisk='"+textrisk+"',textfund='"+textfund+"',textrecomendation='"+textrecomendation+"',";
|
||||
qry = qry +"textschedule='"+textschedule+"',status='"+status+"',statusdescription='"+statusdescription+"',filedoc='"+filedoc+"',iby='"+nik+"',idt=now()";
|
||||
qry = qry +"textschedule='"+textschedule+"',status='"+status+"',statusdescription='"+statusdescription+"',filedoc='"+filedoc+"'"+currencyFieldsJ+",iby='"+nik+"',idt=now()";
|
||||
// console.log(qry);
|
||||
db.query(qry,[],function(err,result,fields){
|
||||
if(err){
|
||||
@ -240,12 +245,17 @@ class JustificationAdapter extends Adapter{
|
||||
let filedocqry = "filedoc='"+filedoc+"',";
|
||||
if(filename==""){filedocqry="";}
|
||||
|
||||
let currency_id_ju = req.body.currency_id ?? null;
|
||||
let currencyFieldsJU = currency_id_ju
|
||||
? ",currency_id='"+currency_id_ju+"',rate_snapshot=(select rate from tbl_currency where _idx='"+currency_id_ju+"' and isdeleted=0 limit 1)"
|
||||
: ",currency_id=NULL,rate_snapshot=NULL";
|
||||
|
||||
// console.log(filedocqry);
|
||||
let qry = "update tbl_justification ";
|
||||
qry = qry +"set idxrequestbudget='"+idxrequestbudget+"', trxid='"+trxid+"',justificationnumber='"+justificationnumber+"',title='"+title+"',division='"+division+"',";
|
||||
qry = qry +"glacc='"+glacc+"',description='"+description+"',budgettype='"+budgettype+"',amount='"+amount+"',useddate='"+useddate+"',textpurpose='"+textpurpose+"',textintroduce='"+textintroduce+"',";
|
||||
qry = qry +"textstrategic='"+textstrategic+"',textbussiness='"+textbussiness+"',textrisk='"+textrisk+"',textfund='"+textfund+"',textrecomendation='"+textrecomendation+"',";
|
||||
qry = qry +"textschedule='"+textschedule+"',"+filedocqry+"uby='"+nik+"',udt=now() ";
|
||||
qry = qry +"textschedule='"+textschedule+"',"+filedocqry+currencyFieldsJU.substring(1)+",uby='"+nik+"',udt=now() ";
|
||||
qry = qry +"where _idx='"+idxjustification+"'";
|
||||
|
||||
// console.log(qry);
|
||||
|
||||
Reference in New Issue
Block a user