File mfg/2013/base/src/QAD_CustProfitability.p changed (mode: 100644) (index 4eda6f0..6376615) |
6 |
6 |
/* REVISION: 1.0 LAST MODIFIED: 20-MAY-2013 BY: gbg *c1407* */ |
/* REVISION: 1.0 LAST MODIFIED: 20-MAY-2013 BY: gbg *c1407* */ |
7 |
7 |
/* REVISION: 1.0 LAST MODIFIED: 16-SEP-2014 BY: gbg *c1485* */ |
/* REVISION: 1.0 LAST MODIFIED: 16-SEP-2014 BY: gbg *c1485* */ |
8 |
8 |
/* REVISION: 1.0 LAST MODIFIED: 18-NOV-2014 BY: nac *c1485a* */ |
/* REVISION: 1.0 LAST MODIFIED: 18-NOV-2014 BY: nac *c1485a* */ |
|
9 |
|
/* REVISION: 1.0 LAST MODIFIED: 09-DEC-2014 BY: nac *c1485b* */ |
9 |
10 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
10 |
11 |
/* Report matches gltbrp.p for use by QAD Reporting Framework */ |
/* Report matches gltbrp.p for use by QAD Reporting Framework */ |
11 |
12 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
|
... |
... |
define temp-table ttCustProfit no-undo |
59 |
60 |
field InvTerms as dec |
field InvTerms as dec |
60 |
61 |
field RangeBeg as date |
field RangeBeg as date |
61 |
62 |
field RangeEnd as date |
field RangeEnd as date |
|
63 |
|
field tbegyearper as int |
|
64 |
|
field tendyearper as int |
62 |
65 |
. |
. |
63 |
66 |
|
|
64 |
67 |
/*c1485* start added code */ |
/*c1485* start added code */ |
65 |
68 |
define temp-table ttReportOptions no-undo |
define temp-table ttReportOptions no-undo |
66 |
69 |
field rptDateBegin as char |
field rptDateBegin as char |
67 |
|
field rptEndDate as char |
|
|
70 |
|
field rptDateEnd as char |
68 |
71 |
field rptCustFrom as char |
field rptCustFrom as char |
69 |
72 |
field rptCustTo as char |
field rptCustTo as char |
70 |
73 |
. |
. |
|
... |
... |
run CreateField in reportHandle |
675 |
678 |
|
|
676 |
679 |
run CreateField in reportHandle |
run CreateField in reportHandle |
677 |
680 |
(buffername, |
(buffername, |
678 |
|
"ReportEnd", |
|
|
681 |
|
"RangeEnd", |
679 |
682 |
"End Date", |
"End Date", |
680 |
683 |
"date", |
"date", |
681 |
684 |
"99/99/99", |
"99/99/99", |
|
... |
... |
run CreateField in reportHandle |
693 |
696 |
"", |
"", |
694 |
697 |
{&ParameterValueType_Constant}). |
{&ParameterValueType_Constant}). |
695 |
698 |
|
|
|
699 |
|
run CreateField in reportHandle |
|
700 |
|
(buffername, |
|
701 |
|
"tbegyearper", |
|
702 |
|
"BegYrPr", |
|
703 |
|
"int", |
|
704 |
|
"999999", |
|
705 |
|
"", |
|
706 |
|
false, |
|
707 |
|
true, |
|
708 |
|
true, |
|
709 |
|
false, |
|
710 |
|
false, |
|
711 |
|
false, |
|
712 |
|
false, |
|
713 |
|
"", |
|
714 |
|
{&ParameterOperator_Equals}, |
|
715 |
|
{&ParameterValueType_Constant}, |
|
716 |
|
"", |
|
717 |
|
{&ParameterValueType_Constant}). |
|
718 |
|
|
|
719 |
|
run CreateField in reportHandle |
|
720 |
|
(buffername, |
|
721 |
|
"tendyearper", |
|
722 |
|
"EndYrPr", |
|
723 |
|
"int", |
|
724 |
|
"999999", |
|
725 |
|
"", |
|
726 |
|
false, |
|
727 |
|
true, |
|
728 |
|
true, |
|
729 |
|
false, |
|
730 |
|
false, |
|
731 |
|
false, |
|
732 |
|
false, |
|
733 |
|
"", |
|
734 |
|
{&ParameterOperator_Equals}, |
|
735 |
|
{&ParameterValueType_Constant}, |
|
736 |
|
"", |
|
737 |
|
{&ParameterValueType_Constant}). |
696 |
738 |
|
|
697 |
739 |
buffername = "ttReportOptions". |
buffername = "ttReportOptions". |
698 |
740 |
run CreateBufferHeader in reportHandle |
run CreateBufferHeader in reportHandle |
|
... |
... |
define var stringVar as char. |
978 |
1020 |
|
|
979 |
1021 |
/* dates */ |
/* dates */ |
980 |
1022 |
stringVar = getFilterValue("ttReportOptions", "rptDateBegin", ""). |
stringVar = getFilterValue("ttReportOptions", "rptDateBegin", ""). |
|
1023 |
|
/* begdt = date(stringVar) no-error. */ |
981 |
1024 |
begdt = date(stringVar) no-error. |
begdt = date(stringVar) no-error. |
982 |
|
stringVar = getFilterValue("ttReportOptions", "rptEndDate", ""). |
|
|
1025 |
|
stringVar = getFilterValue("ttReportOptions", "rptDateEnd", ""). |
983 |
1026 |
enddt = date(stringVar) no-error. |
enddt = date(stringVar) no-error. |
984 |
1027 |
/*c1485* start added code */ |
/*c1485* start added code */ |
985 |
1028 |
/* Cust Codes */ |
/* Cust Codes */ |
|
... |
... |
define var stringVar as char. |
1009 |
1052 |
then do: |
then do: |
1010 |
1053 |
assign |
assign |
1011 |
1054 |
begdt = glc_start |
begdt = glc_start |
1012 |
|
begyearper = int(string(glc_year,"9999") + string(glc_per,"99")). |
|
|
1055 |
|
endyearper = int(string(glc_year,"9999") + string(glc_per,"99")). |
1013 |
1056 |
end. |
end. |
1014 |
1057 |
end. |
end. |
1015 |
1058 |
end. |
end. |
|
... |
... |
define var stringVar as char. |
1038 |
1081 |
end. |
end. |
1039 |
1082 |
end. |
end. |
1040 |
1083 |
|
|
1041 |
|
|
|
1042 |
|
/* |
|
1043 |
|
if rpt_curr = "" then rpt_curr = base_curr. |
|
1044 |
|
if et_report_curr = "" then et_report_curr = rpt_curr. |
|
1045 |
|
*/ |
|
1046 |
|
|
|
1047 |
|
/* initialise dates from calendar */ |
|
1048 |
|
|
|
1049 |
|
/* |
|
1050 |
|
find first glc_cal no-lock |
|
|
1084 |
|
find last glc_cal no-lock |
1051 |
1085 |
where glc_domain = global_domain |
where glc_domain = global_domain |
1052 |
|
and glc_start <= enddt |
|
1053 |
|
and glc_end >= begdt |
|
1054 |
|
no-error. |
|
1055 |
|
if available glc_cal |
|
1056 |
|
then do: |
|
1057 |
|
yr = glc_year. |
|
1058 |
|
begyearper = int(string(glc_year,"9999") + string(glc_per,"99")). |
|
1059 |
|
find first glc_cal no-lock |
|
1060 |
|
where glc_domain = global_domain |
|
1061 |
|
and glc_year = yr |
|
1062 |
|
and glc_per = 1 |
|
1063 |
|
no-error. |
|
1064 |
|
if available glc_cal |
|
1065 |
|
then do: |
|
1066 |
|
assign |
|
1067 |
|
yr_beg = glc_start. |
|
1068 |
|
end. |
|
1069 |
|
find last glc_cal no-lock |
|
1070 |
|
where glc_domain = global_domain |
|
1071 |
|
and glc_year = yr |
|
1072 |
|
no-error. |
|
1073 |
|
if available glc_cal |
|
1074 |
|
then do: |
|
1075 |
|
assign |
|
1076 |
|
yr_end = glc_end |
|
1077 |
|
end. |
|
1078 |
|
end. |
|
1079 |
|
*/ |
|
1080 |
|
find first glc_cal no-lock |
|
1081 |
|
where glc_domain = global_domain |
|
1082 |
|
and glc_start >= begdt |
|
|
1086 |
|
and glc_start <= begdt |
1083 |
1087 |
no-error. |
no-error. |
1084 |
1088 |
if available glc_cal |
if available glc_cal |
1085 |
1089 |
then |
then |
|
... |
... |
define var stringVar as char. |
1223 |
1227 |
ttCustProfit.LineList = vlist |
ttCustProfit.LineList = vlist |
1224 |
1228 |
ttCustProfit.RangeBeg = begdt |
ttCustProfit.RangeBeg = begdt |
1225 |
1229 |
ttCustProfit.RangeEnd = enddt |
ttCustProfit.RangeEnd = enddt |
|
1230 |
|
ttCustProfit.tbegyearper = begyearper |
|
1231 |
|
ttCustProfit.tendyearper = endyearper |
|
1232 |
|
|
1226 |
1233 |
. |
. |
1227 |
1234 |
|
|
1228 |
|
if last-of(ih_cust) then do: |
|
|
1235 |
|
if last-of(idh_inv_nbr) then do: |
|
1236 |
|
vfreight = 0. |
|
1237 |
|
if ih_trl1_cd <> "10" then |
|
1238 |
|
vfreight = ih_trl1_amt. |
|
1239 |
|
else if ih_trl2_cd <> "10" then |
|
1240 |
|
vfreight = ih_trl2_amt. |
|
1241 |
|
else if ih_trl3_cd <> "10" then |
|
1242 |
|
vfreight = ih_trl3_amt. |
|
1243 |
|
/*gbg*/ if vfreight <> 0 |
|
1244 |
|
/*gbg*/ then do: |
|
1245 |
|
create ttCustProfit. |
|
1246 |
|
assign |
|
1247 |
|
ttCustProfit.InvDate = ih_inv_date |
|
1248 |
|
ttCustProfit.Invbill = ih_bill |
|
1249 |
|
ttCustProfit.SoNumber = ih_nbr |
|
1250 |
|
ttCustProfit.InvoiceNumber = ih_inv_nbr |
|
1251 |
|
ttCustProfit.InvCust = ih_cust |
|
1252 |
|
ttCustProfit.CustSort = vsort |
|
1253 |
|
ttCustProfit.CustRegion = vregion |
|
1254 |
|
ttCustProfit.CustGlobal = vglobal |
|
1255 |
|
ttCustProfit.CustSegment = vsegment |
|
1256 |
|
ttCustProfit.DivCode = DivisionCode |
|
1257 |
|
ttCustProfit.LineGLCode = GL.GLCode |
|
1258 |
|
ttCustProfit.InvFreight = vfreight |
|
1259 |
|
ttCustProfit.RangeBeg = begdt |
|
1260 |
|
ttCustProfit.RangeEnd = enddt |
|
1261 |
|
ttCustProfit.tbegyearper = begyearper |
|
1262 |
|
ttCustProfit.tendyearper = endyearper |
|
1263 |
|
. |
|
1264 |
|
/*gbg*/ end. |
|
1265 |
|
end. |
|
1266 |
|
end. |
|
1267 |
|
if last-of(ih_cust) then do: |
1229 |
1268 |
vfreight = 0. |
vfreight = 0. |
1230 |
1269 |
vdiscount = 0. |
vdiscount = 0. |
1231 |
1270 |
vterms = 0. |
vterms = 0. |
|
... |
... |
define var stringVar as char. |
1242 |
1281 |
/*c1485*/ lookup(GLCode, "41745,41765,41725,41735,41755,51500") > 0 |
/*c1485*/ lookup(GLCode, "41745,41765,41725,41735,41755,51500") > 0 |
1243 |
1282 |
no-lock: |
no-lock: |
1244 |
1283 |
for each PostingLine where |
for each PostingLine where |
1245 |
|
PostingLine.GL_ID = GL.GL_ID |
|
|
1284 |
|
PostingLine.Company_ID = Company.Company_ID |
|
1285 |
|
and PostingLine.GL_ID = GL.GL_ID |
1246 |
1286 |
and PostingYearPeriod >= begyearper |
and PostingYearPeriod >= begyearper |
1247 |
1287 |
and PostingYearPeriod <= endyearper |
and PostingYearPeriod <= endyearper |
|
1288 |
|
and (PostingLineCreditTC + PostingLineDebitTC) <> 0 |
1248 |
1289 |
and can-find(first Division where |
and can-find(first Division where |
1249 |
1290 |
Division.Division_ID = PostingLine.Division_ID and |
Division.Division_ID = PostingLine.Division_ID and |
1250 |
1291 |
DivisionCode = ih_cust) |
DivisionCode = ih_cust) |
1251 |
1292 |
no-lock: |
no-lock: |
1252 |
|
/* |
|
1253 |
|
display |
|
1254 |
|
GL.GLCode |
|
1255 |
|
(PostingLineCreditTC + PostingLineDebitTC). |
|
1256 |
|
*/ |
|
1257 |
1293 |
|
|
1258 |
1294 |
create ttCustProfit. |
create ttCustProfit. |
1259 |
1295 |
assign |
assign |
|
... |
... |
define var stringVar as char. |
1266 |
1302 |
ttCustProfit.CustRegion = vregion |
ttCustProfit.CustRegion = vregion |
1267 |
1303 |
ttCustProfit.CustGlobal = vglobal |
ttCustProfit.CustGlobal = vglobal |
1268 |
1304 |
ttCustProfit.CustSegment = vsegment |
ttCustProfit.CustSegment = vsegment |
1269 |
|
ttCustProfit.DivCode = DivisionCode |
|
|
1305 |
|
ttCustProfit.DivCode = ih_cust |
1270 |
1306 |
ttCustProfit.LineGLCode = GL.GLCode |
ttCustProfit.LineGLCode = GL.GLCode |
|
1307 |
|
ttCustProfit.RangeBeg = begdt |
|
1308 |
|
ttCustProfit.RangeEnd = enddt |
|
1309 |
|
ttCustProfit.tbegyearper = PostingYearPeriod |
|
1310 |
|
ttCustProfit.tendyearper = PostingYearPeriod |
1271 |
1311 |
. |
. |
1272 |
1312 |
if lookup(GL.GLCode,"41745,41765") > 0 |
if lookup(GL.GLCode,"41745,41765") > 0 |
1273 |
1313 |
then |
then |
|
... |
... |
define var stringVar as char. |
1287 |
1327 |
end. |
end. |
1288 |
1328 |
end. |
end. |
1289 |
1329 |
end. |
end. |
1290 |
|
if last-of(idh_inv_nbr) then do: |
|
1291 |
|
if ih_trl1_cd <> "10" then |
|
1292 |
|
vfreight = ih_trl1_amt. |
|
1293 |
|
else if ih_trl2_cd <> "10" then |
|
1294 |
|
vfreight = ih_trl2_amt. |
|
1295 |
|
else if ih_trl3_cd <> "10" then |
|
1296 |
|
vfreight = ih_trl3_amt. |
|
1297 |
|
/*gbg*/ if vfreight <> 0 |
|
1298 |
|
/*gbg*/ then do: |
|
1299 |
|
create ttCustProfit. |
|
1300 |
|
assign |
|
1301 |
|
ttCustProfit.InvDate = ih_inv_date |
|
1302 |
|
ttCustProfit.Invbill = ih_bill |
|
1303 |
|
ttCustProfit.SoNumber = ih_nbr |
|
1304 |
|
ttCustProfit.InvoiceNumber = ih_inv_nbr |
|
1305 |
|
ttCustProfit.InvCust = ih_cust |
|
1306 |
|
ttCustProfit.CustSort = vsort |
|
1307 |
|
ttCustProfit.CustRegion = vregion |
|
1308 |
|
ttCustProfit.CustGlobal = vglobal |
|
1309 |
|
ttCustProfit.CustSegment = vsegment |
|
1310 |
|
ttCustProfit.DivCode = DivisionCode |
|
1311 |
|
ttCustProfit.LineGLCode = GL.GLCode |
|
1312 |
|
ttCustProfit.InvFreight = vfreight |
|
1313 |
|
. |
|
1314 |
|
/*gbg*/ end. |
|
1315 |
|
end. |
|
1316 |
|
end. |
|
1317 |
1330 |
end. |
end. |
1318 |
1331 |
|
|
1319 |
1332 |
/* |
/* |