123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- $PBExportHeader$f_getcusrepamt_info.srf
- global type f_getcusrepamt_info from function_object
- end type
- forward prototypes
- global function integer f_getcusrepamt_info (long arg_scid, long arg_cusid, long arg_moneyid, ref decimal arg_cusbalcamt, ref decimal arg_cusmaxamt, ref decimal arg_outrep_balcamt, ref decimal arg_outrep_maxamt)
- end prototypes
- global function integer f_getcusrepamt_info (long arg_scid, long arg_cusid, long arg_moneyid, ref decimal arg_cusbalcamt, ref decimal arg_cusmaxamt, ref decimal arg_outrep_balcamt, ref decimal arg_outrep_maxamt);//f_getcusrepamt_info(arg_cusid,arg_cusbalcamt,arg_cusmaxamt,arg_outrep_balcamt,arg_outrep_maxamt)
- Long rslt = 1
- Decimal cusamt,cusmaxamt,outrep_amt,outrep_maxamt,rep_cus_count
- String custype
- IF sys_option_scid_msttake_mstpay = 1 THEN
- SELECT u_cust.custype,
- u_cust.maxmtnum,
- isnull(v_cus_balcamt.cus_balcamt ,0)
- INTO :custype,:cusmaxamt,:cusamt
- FROM u_cust left OUTER join
- v_cus_balcamt on u_cust.cusid = v_cus_balcamt.cusid
- WHERE ( u_cust.cusid = :arg_cusid )
- AND isnull(v_cus_balcamt.scid,0) = :arg_scid
- And IsNull(v_cus_balcamt.moneyid,0) = :arg_moneyid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- SELECT u_outrepdef.maxamt,
- count(v_cus_balcamt.cus_balcamt) as rep_cus_count,
- sum(v_cus_balcamt.cus_balcamt) as outrep_balcamt
- INTO :outrep_maxamt,
- :rep_cus_count,
- :outrep_amt
- FROM u_cust,
- v_cus_balcamt,
- u_outrepdef
- WHERE ( u_cust.cusid = v_cus_balcamt.cusid )
- AND ( u_cust.custype = u_outrepdef.outrepname)
- AND ( u_cust.custype = :custype )
- AND isnull(v_cus_balcamt.scid ,0) = :arg_scid
- AND isnull(v_cus_balcamt.moneyid ,0) = :arg_moneyid
- Group By u_cust.custype ,u_outrepdef.maxamt;
- IF sqlca.SQLCode <> 0 THEN
- // rslt = 0
- // GOTO ext
- outrep_maxamt = 0
- rep_cus_count = 0
- outrep_amt = 0
- END IF
- ELSE
- SELECT u_cust.custype,
- u_cust.maxmtnum,
- sum(v_cus_balcamt.cus_balcamt)
- INTO :custype,:cusmaxamt,:cusamt
- FROM u_cust,
- v_cus_balcamt
- WHERE ( u_cust.cusid = v_cus_balcamt.cusid ) AND
- ( u_cust.cusid = :arg_cusid ) AND
- ( v_cus_balcamt.moneyid = :arg_moneyid)
- Group By u_cust.custype,u_cust.maxmtnum;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- SELECT u_outrepdef.maxamt,
- count(v_cus_balcamt.cus_balcamt) as rep_cus_count,
- sum(v_cus_balcamt.cus_balcamt) as outrep_balcamt
- INTO :outrep_maxamt,
- :rep_cus_count,
- :outrep_amt
- FROM u_cust,
- v_cus_balcamt,
- u_outrepdef
- WHERE ( u_cust.cusid = v_cus_balcamt.cusid )
- AND ( u_cust.custype = u_outrepdef.outrepname)
- AND ( u_cust.custype = :custype )
- AND isnull(v_cus_balcamt.moneyid ,0) = :arg_moneyid
- Group By u_cust.custype ,u_outrepdef.maxamt;
- IF sqlca.SQLCode <> 0 THEN
- // rslt = 0
- // GOTO ext
- outrep_maxamt = 0
- rep_cus_count = 0
- outrep_amt = 0
- END IF
- END IF
- IF IsNull(cusamt) THEN cusamt = 0
- IF IsNull(cusmaxamt) THEN cusmaxamt = 0
- IF IsNull(outrep_amt) THEN outrep_amt = 0
- IF IsNull(outrep_maxamt) THEN outrep_maxamt = 0
- arg_cusbalcamt = cusamt
- arg_cusmaxamt = cusmaxamt
- arg_outrep_balcamt = outrep_amt
- arg_outrep_maxamt = outrep_maxamt
- rslt = rep_cus_count
- ext:
- RETURN rslt
- end function
|