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

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

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

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

函数格式:
getCustomerSales(customerno, startDate, isLastYear, quarter)
函数说明:
Customerno : 客户号
startDate : 日期,根据此日期获取财务年
isLastYear : 是否上年
quarter : 季度,1/2/3/4
示例:
实现getCustomerSales(customerno, startDate, isLastYear, quarter)函数的应用
  1. function getCustomerSales(customerno, startDate, isLastYear, quarter) {
  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 sqlQuarter = "";
  17.         if (quarter) {
  18.                 sqlQuarter = " and item_quarter=" + quarter;
  19.         } //var customerno = getItemValue("customerno");
  20.         var countSql = "select SUM(item_sales) from tlk_customersales  where ITEM_customerno='" + customerno + "'"
  21.                 + " and ITEM_SALESSTARTDATE >= (select MIN(item_from) from TLK_CALENDAR where ITEM_YEAR='" + syear + "'" + sqlQuarter + ")"
  22.                 + " and ITEM_SALEENDDATE <= (select MAX(item_to) from TLK_CALENDAR where ITEM_YEAR='" + syear + "'" + sqlQuarter + ")";
  23.         var value = sumBySQL(countSql);
  24.         return value;
  25. }
复制代码
调用
  1. #include " businesslib";
  2. getCustomerSales("customerno", "startDate", "isLastYear", "quarter");
复制代码

本版积分规则

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

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

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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