: !/bin/sh carrier="TELSTRABRSS" month="$1" infile="$2" outfile="$3" datasrcid="$4" ## Testing #month="072008" #infile="tbrss.zip" #outfile="tbrss.out" #datasrcid="21" ##adjmonth=$month ##adjmonth=`../../../adjmonth $month` #datadirpat=`echo "$adjmonth" | awk '{ print "??" substr($1,1,2) substr($1,5,2) }'` #echo "$0: datadirpat=[$datadirpat]" #infile=`ls ${datadirpat}/rcp*.dat` if [ "$outfile" = "" ]; then outfile="${carrier}_${month}.out" fi #echo "$0: infile=[$infile] outfile=[$outfile]" rm -f $outfile #### # from brss zip file # in root #==> zip_info.txt <== #fileformat=07001 #appversionreqd=0700 #MICA|Mobile Services|1029676598|MICA0002281018|25082008|50369 # head if files in BILL1 folder... #==> adjustmt.txt <== #MICA0002281018|0000000000001|||||BLACKBERRY BES XMLPROVISIONING|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST #MICA0002281018|0000000000002|||||BLACKBERRY WEB BROWSER|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST #MICA0002281018|0000000000003|||||GPRS BLACKBERRY BRONZE ACCESS|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST #MICA0002281018|0000000000004|||||GPRS MMS TRIAL APN|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST #MICA0002281018|0000000000005|||||GPRS TELSTRA.COM ACCESS|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST #MICA0002281018|0000000000006|||||GPRS WAP BRONZE ACCESS|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST #MICA0002281018|0000000000007|||||WAP GPRS BROWSER CODE|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST # #==> aust_usg.txt <== # #==> bill.txt <== #MICA0002281018|1029676598|2008-08-25|MICA # #==> bilsumly.txt <== #BTOTOTHR|Sub-total excluding GST|2000|1|N||0|GE #BTOTOTHR|Total GST|2100|1|N||0|GA #BTOTUSAG|Sub-total excluding GST|2000|1|N||0|GE #BTOTUSAG|Total GST|2100|1|N||0|GA #FCABADJS|Adjustments|3100|2|H|SSUMOTHR|3|GI #FCABBILR|Bill Rounding|3000|2|H|SSUMOTHR|3|GI #FCABDIRC|Directory Charges|1200|2|H|SSUMOTHR|5|GE #FCABGRPD|Group Plan Discounts|1400|2|H|SSUMOTHR|3|GE #FCABOTCC|Other Charges & Credits|1300|2|H|SSUMOTHR|8|GE #FCABSREQ|Services and Equipment Rental|1100|2|H|SSUMOTHR|11|GE # #==> call_det_1.txt <== #MICA0002281018|0419930522|FLXC5421|0000000000001|0.07|2008-07-25 06:52:26|0439388190MNET|0439388190MNET|KINGSLEYNTH|26||||00001||0|||0.01|0.08||||||||||||||||||| #MICA0002281018|0419930522|FLXC5421|0000000000002|0.17|2008-07-25 09:59:11|0413652763MNET|0413652763MNET|KINGSLEYNTH|59||||00002||0|||0.01|0.18||||||||||||||||||| #MICA0002281018|0419930522|FLXC5421|0000000000003|1.19|2008-08-04 10:53:10|63043823|63043823|KINGSLEYNTH|713||||00003||0|||0.12|1.31||||||||||||||||||| #MICA0002281018|0419930522|FLXC5421|0000000000004|0.02|2008-08-05 14:00:36|0409373562MNET|0409373562MNET|KINGSLEYNTH|7||||00004||0|||0.00|0.02||||||||||||||||||| #MICA0002281018|0419930522|FLXC5421|0000000000005|0.06|2008-08-15 17:19:53|0422125558MNET|0422125558MNET|KINGSLEYNTH|23||||00005||0|||0.01|0.07||||||||||||||||||| #MICA0002281018|0419930522|FLXC5421|0000000000006|0.19|2008-08-23 17:32:54|0413652763MNET|0413652763MNET|KINGSLEYNTH|111||||00006||0|||0.02|0.21||||||||||||||||||| #MICA0002281018|0419930522|FLXOTHER|0000000000007|0.15|2008-07-29 11:22:45|0430566715|0430566715|JOONDALUP|0|SP|||00007||0|||0.02|0.17||||||||||||||||||| #MICA0002281018|0419930522|FLXOTHER|0000000000008|0.15|2008-08-01 09:16:38|+61401676558MNET|+61401676558MNET|JOONDALUP|0|SP|||00008||0|||0.01|0.16||||||||||||||||||| #MICA0002281018|0419930522|FLXOTHER|0000000000009|0.15|2008-07-28 16:21:19|+48603693658|+48603693658|POLAND M|0||||00009||0|||0.02|0.17||||||||||||||||||| #MICA0002281018|0419930522|FLXOTHER|0000000000010|0.15|2008-07-28 16:21:22|+48603693658|+48603693658|POLAND M|0||||00010||0|||0.01|0.16||||||||||||||||||| # #==> codes.txt <== #AC|*FYI|ZFYIOnly|FYIOnly|FCAB #AC|ACPLC|ZAcPChg|Discount|MICA #AC|ADJUST|ZAdjust|Adjustment|FCAB #AC|ADJUST|ZAdjust|Adjustment|MICA #AC|BILRND|ZbillRound||FCAB #AC|BILRND|ZbillRound||MICA #AC|EQUIPM|ZEquip|Equipment|MICA #AC|GPPLAN|ZGroupPlan|GroupPlanDiscount|MICA #AC|GRPPLN|ZGPDisc|GroupPlanDiscount|FCAB #AC|OCANDC|ZOC&C|OC&C|MICA # #==> ctldat_v.txt <== #controldataversion=040003 # #==> gen_chg.txt <== #MICA0002281018|!DUMMY_EQUIPM|MSVEQUIP|0000000000001|EQUIPMENT ACCOUNT INDICATOR|1|0.00||MICA Equipment Charges - Account||2008-09-24||||0.00|0.00|||||||| #MICA0002281018|!DUMMY_EQUIPM|MSVEQUIP|0000000000002|POSTPAID 3G 850|1|770.00||MICA Equipment Charges - Account||2008-08-25||||77.00|847.00|||||||| #MICA0002281018|0419930522|MICASRVC|0000000000001|CORPORATE FLEXIPLAN ACCESS FEE||0.00||MICA Service Charges|2008-08-25|2008-09-24||||0.00|0.00|||||||| #MICA0002281018|0419930522|MICASRVC|0000000000002|ACCESS TO USE MOBILE OVERSEAS||0.00||MICA Service Charges|2008-08-25|2008-09-24||||0.00|0.00|||||||| #MICA0002281018|0419930522|MICASRVC|0000000000003|MANAGED SERVICES CHARGE||2.00||MICA Service Charges|2008-07-25|2008-08-24||||0.20|2.20|||||||| #MICA0002281018|0419930522|MICASRVC|0000000000004|MSGBANK PREMIUM ACCESS FEE||0.00||MICA Service Charges|2008-08-25|2008-09-24||||0.00|0.00|||||||| #MICA0002281018|0419930522|FCABSPCH|0000000000001|DIALCT-DIALECT INTERACTIVE PTY LTD ABN 99 060 060 862|1|2.27|0000000000|193500MT|2008-07-25 15:37:58||DIALCT|||0.23|2.50|||ITEM(S)||||| #MICA0002281018|0419930522|FCABSPCH|0000000000002|DIALCT-DIALECT INTERACTIVE PTY LTD ABN 99 060 060 862|1|2.27|0000000000|193500MT|2008-07-25 15:38:15||DIALCT|||0.23|2.50|||ITEM(S)||||| #MICA0002281018|0419930522|FCABSPCH|0000000000003|DIALCT-DIALECT INTERACTIVE PTY LTD ABN 99 060 060 862|1|2.27|0000000000|193500MT|2008-08-05 16:10:53||DIALCT|||0.23|2.50|||ITEM(S)||||| #MICA0002281018|0419930522|FCABSPCH|0000000000004|DIALCT-DIALECT INTERACTIVE PTY LTD ABN 99 060 060 862|1|2.28|0000000000|193500MT|2008-08-05 16:11:04||DIALCT|||0.22|2.50|||ITEM(S)||||| # #==> grp_plan.txt <== # #==> med_info.txt <== #Date/Time Processed:26/08/2008 09:54:23 #Batch Number:195978 #Built using Mediation version:H605 # #==> ons_offs.txt <== #MICA0002281018|0427086084|0000000001000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0408939669|0000000002000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0439699721|0000000003000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0439932371|0000000004000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0447896833|0000000005000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0419964219|0000000006000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0408904311|0000000007000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0419093431|0000000008000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0428950499|0000000009000||2||1|Mobile|0000000000|||||SRVONOFF #MICA0002281018|0408941898|0000000010000||2||1|Mobile|0000000000|||||SRVONOFF # #==> rec_chg.txt <== # #==> remap.txt <== #1|1|Y|UT2UC|FLX10171|FUSGFAXC|FUSGCENT|| #1|2|Y|UT2UC|FLX10172|FUSGFAXC|FUSGCENT|| #1|3|Y|UT2UC|FLX10173|FUSGFAXC|FUSGCENT|| #1|4|Y|UT2UC|FLX10174|FUSGFAXC|FUSGCENT|| #1|5|Y|UT2UC|FLX10175|FUSGFAXC|FUSGCENT|| #1|6|Y|UT2UC|FLX10176|FUSGFAXC|FUSGCENT|| #1|7|Y|UT2UC|FLX10345|FUSGFAXC|FUSGCENT|| #1|8|Y|UT2UC|FLX10024|FUSGINET|FUSGCENT|| #1|9|Y|UT2UC|FLX10025|FUSGINET|FUSGCENT|| #1|10|Y|UT2UC|FLX10020|FUSGINET|FUSGCENT|| # #==> remap_ss.txt <== #1|1|Y|20201|Broad re-categorisation of usage types to new/existing usage categories. #2|2|Y|020301|Re-categorisation of usage types from the Data Usage category to ISDN and ISDN (On Ramp). #3|3|Y|020301|Transfer Inventory Ons & Offs amounts from the GST Exclusive column to the GST Inclusive column. #4|4|Y|020302|Re-categorises Other Charges and Credits as Telstra Other Charges and credits. #5|5|Y|030001|Update transmission summary by route information. #6|6|Y|030001|Update Miscellaneous data product description. #7|7|Y|030001|Remove duplicate service types. #8|8|Y|030002|Remove obsolete service types. #9|9|Y|030004|re-mapping of all call types to new call categories #10|11|Y|030101|Call Types Remapping # #==> rep_sum.txt <== #MICA0002281018|!DUMMY_ADJUST|FCABADJS|0.00|000|7|0.00|0.00 #MICA0002281018|!DUMMY_ADJUST|RTOTOTHR|0.00|000|7|0.00|0.00 #MICA0002281018|!DUMMY_BILRND|FCABBILR|0.00|000|1|0.00|-0.28 #MICA0002281018|!DUMMY_BILRND|RTOTOTHR|0.00|000|1|0.00|-0.28 #MICA0002281018|!DUMMY_EQUIPM|BTOTOTHR|770.00|000|2|77.00|847.00 #MICA0002281018|!DUMMY_EQUIPM|FCABOTCC|770.00|000|2|77.00|847.00 #MICA0002281018|!DUMMY_EQUIPM|MSVEQUIP|770.00|000|2|77.00|847.00 #MICA0002281018|!DUMMY_EQUIPM|RTOTOTHR|770.00|000|2|77.00|847.00 #MICA0002281018|0400199895|BTOTOTHR|0.00|000|0|0.00|0.00 #MICA0002281018|0400199895|BTOTUSAG|6.76|000|36|0.68|7.44 # #==> serv_sum.txt <== #MICA0002281018|0419930522|SSUMUSAG|0000000000001|1.70|CALL & TRANSACTION CHARGES||2008-08-24|6|CALLS|NATIONAL DIRECT|0000000000|0.17|1.87| #MICA0002281018|0419930522|SSUMUSAG|0000000000002|0.30|CALL & TRANSACTION CHARGES||2008-08-24|2|CALLS|MOBILE ORIGINATED SMS|0000000000|0.03|0.33| #MICA0002281018|0419930522|SSUMUSAG|0000000000003|3.45|CALL & TRANSACTION CHARGES||2008-08-24|23|CALLS|INTERNATIONAL DIRECT - SMS|0000000000|0.35|3.80| #MICA0002281018|0419930522|SSUMUSAG|0000000000004|0.19|CALL & TRANSACTION CHARGES||2008-08-24|5|CALLS|CALL DIVERSION CHARGES|0000000000|0.01|0.20| #MICA0002281018|0419930522|SSUMOTHR|0000000000005|0.00|SERVICE CHARGES|2008-08-25|2008-09-24|0||CORPORATE FLEXIPLAN ACCESS FEE|0000000000|0.00|0.00| #MICA0002281018|0419930522|SSUMOTHR|0000000000006|0.00|SERVICE CHARGES|2008-08-25|2008-09-24|0||ACCESS TO USE MOBILE OVERSEAS|0000000000|0.00|0.00| #MICA0002281018|0419930522|SSUMOTHR|0000000000007|2.00|SERVICE CHARGES|2008-07-25|2008-08-24|0||MANAGED SERVICES CHARGE|0000000000|0.20|2.20| #MICA0002281018|0419930522|SSUMOTHR|0000000000008|0.00|SERVICE CHARGES|2008-08-25|2008-09-24|0||MSGBANK PREMIUM ACCESS FEE|0000000000|0.00|0.00| #MICA0002281018|0419930522|SSUMOTHR|0000000000009|15.91|TOTAL SEPARATE PURCHASES|||0|||0000000000|1.59|17.50| #MICA0002281018|0419940998|SSUMUSAG|0000000000010|48.45|CALL & TRANSACTION CHARGES||2008-08-24|212|CALLS|NATIONAL DIRECT|0000000000|4.85|53.30| # #==> service.txt <== #0419930522|F0034|0419 930 522||||||. Y WALLWORK ITSS||S #0419940998|F0034|0419 940 998||||||HENRY LIM BPM||S #0419948105|F0034|0419 948 105||||||A BROWN, BPM||S #0419944572|F0034|0419 944 572||||||. . F COLLINS F&S||S #0419938671|F0034|0419 938 671||||||ROB CHANDLER, SSC||S #0419966171|F0034|0419 966 171||||||B LAMBERT, SSC||S #0419935583|F0034|0419 935 583||||||KITSC M GRANT||S #0419836961|F0034|0419 836 961||||||K LAMBERT, SSC||S #0419869887|F0034|0419 869 887||||||R HULL F & S||S #0419836761|F0034|0419 836 761||||||G F&BSC ZLNAY||S # #==> xref.txt <== #BTOTOTHR||TELSTRA|||||||BT|BT|Y||||0||||||OTHER #BTOTUSAG||TELSTRA|||||||BT|BT|Y||||0||||||USAGE #FCABADJS||TELSTRA||||||ADJST|CH|AD|N|FCABADJS|ADJUST|IPLAY27|1||||||OTHER #FCABBILR||TELSTRA||||||BILRD|CH|BR|N|FCABBILR|BILRND|IPLAY49|0||||||OTHER #FCABDIRC||TELSTRA||||||DIRCH|CH|DC|N|FCABDIRC||IPLAY14|0||||||OTHER #FCABGRPD||TELSTRA||||||GRPPD|CH|GD|N|FCABGRPD|GRPPLN|IPLAY13|0||||||OTHER #FCABOTCC||TELSTRA||||||OTCCR|CH|OC|N|FCABOTCC|||0||||||OTHER #FCABSPCH||TELSTRA||||||OTCCR|CS|OC|N|FCABOTCC||IPLAY40|400|SEPPUR|||||OTHER #FCABSREQ||TELSTRA||||||SRVEQ|CH|SE|N|FCABSREQ|||0||||||OTHER #FCABTOCC||TELSTRA||||||OTCCR|CS|OC|N|FCABOTCC|OCANDC|IPLAY10|100|TLSOCC|||||OTHER # ############# #ZZZZZ ( unzip -p "$infile" "zip_info.txt" | sed -e 's/^/zip_info\|/' unzip -p "$infile" "BILL1/xref.txt" | sed -e 's/^/xref\|/' unzip -p "$infile" "BILL1/codes.txt" | sed -e 's/^/codes\|/' unzip -p "$infile" "BILL1/remap.txt" | sed -e 's/^/remap\|/' unzip -p "$infile" "BILL1/bill.txt" | sed -e 's/^/bill\|/' unzip -p "$infile" "BILL1/service.txt" | sed -e 's/^/service\|/' unzip -p "$infile" "BILL1/adjustmt.txt" | sed -e 's/^/adjustmt\|/' unzip -p "$infile" "BILL1/gen_chg.txt" | sed -e 's/^/gen_chg\|/' unzip -p "$infile" "BILL1/serv_sum.txt" | sed -e 's/^/serv_sum\|/' unzip -p "$infile" "BILL1/call_det_1.txt" | sed -e 's/^/call_det_1\|/' ) | sed -e 's/ $//' | \ awk -F '|' -v "billmonth=$month" -v "carrier=$carrier" \ -v "datasrcid=$datasrcid" ' function trim(is) { #sub(/^\"/,"", is) #sub(/\"$/,"", is) while (sub(/^ /, "", is) != 0) is = is "" while (sub(/ $/, "", is) != 0) is = is "" return is } ##################################################### # main BEGIN { monthstr[1] = "Jan"; monthstr[2] = "Feb"; monthstr[3] = "Mar"; monthstr[4] = "Apr"; monthstr[5] = "May"; monthstr[6] = "Jun"; monthstr[7] = "Jul"; monthstr[8] = "Aug"; monthstr[9] = "Sep"; monthstr[10] = "Oct"; monthstr[11] = "Nov"; monthstr[12] = "Dec"; billmm = 0 + substr(billmonth,1,2) billyyyy = 0 + substr(billmonth,3,4) billperiod = monthstr[billmm] " " billyyyy bill_callcounttotal = 0 bill_total_cost = 0.0 } { gsub(/\r/, "") # remove CR gsub(/\032/, "") # remove FF #print $0 f = 0 fname = $(++f) #print "fname=[" fname "]" f01 = $(++f) f02 = $(++f) f03 = $(++f) f04 = $(++f) f05 = $(++f) f06 = $(++f) f07 = $(++f) f08 = $(++f) f09 = $(++f) f10 = $(++f) f11 = $(++f) f12 = $(++f) f13 = $(++f) f14 = $(++f) f15 = $(++f) f16 = $(++f) f17 = $(++f) f18 = $(++f) f19 = $(++f) f20 = $(++f) f21 = $(++f) f22 = $(++f) f23 = $(++f) f24 = $(++f) f25 = $(++f) f26 = $(++f) f27 = $(++f) f28 = $(++f) f29 = $(++f) f30 = $(++f) f31 = $(++f) f32 = $(++f) f33 = $(++f) f34 = $(++f) f35 = $(++f) f36 = $(++f) f37 = $(++f) f38 = $(++f) ######### # zip_info if ( fname == "zip_info" ) { dozip_info() next } # xref if ( fname == "xref" ) { doxref() next } # codes if ( fname == "codes" ) { docodes() next } # remap if ( fname == "remap" ) { doremap() next } # bill if ( fname == "bill" ) { dobill() next } # service if ( fname == "service" ) { doservice() next } # adjustmt if ( fname == "adjustmt" ) { doadjustmt() next } # gen_chg if ( fname == "gen_chg" ) { dogen_chg() next } # serv_sum if ( fname == "serv_sum" ) { doserv_sum() next } # call_det_1 call detail records if ( fname == "call_det_1" ) { docall_det_1() next } } #------------------------------------------------ function dozip_info() { # zip_info #fileformat=07001 #appversionreqd=0700 #MICA|Mobile Services|1029676598|MICA0002281018|25082008|50369 if ( substr(f01,1,10) == "fileformat" ) { fileformat = substr(f01,12) #print "dozip_info() fileformat=[" fileformat "]" return } if ( substr(f01,1,14) == "appversionreqd" ) { appversionreqd = substr(f01,16) #print "dozip_info() appversionreqd=[" appversionreqd "]" return } ffmt = trim(f01) servicetype = trim(f02) mica_number = substr(f04,5) invoice_number = trim(f03) zipdate = trim(f05) idnumber = trim(f06) reccode = "" expect_nflds = 5 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } #print "dozip_info() mica_number=[" mica_number "]" " invoice_number=[" invoice_number "]" " idnumber=[" idnumber "]" return } function docodes() { # codes #CC|NATL|National Calls|TelephoneNational|VOIC #CT|420|National Direct Dialled|| rectype = f01 classtype = f02 classtypedesc = f03 expect_nflds = 4 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = rectype "_" classtype "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } #print "docodes()" codes_rectype_classtype_to_classtypedesc_arr[rectype "|" classtype] = classtypedesc } function doxref() { # xref #FLXA1415||TELSTRA|||VOIC|NATL|415|USAGE|CT||N|FUSGNATL||IPLAY01|11500||F||F0119||USAGE #FCABSPCH||TELSTRA||||||OTCCR|CS|OC|N|FCABOTCC||IPLAY40|400|SEPPUR|||||OTHER reccode = f01 class = f07 chargeclass = f22 expect_nflds = 21 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } #print "doxref()" #xref_reccode_to_xref_arr[reccode] = $0 xref_reccode_to_callclass_arr[reccode] = class xref_reccode_to_chargeclass_arr[reccode] = chargeclass } function doremap() { # remap #16|14|Y|RNXREF|MNATL001|FLXC5421|CALL_DET|| #9|1789|Y|UT2UC|FLXC5376|FUSGMOBN|FUSGMSMS|| #14|3|Y|RNXREF|MICAOTCC|FCABTOCC|GEN_CHG|| #14|4|Y|RNXREF|MICASPCH|FCABSPCH|REP_SUM|| class = f05 reccode = f06 filetype = f07 expect_nflds = 8 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } #print "doremap()" if ( filetype == "CALL_DET" ) { #remap_call_det_reccode_to_remap_arr[reccode] = $0 remap_call_det_reccode_to_callclass_arr[reccode] = class } if ( filetype == "GEN_CHG" ) { remap_gen_chg_reccode_to_callclass_arr[reccode] = class } if ( filetype == "REP_SUM" ) { remap_rep_sum_reccode_to_callclass_arr[reccode] = class } } function dobill() { # bill #MICA0002281018|1029676598|2008-08-25|MICA bill_total_mica_number = substr(f01,5) bill_total_account_number = trim(f02) bill_total_invoice_number = trim(f03) reccode = "" datestr = trim(f03) yyyy = 0 + substr(datestr,1,4) mm = 0 + substr(datestr,6,2) dd = 0 + substr(datestr,9,2) bill_total_to = sprintf("%02d/%02d/%04d", dd, mm, yyyy) #bill_total_from = "dd/mm/yyyy" bill_total_from = "" total_from_to = bill_total_from " to " bill_total_to expect_nflds = 3 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } #print "dobill() mica_number=[" mica_number "]" " account_number=[" account_number "]" " invoice_number=[" invoice_number "]" return } function doservice() { # service #0419930522|F0034|0419 930 522||||||. Y WALLWORK ITSS||S servicenumber = f01 costcentre = f02 name = f09 reccode = "" expect_nflds = 10 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } #print "doservice() name=[" name "]" " servicenumber=[" servicenumber "]" " costcentre=[" costcentre "]" init_servicenumber(servicenumber) servicenumber_to_costcentre_arr[servicenumber] = costcentre servicenumber_to_name_arr[servicenumber] = name # cost centre, name rectype = "CONFIG" recclass = "COSTCENTRE" sdate_str = "" btxt_stime_str = "" btxt_origin = costcentre btxt_destination = name btxt_dialled = "" btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() # name, account number, invoice number rectype = "CONFIG" recclass = "NAME" sdate_str = "" btxt_stime_str = "" btxt_origin = account_number btxt_destination = name btxt_dialled = "" btxt_rate = invoice_number dursecs = 0 costinclgst = 0.0 outrec() return } function doadjustmt() { # adjustmt #MICA0002281018|0000000000001|||||BLACKBERRY BES XMLPROVISIONING|0.00|0.00|0.00|MICA0002281018|FCABADJS|!DUMMY_ADJUST mica_number = substr(f01,5) #servicenumber = ??? servicenumber = "0400000000" reccode = f12 expect_nflds = 12 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } init_servicenumber(servicenumber) #print "doadjustmt() servicenumber=[" servicenumber "]" " reccode=[" reccode "]" rectype = "CHARGE_DESC" recclass = "OTHER" from_date = total_from to_date = total_to sdate_str = to_date btxt_stime_str = "" btxt_origin = reccode btxt_destination = trim(f07) " " trim(f13) # description btxt_dialled = from_date " to " to_date btxt_rate = "" dursecs = 0 costinclgst = 0.0 + trim(f10) if ( costinclgst >= 0 ) { # cost is not negative othertotal_arr[servicenumber] += costinclgst } else { # cost is negative other_discount_arr[servicenumber] += costinclgst } if ( costinclgst != 0 ) outrec() return } function dogen_chg() { # gen_chg #MICA0002281018|!DUMMY_EQUIPM|MSVEQUIP|0000000000002|POSTPAID 3G 850|1|770.00||MICA Equipment Charges - Account||2008-08-25||||77.00|847.00|||||||| #MICA0002281018|0419930522|MICASRVC|0000000000001|CORPORATE FLEXIPLAN ACCESS FEE||0.00||MICA Service Charges|2008-08-25|2008-09-24||||0.00|0.00|||||||| #MICA0002281018|0419930522|FCABSPCH|0000000000001|DIALCT-DIALECT INTERACTIVE PTY LTD ABN 99 060 060 862|1|2.27|0000000000|193500MT|2008-07-25 15:37:58||DIALCT|||0.23|2.50|||ITEM(S)||||| mica_number = substr(f01,5) servicenumber = f02 reccode = f03 expect_nflds = 23 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } if ( servicenumber == "!DUMMY_EQUIPM" ) servicenumber = "0400000000" chargeclass = xref_reccode_to_chargeclass_arr[reccode] init_servicenumber(servicenumber) #print "dogen_chg() servicenumber=[" servicenumber "]" " reccode=[" reccode "]" #rint " chargeclass=[" chargeclass "]" if ( reccode == "MICASRVC" ) { rectype = "CHARGE_DESC" recclass = "RENT" from_date = total_from datestr = trim(f10) yyyy = 0 + substr(datestr,1,4) mm = 0 + substr(datestr,6,2) dd = 0 + substr(datestr,9,2) to_date = sprintf("%02d/%02d/%04d", dd, mm, yyyy) sdate_str = to_date timestr = substr(trim(f10),12) btxt_stime_str = substr(timestr,1,2) substr(timestr,4,2) substr(timestr,7,2) btxt_origin = reccode btxt_destination = trim(f05) " " trim(f09) # description btxt_dialled = from_date " to " to_date btxt_rate = "" dursecs = 0 costinclgst = 0.0 + trim(f16) if ( costinclgst >= 0 ) { # cost is not negative renttotal_arr[servicenumber] += costinclgst } else { # cost is negative rent_discount_arr[servicenumber] += costinclgst } if ( costinclgst != 0 ) { outrec() } return } #if ( reccode == "SSUMUSAG" ) { if ( chargeclass == "OTHER" ) { rectype = "CHARGE_DESC" recclass = "OTHER" datestr = trim(f10) yyyy = 0 + substr(datestr,1,4) mm = 0 + substr(datestr,6,2) dd = 0 + substr(datestr,9,2) to_date = sprintf("%02d/%02d/%04d", dd, mm, yyyy) sdate_str = to_date timestr = substr(trim(f10),12) btxt_stime_str = substr(timestr,1,2) substr(timestr,4,2) substr(timestr,7,2) btxt_origin = reccode btxt_destination = trim(f05) " " trim(f09) # description btxt_dialled = from_date " to " to_date btxt_rate = "" dursecs = 0 costinclgst = 0.0 + trim(f16) if ( costinclgst >= 0 ) { # cost is not negative othertotal_arr[servicenumber] += costinclgst } else { # cost is negative other_discount_arr[servicenumber] += costinclgst } if ( costinclgst != 0 ) outrec() return } return } function doserv_sum() { # serv_sum #MICA0002281018|0419930522|SSUMUSAG|0000000000004|0.19|CALL & TRANSACTION CHARGES||2008-08-24|5|CALLS|CALL DIVERSION CHARGES|0000000000|0.01|0.20| #MICA0002281018|0419930522|SSUMOTHR|0000000000005|0.00|SERVICE CHARGES|2008-08-25|2008-09-24|0||CORPORATE FLEXIPLAN ACCESS FEE|0000000000|0.00|0.00| mica_number = substr(f01,5) servicenumber = f02 reccode = f03 expect_nflds = 14 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds "~" fname "~" "Rec " NR btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } chargeclass = xref_reccode_to_chargeclass_arr[reccode] init_servicenumber(servicenumber) #print "doserv_sum() servicenumber=[" servicenumber "]" " reccode=[" reccode "]" #print " chargeclass=[" chargeclass "]" #if ( reccode == "SSUMUSAG" ) { if ( chargeclass == "USAGE" ) { rectype = "CHARGE_DESC" recclass = "CALL" from_date = total_from datestr = trim(f08) yyyy = 0 + substr(datestr,1,4) mm = 0 + substr(datestr,6,2) dd = 0 + substr(datestr,9,2) to_date = sprintf("%02d/%02d/%04d", dd, mm, yyyy) sdate_str = to_date btxt_stime_str = "" btxt_origin = reccode btxt_destination = trim(f06) " " trim(f11) # description btxt_dialled = from_date " to " to_date btxt_rate = "" dursecs = 0 costinclgst = 0.0 + trim(f14) if ( costinclgst >= 0 ) { # cost is not negative calltotal_arr[servicenumber] += costinclgst } else { # cost is negative call_discount_arr[servicenumber] += costinclgst } if ( costinclgst != 0 ) outrec() } # in gen_charge #if ( reccode == "SSUMOTHR" ) { # rectype = "CHARGE_DESC" # recclass = "OTHER" # # datestr = trim(f07) # yyyy = 0 + substr(datestr,1,4) # mm = 0 + substr(datestr,6,2) # dd = 0 + substr(datestr,9,2) # from_date = sprintf("%02d/%02d/%04d", dd, mm, yyyy) # # datestr = trim(f08) # yyyy = 0 + substr(datestr,1,4) # mm = 0 + substr(datestr,6,2) # dd = 0 + substr(datestr,9,2) # to_date = sprintf("%02d/%02d/%04d", dd, mm, yyyy) # # sdate_str = to_date # btxt_stime_str = "" # btxt_origin = reccode # btxt_destination = trim(f06) " " trim(f11) # description # btxt_dialled = from_date " to " to_date # btxt_rate = "" # dursecs = 0 # costinclgst = 0.0 + trim(f14) # # if ( costinclgst >= 0 ) { # cost is not negative # othertotal_arr[servicenumber] += costinclgst # } # else { # cost is negative # other_discount_arr[servicenumber] += costinclgst # } # # if ( costinclgst != 0 ) # outrec() #} # #return } function docall_det_1() { # call_det_1 #MICA0002281018|0419930522|FLXC5421|0000000000001|0.07|2008-07-25 06:52:26|0439388190MNET|0439388190MNET|KINGSLEYNTH|26||||00001||0|||0.01|0.08||||||||||||||||||| #MICA0002281018|0419930522|FLXOTHER|0000000000007|0.15|2008-07-29 11:22:45|0430566715|0430566715|JOONDALUP|0|SP|||00007||0|||0.02|0.17||||||||||||||||||| #f01 = MICA0002281018 #f02 = 0419930522 #f03 = FLXC5421 #f04 = 0000000000004 #f05 = 0.02 #f06 = 2008-08-05 14:00:36 #f07 = 0409373562MNET #f08 = 0409373562MNET #f09 = KINGSLEYNTH #f10 = 7 #f11 = #f12 = #f13 = #f14 = 00004 #f15 = #f16 = 0 #f17 = #f18 = #f19 = 0.00 #f20 = 0.02 #f21 = #f22 = #f23 = #f24 = #f25 = #f26 = #f27 = #f28 = #f29 = #f30 = #f31 = #f32 = #f33 = #f34 = #f35 = #f36 = #f37 = #f38 = mica_number = substr(f01,5) servicenumber = f02 reccode = f03 # Testing #if ( servicenumber != "0419901849" ) # return expect_nflds = 38 + 2 if ( NF != expect_nflds ) { ++conv_errors rectype = "ERROR" recclass = "CONVERROR" sdate_str = "" btxt_stime_str = "" btxt_origin = reccode "~" NF " fields" "~" "expected " expect_nflds btxt_destination = NR btxt_dialled = NF btxt_rate = "" dursecs = 0 costinclgst = 0.0 outrec() return } init_servicenumber(servicenumber) #print "docall_det_1() servicenumber=[" servicenumber "]" " reccode=[" reccode "]" seq = f04 rectype = "CDR" if ( reccode == "" ) recode = "BLANK" # from xref file xref = xref_reccode_to_xref_arr[reccode] callclass = xref_reccode_to_callclass_arr[reccode] # from codes file callclassdesc = codes_rectype_classtype_to_classtypedesc_arr["CC" "|" callclass] ## from remap file #remap = remap_call_det_reccode_to_remap_arr[reccode] #remapclass = remap_call_det_reccode_to_callclass_arr[reccode] if ( callclass == "" ) callclass = reccode recclass = callclass #printf("Service Number = [%s] Call Class = [%s]\n", servicenumber, callclass); #printf("\n"); #printf("CDR: [%s]\n", $0); #printf("\n"); #printf(" Xref [%s]\n", xref); #printf(" Xref callclass = [%s] callclassdesc = [%s]\n", callclass, callclassdesc); #printf("\n"); #printf(" Remap [%s]\n", remap); #printf(" Remap remapclass = [%s]\n", remapclass); #printf("\n"); datetimestr = trim(f06) #2008-08-05 14:00:36 yyyy = 0 + substr(datetimestr,1,4) mm = 0 + substr(datetimestr,6,2) dd = 0 + substr(datetimestr,9,2) HH = 0 + substr(datetimestr,12,2) MM = 0 + substr(datetimestr,15,2) SS = 0 + substr(datetimestr,18,2) sdate_str = sprintf("%02d/%02d/%04d", dd, mm, yyyy) btxt_stime_str = sprintf("%02d%02d%02d", HH, MM, SS) btxt_origin = trim(f09) btxt_dialled = trim(f07) btxt_destination = btxt_dialled #if ( f07 != f08 ) # print "f07 != f08 [" f07 "]" " [" f08 "]" #printf("DBG: 0 btxt_dialled=[%s]\n", btxt_dialled); #printf("DBG: 0 btxt_destination=[%s]\n", btxt_destination); # process dialled number to remove inconsistencies sub(/MNET/, "", btxt_dialled) # remove MNET sub(/MN/, "", btxt_dialled) # remove MN sub(/C/, "", btxt_dialled) # remove C orgph = btxt_dialled sub(/^\+61/, "0", btxt_dialled) # replace with 0 if ( length(btxt_dialled) >= 13 ) sub(/^0061/, "0", btxt_dialled) # replace with 0 if ( length(btxt_dialled) >= 11 ) sub(/^61/, "0", btxt_dialled) # replace with 0 #printf("DBG: 1 btxt_dialled=[%s]\n", btxt_dialled); # if same them blank the dialed number if not one if ( btxt_destination == btxt_dialled ) { if ( match(btxt_dialled,"[0-9]*") <= 0 ) { btxt_dialled = "" } #printf("DBG: 2 btxt_dialled=[%s]\n", btxt_dialled); } # remove dialled from destination if ( substr(btxt_destination, 1, length(orgph)) == orgph ) { btxt_destination = substr(btxt_destination, length(orgph)+1) #printf("DBG: 2 btxt_destination=[%s]\n", btxt_destination); } # prepend call desc if ( callclassdesc != "" ) { tdest = btxt_destination btxt_destination = callclassdesc if ( btxt_destination != "" && tdest != "" ) btxt_destination = btxt_destination " " btxt_destination = btxt_destination tdest } #printf("DBG: 3 btxt_destination=[%s]\n", btxt_destination); btxt_rate = trim(f11) dursecs = 0 + trim(f10) #exclgst = 0.0 + trim(f05) costinclgst = 0.0 + trim(f20) # add cdr call count/cost ++callcounttotal_arr[servicenumber] outrec() } #--------------------------------- function init_servicenumber(servicenumber) { if ( servicenumber_arr[servicenumber] == 1 ) return servicenumber_arr[servicenumber] = 1 # init totals callcounttotal_arr[servicenumber] = 0 renttotal_arr[servicenumber] = 0.0 rent_discount_arr[servicenumber] = 0.0 calltotal_arr[servicenumber] = 0.0 call_discount_arr[servicenumber] = 0.0 othertotal_arr[servicenumber] = 0.0 other_discount_arr[servicenumber] = 0.0 } #--------------------------------- function finish_mobile(servicenumber) { if ( servicenumber == "" ) return #------------- # CALL_TOTAL (not including discounts) rectype = "CHARGE_DESC_INFO" recclass = "CALL_TOTAL" callcounttotal = callcounttotal_arr[servicenumber] calltotal = calltotal_arr[servicenumber] sdate_str = "" btxt_stime_str = "" btxt_origin = "" btxt_destination = "Call Charges (not incl. discount)" btxt_dialled = total_from_to btxt_rate = "" # get from CDR totals dursecs = callcounttotal # total call count costinclgst = calltotal # call total #if ( costinclgst != 0 ) { outrec() #} #################################### # call discount rectype = "CHARGE_DESC_INFO" recclass = "CALL_DISCOUNT" call_discount = call_discount_arr[servicenumber] sdate_str = "" btxt_stime_str = "" btxt_origin = "" btxt_destination = "Call Usage Discount" btxt_dialled = total_from_to btxt_rate = "" dursecs = 0 costinclgst = 0.0 + call_discount # call discount #if ( costinclgst != 0 ) { outrec() #} #################################### # output recurring discount rectype = "CHARGE_DESC_INFO" recclass = "RECURRING_DISCOUNT" recurring_discount = rent_discount_arr[servicenumber] sdate_str = "" btxt_stime_str = "" btxt_origin = "" btxt_destination = "Recurring Discount (not incl. call discount)" btxt_dialled = total_from_to btxt_rate = "" dursecs = 0 costinclgst = 0.0 + recurring_discount # recurring_discount #if ( costinclgst != 0 ) { outrec() #} #################################### # calculate and output adjustment rectype = "CHARGE_DESC_INFO" recclass = "ADJUSTMENT" call_discount = call_discount_arr[servicenumber] adjustment = recurring_discount + call_discount sdate_str = "" btxt_stime_str = "" btxt_origin = "" btxt_destination = "Total Adjustment (incl. call discount)" btxt_dialled = total_from_to btxt_rate = "" dursecs = 0 costinclgst = 0.0 + adjustment # adjustment #if ( costinclgst != 0 ) { outrec() #} #################################### # calculate and output call recurring rectype = "CHARGE_DESC_INFO" recclass = "RECURRING" recurring = renttotal_arr[servicenumber] sdate_str = "" btxt_stime_str = "" btxt_origin = "" btxt_destination = "Recurring Charges" btxt_dialled = total_from_to btxt_rate = "" dursecs = 0 costinclgst = 0.0 + recurring # call discount #if ( costinclgst != 0 ) { outrec() #} # do carrier totals bill_callcounttotal += callcounttotal_arr[servicenumber] bill_total_cost += renttotal_arr[servicenumber] + rent_discount_arr[servicenumber] + calltotal_arr[servicenumber] + call_discount_arr[servicenumber] + othertotal_arr[servicenumber] + other_discount_arr[servicenumber] } function outrec() { if ( length(datasrcid) > 0 ) printf("%s|", datasrcid) printf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%d|%0.2f|\n", servicenumber, carrier, rectype, recclass, billperiod, sdate_str, btxt_stime_str, btxt_origin, btxt_destination, btxt_dialled, btxt_rate, dursecs, costinclgst) } END { for ( servicenumber in servicenumber_arr ) { finish_mobile(servicenumber) } #------------------------------------ # Bill Total # total cost / account number / invoice number rectype = "CHARGE_DESC_INFO" recclass = "TOTAL" sdate_str = bill_total_to btxt_stime_str = "" btxt_origin = bill_total_account_number btxt_destination = "Total Cost" btxt_dialled = total_from_to btxt_rate = bill_total_invoice_number dursecs = bill_callcounttotal costinclgst = 0.0 + bill_total_cost outrec() } ' >$outfile test -f tt.uniq && mv -f tt.uniq tt_$1.uniq test -f btxt_dialled.uniq && mv -f btxt_dialled.uniq btxt_dialled_$1.uniq test -f btxt_dialled_6.uniq && mv -f btxt_dialled_6.uniq btxt_dialled_6_$1.uniq test -f btxt_origin.uniq && mv -f btxt_origin.uniq btxt_origin_$1.uniq exit 0