天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 1963|回复: 0

[Iscript] 获取某几个月客户销量【业务逻辑函数】

[复制链接]
purple 发表于 2011-11-29 11:35:25 | 显示全部楼层 |阅读模式
本帖最后由 purple 于 2012-12-17 10:17 编辑

函数格式:
getCustomerSalesByMonths(customerno, startDate, isLastYear, beginNum, endNum)
函数说明:
customerno: 客户号
startDate: 日期,根据此日期获取财务年
isLastYear: 是否上年
beginNum: 开始月份
endNum: 结束月份
示例:
实现getCustomerSalesByMonths(customerno, startDate, isLastYear, beginNum, endNum)函数的应用

  1. function getCustomerSalesByMonths(customerno, startDate, isLastYear, beginNum, endNum) {
  2.         var year = "";
  3.         var strDate = "";
  4.         var iyear = 0; //var startDate = getItemValueAsDate("startdate");
  5.         if (startDate != null) {
  6.                 strDate = format(startDate, "yyyy-MM-dd");
  7.         }
  8.         var sql = "select * from TLK_CALENDAR where '" + strDate + "' between ITEM_FROM and ITEM_TO";
  9.         var cal = findBySQL(sql);
  10.         year = cal.getItemValueAsString("year");
  11.         if (year != null && year.length() > 3) {
  12.                 iyear = parseInt(year.substring(2, year.length()));
  13.                 if (isLastYear) iyear = iyear - 1;
  14.         }
  15.         var syear = "FY" + iyear;

  16.          //var customerno = getItemValue("customerno");
  17.         var countSql = "select SUM(item_sales) from tlk_customersales  where ITEM_customerno='" + customerno + "'"
  18.                 + " and ITEM_SALESSTARTDATE >= (select MIN(item_from) from TLK_CALENDAR where ITEM_YEAR='" + syear + "' and item_num between "+beginNum+" and "+endNum+")"
  19.                 + " and ITEM_SALEENDDATE <= (select MAX(item_to) from TLK_CALENDAR where ITEM_YEAR='" + syear + "' and item_num between "+beginNum+" and "+endNum+")";
  20.         var value = sumBySQL(countSql);
  21.         return value;
  22. }
复制代码
调用

  1. #include " businesslib";
  2. getCustomerSalesByMonths ("customerno", " startDate", " isLastYear", " beginNum", " endNum");
复制代码

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 09:35

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表