function check_credit_threshold(){
var todaysDate = new todaysDate().toString().slice(4, -24);
var body = 'Employee ID, Employee Name,Credit Threshold \n';
var query = "SELECT \"EMP_ID\",\"EMP_NAME\",\"CRD_THRD\" FROM \"_SYS_BIC\".\"CreditHistory/E_CREDIT_HISTORY\" ";
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement(query);
pstmt.execute();
var rs = pstmt.getResultSet();
while(rs.next()) {
body += rs.getString(1)+
","+rs.getString(2).replace(/,/g,' ')+
","+rs.getString(3).replace(/,/g,' ')+"\r\n";
}
var mail = new $.net.Mail({
sender: {address: "hstryCheck@mydemo.com"},
to: [{ name: "Demo Company Credit History", address: "pallab@mydemo.com", nameEncoding: "US-ASCII"}],
cc: ["debu123@mydemo.com", "rita456@mydemo.com"],
subject: "Demo Company Credit History",
subjectEncoding: "UTF-8",
parts: [ new $.net.Mail.Part({
type: $.net.Mail.Part.TYPE_TEXT,
text: " Please Demo Company Credit History for Date " + todaysDate,
contentType: "text/plain",
encoding: "UTF-8"
})]
});
mail.parts.push(
new $.net.Mail.Part({
type: $.net.Mail.Part.TYPE_ATTACHMENT,
data: (body),
contentType: "application/vnd.ms-excel; charset=utf-16le",
encoding: "UTF-8",
fileName: "Credit_History" + ' ' + todaysDate + ".csv"
})
);
mail.send();
rs.close();
pstmt.close();
conn.close();
/*var columnCount = 0;*/
var columnCount = 0;
var todaysDate1 = new todaysDate().toString().slice(4, -24);
var body1 = 'Employee ID,Credit Threshold \n';
var query1 = "SELECT \"EMP_ID\",\"CRD_THRD\" FROM \"_SYS_BIC\".\"CreditHistory/E_CREDIT_HISTORY\" ";
var conn1 = $.db.getConnection();
var pstmt1 = conn1.prepareStatement(query1);
pstmt1.execute();
var rs1 = pstmt1.getResultSet();
while(rs1.next()) {
var rcount= 0;
rcount = Number(rs1.getString(2));
if (rcount>150)
{
body1 += rs1.getString(1).replace(/,/g,' ')+
"\t"+rs1.getString(2)+ "\r\n";
columnCount += 1;
}
}
if( columnCount > 0)
{
var mail1 = new $.net.Mail({
sender: {address: ""hstryCheck@mydemo.com"},
to: [{ name: "Demo Company Credit History Exceeds", address: "pallab@mydemo.com", nameEncoding: "US-ASCII"}],
cc: ["debu123@mydemo.com", "rita456@mydemo.com"],
subject: "Customer credit threshold exceeds and more than 150, Please blok credit card",
subjectEncoding: "UTF-8",
parts: [ new $.net.Mail.Part({
type: $.net.Mail.Part.TYPE_TEXT,
text: "Customer credit threshold exceeds and more than 150 " + todaysDate1 + "\r\n" + ". Please blok credit card",
contentType: "text/plain",
encoding: "UTF-8"
})]
});
mail1.parts.push(
new $.net.Mail.Part({
type: $.net.Mail.Part.TYPE_ATTACHMENT,
data: (body1),
contentType: "application/vnd.ms-excel",
encoding: "UTF-8",
fileName: "Customer_Credit_Exceeds_list" + ' ' + todaysDate + ".xls"
})
);
mail1.send();
}
rs1.close();
pstmt1.close();
conn1.close();
}
{
"description": "Demo Company Credit History",
"action": "CreditHistory:DEMO_NOTOFICATION_TEST.xsjs::check_credit_threshold",
"schedules":
[
{
"description": "Generate Demo Company Credit History",
"xscron": "* * * mon:fri 8 0 0"
}
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 |