File mfg/2013/base/src/QAD_CustProfitability.p changed (mode: 100644) (index 6376615..1c1a8e5) |
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* */ |
|
10 |
9 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
11 |
10 |
/* Report matches gltbrp.p for use by QAD Reporting Framework */ |
/* Report matches gltbrp.p for use by QAD Reporting Framework */ |
12 |
11 |
/*---------------------------------------------------------------------------*/ |
/*---------------------------------------------------------------------------*/ |
|
... |
... |
define var stringVar as char. |
1032 |
1031 |
custto = trim(stringVar) no-error. |
custto = trim(stringVar) no-error. |
1033 |
1032 |
/*c1485* end added code */ |
/*c1485* end added code */ |
1034 |
1033 |
|
|
|
1034 |
|
/*nac*/ if begdt = ? then begdt = low_date. |
|
1035 |
|
/*nac*/ if enddt = ? then enddt = hi_date. |
|
1036 |
|
|
1035 |
1037 |
if begdt = ? |
if begdt = ? |
1036 |
1038 |
then do: |
then do: |
1037 |
1039 |
find last glc_cal no-lock |
find last glc_cal no-lock |
|
... |
... |
define var stringVar as char. |
1102 |
1104 |
/* Run the Trial Balance Report */ |
/* Run the Trial Balance Report */ |
1103 |
1105 |
{gprun.i ""gltrbl01.p""} |
{gprun.i ""gltrbl01.p""} |
1104 |
1106 |
*<<*/ |
*<<*/ |
1105 |
|
|
|
|
1107 |
|
/*nac>>*/ |
|
1108 |
|
if custto = "" then custto = hi_char. |
|
1109 |
|
/*nac<<*/ |
|
1110 |
|
|
|
1111 |
|
for each cm_mstr |
|
1112 |
|
where |
|
1113 |
|
cm_domain = global_domain |
|
1114 |
|
and cm_addr >= custfrom |
|
1115 |
|
and cm_addr <= custto |
|
1116 |
|
no-lock: |
1106 |
1117 |
for each ih_hist |
for each ih_hist |
1107 |
1118 |
where ih_hist.ih_domain = global_domain |
where ih_hist.ih_domain = global_domain |
1108 |
1119 |
and ih_inv_date >= begdt |
and ih_inv_date >= begdt |
1109 |
1120 |
and ih_inv_date <= enddt |
and ih_inv_date <= enddt |
1110 |
|
/*c1485* start added code */ |
|
1111 |
|
and ih_cust >= custfrom |
|
1112 |
|
and ih_cust <= custto |
|
1113 |
|
/*c1485* end added code */ |
|
|
1121 |
|
/*nac |
|
1122 |
|
* /*c1485* start added code */ |
|
1123 |
|
* and ih_cust >= custfrom |
|
1124 |
|
* and ih_cust <= custto |
|
1125 |
|
* /*c1485* end added code */ |
|
1126 |
|
*/ |
|
1127 |
|
/*nac*/ and ih_cust = cm_addr |
1114 |
1128 |
no-lock |
no-lock |
1115 |
1129 |
break by ih_cust: |
break by ih_cust: |
1116 |
1130 |
for each idh_hist |
for each idh_hist |
|
... |
... |
define var stringVar as char. |
1133 |
1147 |
input idh_part). |
input idh_part). |
1134 |
1148 |
*<<*/ |
*<<*/ |
1135 |
1149 |
|
|
|
1150 |
|
/* |
1136 |
1151 |
find cm_mstr where |
find cm_mstr where |
1137 |
1152 |
cm_domain = global_domain and |
cm_domain = global_domain and |
1138 |
1153 |
cm_addr = ih_cust |
cm_addr = ih_cust |
1139 |
1154 |
no-lock no-error. |
no-lock no-error. |
1140 |
1155 |
if available cm_mstr then do: |
if available cm_mstr then do: |
|
1156 |
|
*/ |
1141 |
1157 |
assign vsort = cm_sort |
assign vsort = cm_sort |
1142 |
1158 |
vglobal = if cm_type begins "AU" then "Domestic" else "Export" |
vglobal = if cm_type begins "AU" then "Domestic" else "Export" |
1143 |
1159 |
vsegment = substring(cm_type,1,2) |
vsegment = substring(cm_type,1,2) |
1144 |
1160 |
vregion = cm_region. |
vregion = cm_region. |
|
1161 |
|
/* |
1145 |
1162 |
end. |
end. |
|
1163 |
|
*/ |
1146 |
1164 |
find pt_mstr where |
find pt_mstr where |
1147 |
1165 |
pt_domain = global_domain and |
pt_domain = global_domain and |
1148 |
1166 |
pt_part = idh_part |
pt_part = idh_part |
|
... |
... |
define var stringVar as char. |
1264 |
1282 |
/*gbg*/ end. |
/*gbg*/ end. |
1265 |
1283 |
end. |
end. |
1266 |
1284 |
end. |
end. |
1267 |
|
if last-of(ih_cust) then do: |
|
|
1285 |
|
end. |
|
1286 |
|
assign vsort = cm_sort |
|
1287 |
|
vglobal = if cm_type begins "AU" then "Domestic" else "Export" |
|
1288 |
|
vsegment = substring(cm_type,1,2) |
|
1289 |
|
vregion = cm_region. |
|
1290 |
|
/* if last-of(ih_cust) then do: */ |
1268 |
1291 |
vfreight = 0. |
vfreight = 0. |
1269 |
1292 |
vdiscount = 0. |
vdiscount = 0. |
1270 |
1293 |
vterms = 0. |
vterms = 0. |
|
... |
... |
define var stringVar as char. |
1278 |
1301 |
if available Company then do: |
if available Company then do: |
1279 |
1302 |
for each GL where |
for each GL where |
1280 |
1303 |
/*c1485* lookup(GLCode, "41745,41765,41725,41735,41755") > 0 */ |
/*c1485* lookup(GLCode, "41745,41765,41725,41735,41755") > 0 */ |
1281 |
|
/*c1485*/ lookup(GLCode, "41745,41765,41725,41735,41755,51500") > 0 |
|
|
1304 |
|
/*c1485*/ lookup(GLCode, "41745,41765,41725,41735,41755,51500,50700") > 0 |
1282 |
1305 |
no-lock: |
no-lock: |
1283 |
1306 |
for each PostingLine where |
for each PostingLine where |
1284 |
1307 |
PostingLine.Company_ID = Company.Company_ID |
PostingLine.Company_ID = Company.Company_ID |
1285 |
1308 |
and PostingLine.GL_ID = GL.GL_ID |
and PostingLine.GL_ID = GL.GL_ID |
1286 |
1309 |
and PostingYearPeriod >= begyearper |
and PostingYearPeriod >= begyearper |
1287 |
1310 |
and PostingYearPeriod <= endyearper |
and PostingYearPeriod <= endyearper |
1288 |
|
and (PostingLineCreditTC + PostingLineDebitTC) <> 0 |
|
|
1311 |
|
and (PostingLineDebitTC - PostingLineCreditTC) <> 0 |
1289 |
1312 |
and can-find(first Division where |
and can-find(first Division where |
1290 |
1313 |
Division.Division_ID = PostingLine.Division_ID and |
Division.Division_ID = PostingLine.Division_ID and |
1291 |
|
DivisionCode = ih_cust) |
|
|
1314 |
|
DivisionCode = cm_addr) |
1292 |
1315 |
no-lock: |
no-lock: |
1293 |
1316 |
|
|
1294 |
1317 |
create ttCustProfit. |
create ttCustProfit. |
1295 |
1318 |
assign |
assign |
|
1319 |
|
/* |
1296 |
1320 |
ttCustProfit.InvDate = ih_inv_date |
ttCustProfit.InvDate = ih_inv_date |
1297 |
1321 |
ttCustProfit.Invbill = ih_bill |
ttCustProfit.Invbill = ih_bill |
1298 |
1322 |
ttCustProfit.SoNumber = ih_nbr |
ttCustProfit.SoNumber = ih_nbr |
1299 |
1323 |
ttCustProfit.InvoiceNumber = ih_inv_nbr |
ttCustProfit.InvoiceNumber = ih_inv_nbr |
1300 |
|
ttCustProfit.InvCust = ih_cust |
|
|
1324 |
|
*/ |
|
1325 |
|
ttCustProfit.InvCust = cm_addr |
1301 |
1326 |
ttCustProfit.CustSort = vsort |
ttCustProfit.CustSort = vsort |
1302 |
1327 |
ttCustProfit.CustRegion = vregion |
ttCustProfit.CustRegion = vregion |
1303 |
1328 |
ttCustProfit.CustGlobal = vglobal |
ttCustProfit.CustGlobal = vglobal |
1304 |
1329 |
ttCustProfit.CustSegment = vsegment |
ttCustProfit.CustSegment = vsegment |
1305 |
|
ttCustProfit.DivCode = ih_cust |
|
|
1330 |
|
ttCustProfit.DivCode = cm_addr |
1306 |
1331 |
ttCustProfit.LineGLCode = GL.GLCode |
ttCustProfit.LineGLCode = GL.GLCode |
1307 |
1332 |
ttCustProfit.RangeBeg = begdt |
ttCustProfit.RangeBeg = begdt |
1308 |
1333 |
ttCustProfit.RangeEnd = enddt |
ttCustProfit.RangeEnd = enddt |
|
... |
... |
define var stringVar as char. |
1312 |
1337 |
if lookup(GL.GLCode,"41745,41765") > 0 |
if lookup(GL.GLCode,"41745,41765") > 0 |
1313 |
1338 |
then |
then |
1314 |
1339 |
ttCustProfit.InvDisc = |
ttCustProfit.InvDisc = |
1315 |
|
(PostingLineCreditTC + PostingLineDebitTC). |
|
|
1340 |
|
(PostingLineDebitLC - PostingLineCreditLC). |
1316 |
1341 |
/*c1485* start added code */ |
/*c1485* start added code */ |
1317 |
1342 |
else if Gl.GlCode = "51500" |
else if Gl.GlCode = "51500" |
1318 |
1343 |
then ttCustProfit.InvFreight = |
then ttCustProfit.InvFreight = |
1319 |
1344 |
/*c1485a vfreight. */ |
/*c1485a vfreight. */ |
1320 |
|
(PostingLineCreditTC + PostingLineDebitTC). |
|
|
1345 |
|
(PostingLineDebitLC - PostingLineCreditLC). |
1321 |
1346 |
/*c1485* end added code */ |
/*c1485* end added code */ |
|
1347 |
|
else if GL.GLCode = "50700" |
|
1348 |
|
then |
|
1349 |
|
ttCustProfit.Commission = |
|
1350 |
|
(PostingLineDebitLC - PostingLineCreditLC). |
1322 |
1351 |
else |
else |
1323 |
1352 |
ttCustProfit.InvTerms = |
ttCustProfit.InvTerms = |
1324 |
|
(PostingLineCreditTC + PostingLineDebitTC). |
|
|
1353 |
|
(PostingLineDebitLC - PostingLineCreditLC). |
1325 |
1354 |
end. |
end. |
1326 |
1355 |
end. |
end. |
1327 |
1356 |
end. |
end. |
1328 |
1357 |
end. |
end. |
1329 |
|
end. |
|
1330 |
|
end. |
|
|
1358 |
|
/* end. */ |
|
1359 |
|
end. |
1331 |
1360 |
|
|
1332 |
1361 |
/* |
/* |
1333 |
1362 |
/* Copy the data to the Result Dataset */ |
/* Copy the data to the Result Dataset */ |