|
|
本帖最后由 purple 于 2012-12-17 10:17 编辑
函数格式:
getCustomerSalesByMonths(customerno, startDate, isLastYear, beginNum, endNum)
函数说明:
customerno: 客户号
startDate: 日期,根据此日期获取财务年
isLastYear: 是否上年
beginNum: 开始月份
endNum: 结束月份
示例:
实现getCustomerSalesByMonths(customerno, startDate, isLastYear, beginNum, endNum)函数的应用
- function getCustomerSalesByMonths(customerno, startDate, isLastYear, beginNum, endNum) {
- var year = "";
- var strDate = "";
- var iyear = 0; //var startDate = getItemValueAsDate("startdate");
- if (startDate != null) {
- strDate = format(startDate, "yyyy-MM-dd");
- }
- var sql = "select * from TLK_CALENDAR where '" + strDate + "' between ITEM_FROM and ITEM_TO";
- var cal = findBySQL(sql);
- year = cal.getItemValueAsString("year");
- if (year != null && year.length() > 3) {
- iyear = parseInt(year.substring(2, year.length()));
- if (isLastYear) iyear = iyear - 1;
- }
- var syear = "FY" + iyear;
- //var customerno = getItemValue("customerno");
- var countSql = "select SUM(item_sales) from tlk_customersales where ITEM_customerno='" + customerno + "'"
- + " and ITEM_SALESSTARTDATE >= (select MIN(item_from) from TLK_CALENDAR where ITEM_YEAR='" + syear + "' and item_num between "+beginNum+" and "+endNum+")"
- + " and ITEM_SALEENDDATE <= (select MAX(item_to) from TLK_CALENDAR where ITEM_YEAR='" + syear + "' and item_num between "+beginNum+" and "+endNum+")";
- var value = sumBySQL(countSql);
- return value;
- }
复制代码 调用
- #include " businesslib";
- getCustomerSalesByMonths ("customerno", " startDate", " isLastYear", " beginNum", " endNum");
复制代码 |
|