home *** CD-ROM | disk | FTP | other *** search
- |******************************************************************************
- |* tssmaweb2120m 0 VRC B40C c4 gbc1
- |* Maintain contract
- |* kingsley
- |* 17-12-08 [10:56]
- |******************************************************************************
- |* Script Type: 0
- |******************************************************************************
- table ttssma221
- table ttccom000
- table ttccom010
- table ttssma220
- table ttsgal052 |Service Package
- table ttccom001 |Customers
- table ttcgbb008
- table ttsgal059
- long ccon.cnt,seq1
- domain tssma.ccon temp.ccon.f,temp.ccon.t
- long return.val
- string gapi.error.code(151)
- string gapi.message.code(100),gapi.error.code1(150)
- string test1(255)
- string test2(255)
- string linetext1(255,1)
- string linetext2(255,1)
- string line1(255),line2(255)
- string x.refa(6)
- long rett1,rett2
- long file.ptr1,file.ptr2,ret
- domain tccomp i.comp
- extern domain tssma.ccon x.i.ccon
- domain tccpay i.cpay
- domain tssma.desc x.i.desc
- domain tssma.sear x.i.sear
- domain tcncmp x.i.ncmp
- domain tcnama x.i.tccom000.nama
- domain tccuno x.i.cuno
- domain tssma.refa x.i.refa
- domain tcccor x.i.ccor
- long x.i.ctst
- string x.i.sdat(10)
- string x.i.edat(10)
- domain tcamnt x.i.spri
- string x.i.cdat(10)
- domain tcamnt x.i.pric
- long x.i.citp
- domain tcccrs x.i.ccrs
- domain tcccur x.i.ccur
- domain tcclan x.i.clan
- domain tssma.cpac x.i.cpac fixed
- domain tccpay x.i.cpay
- domain tccplt x.i.cplt
- domain tssma.cpro x.i.cpro
- domain tssma.ctpc x.i.ctpc
- domain tccvat x.i.cvat
- extern domain tssma.ccon x.i.ccon
- extern domain tssma.ccon new.ccon
-
- domain tssma.sdat b.sdat
- domain tssma.edat b.edat
- domain tssma.date b.cdat
- extern domain tssma.ccon x.i.from.ccon
- extern domain tssma.ccon hold.from.ccon
- extern domain tssma.ccon x.i.to.ccon
- extern domain tssma.ccon hold.to.ccon
- extern domain tssma.ccon x.i.from.ccon
- extern domain tssma.ccon x.i.to.ccon
- extern domain tcbool flag.first.time
- extern String temp.cont.date(6)
- extern String start.year(4)
- extern String end.year(4)
- extern String start.month(2)
- extern String end.month(2)
- extern String start.date(10)
- extern String end.date(10)
- domain tcbool flg.stat
- string lUser(20), mode(5)
- long err1
- string err2(50),err3(50),err(50)
- #include "iccboiapifunc"
- #include <bic_text>
- function main()
- {
- mode = strip$(shiftl$(argv$(1)))
- x.i.ccon=argv$(2)
- x.i.desc=argv$(3)
- x.i.sear=argv$(13)
- x.i.cuno=argv$(8)
- x.i.refa=argv$(16)
- x.i.ccor=""
- x.i.ctst=lval(argv$(6))
- x.i.sdat=argv$(4)
- x.i.edat=argv$(5)
- x.i.pric=val(argv$(12))
- x.i.citp=lval(argv$(11))
- x.i.ccrs=""
- x.i.ccur="INR"
- x.i.clan="ENG"
- x.i.cpac=argv$(10)
- x.i.cpac = shiftr$(x.i.cpac)
- x.i.cplt=argv$(17)
- x.i.cpro=argv$(9)
- x.i.ctpc=argv$(7)
- x.i.cvat=""
- test1=argv$(14)
- test2=argv$(15)
- seq1 = lval(argv$(82))
-
-
- check.and.get.values.for.contract()
-
- if isspace(gapi.error.code) then
- string lflname_ctxt(100)
- string lflname_itxt(100)
- lflname_ctxt ="/tmp/tssma2120m_ctxt" & "." & x.i.ccon
- lflname_itxt ="/tmp/tssma2120m_itxt" & "." & x.i.ccon
- string command(50)
- command = "rm " & lflname_ctxt
- shell(command,64)
- command = "rm " & lflname_itxt
- shell(command,64)
- file.ptr1 = seq.open(lflname_ctxt,"w")
- file.ptr2 = seq.open(lflname_itxt,"w")
- seq.puts(test1,file.ptr1)
- seq.puts(test2,file.ptr2)
- seq.close(file.ptr1)
- seq.close(file.ptr2)
- db.retry.point()
- select tssma220.*
- from tssma220 for update
- where tssma220._index1 = {:x.i.ccon}
- selectdo
- if not isspace(test1) then
- ret = text.write("tssma220.ctxt","2","tssma220.ctxt","text","","","text","text",lflname_ctxt)
- endif
- if not isspace(test2) then
- ret = text.write("tssma220.itxt","2","tssma220.itxt","text","","","text","text",lflname_itxt)
- endif
- db.update(ttssma220,db.retry)
- commit.transaction()
- endselect
- command = "rm " & lflname_ctxt
- shell(command,64)
- command = "rm " & lflname_itxt
- shell(command,64)
- get.fin.comp()
- String con.fin.mess(50)
- con.fin.mess = str$(new.ccon)&" created for finance company "&str$(tcgbb008.fico)
- endif
- update.tsgal059()
- }
-
-
- function check.emp.code() |#EV GCC/4806
- {
- extern domain tcemno temp.refa
- temp.refa = lval(strip$(shiftl$(x.i.refa)))
- select tccom001.*
- from tccom001
- where tccom001._index1 = {:temp.refa}
- selectdo
- end.date = convert.date.to.string(tccom001.edte)
- start.date = convert.date.to.string(tccom001.sdte)
- String temp.start.date(6),temp.end.date(6)
- temp.start.date = start.date(7;4)&start.date(4;2)
- temp.end.date = end.date(7;4)&end.date(4;2)
- if (temp.end.date >= temp.cont.date or tccom001.edte = 0) and temp.start.date <= temp.cont.date then
- gapi.error.code = ""
- else
- gapi.error.code = "Technician not employed in month of booking of contract"
- endif
- selectempty
- gapi.error.code = "Technician not found."
- endselect
-
- }
-
- function get.fin.comp()
- {
- long comp.log
- comp.log = get.compnr()
- db.set.to.default(ttcgbb008)
- select tcgbb008.fico
- from tcgbb008
- where tcgbb008._index1 = {:comp.log, tcmlt.fin.ttyp.contr, :x.i.ctpc}
- selectdo
- endselect
- }
-
-
- function check.and.get.values.for.contract()
- {
-
- string curr.date(12),yy(2),mm(2)
- long curr.dt
- long sd,sm,sy
-
- err1 = 0
- err2 = ""
- err3 = ""
- sd = lval(x.i.sdat(7;2))
- sm = lval(x.i.sdat(5;2))
- sy = lval(x.i.sdat(1;4))
- flg.stat = FALSE
- ccon.cnt = 0
- x.i.cuno = shiftr$(x.i.cuno)
- db.set.to.default(ttccom010)
- select tccom010.cpay
- from tccom010
- where tccom010._index1 = {:x.i.cuno}
- selectdo
- i.cpay = tccom010.cpay
- endselect
- select tssma220.ctst
- from tssma220
- where tssma220._index1={:x.i.ccon}
- selectdo
- if tssma220.ctst = ltoe(4) then
- gapi.error.code = "This Contract is already Cancelled.So no changes can be done."
- endif
- endselect
-
-
- if mode = "1" then
- curr.dt = date.num()
- curr.date = date.to.inputstr$(curr.dt,"%D002,3",8)
- yy = curr.date(7;2)
- mm = curr.date(3;2)
- db.set.to.default(ttccom010)
- select tccom010.refa,tccom010.creg
- from tccom010
- where tccom010._index1 = {:x.i.cuno}
- selectdo
- endselect
-
- temp.ccon.f = tccom010.creg(2;2) & mm & yy & "0000"
- temp.ccon.t = tccom010.creg(2;2) & mm & yy & "9999"
-
- select count(tssma220.ccon):ccon.cnt
- from tssma220
- where tssma220._index3 inrange {:x.i.cuno,:temp.ccon.f}
- and {:x.i.cuno,:temp.ccon.t}
- selectdo
- endselect
- endif
- if strip$(shiftl$(tccom010.refa)) <> "" then
- if ccon.cnt => lval(tccom010.refa) then
- gapi.error.code = "Contract count for the customer is greater than no. of ctrcts for cust."
- endif
- endif
- if isspace(gapi.error.code) then
-
- select tsgal052.actv,tsgal052.idat
- From tsgal052
- where tsgal052._index1 = {:x.i.cpac}
- selectdo
- if tsgal052.actv = tcyesno.no then
- if (tsgal052.idat <> 0 and tsgal052.idat <= date.to.num(sy,sm,sd)) then
- if x.i.ctst = 4 then
- flg.stat = TRUE
- else
- gapi.error.code = "Service Package is Inactive"
- endif
- endif
- endif
- selectempty
- gapi.error.code = "Service Package Not Found"
- endselect
- endif
-
-
- if flg.stat = TRUE then
-
- f2120mgal.put.Contract( x.i.ccon )
- err1=f2120mgal.find()
- if err1 then
- f2120mgal.put.Contract_Status(ltoe(x.i.ctst))
- f2120mgal.update(1, err2)
- if isspace(err2) then
- f2120mgal.save(err3)
-
- endif
-
- endif
- f2120mgal.end()
- else
- if isspace(gapi.error.code) then
- insert.in.to.contract()
- endif
- endif
-
-
- }
-
- function insert.in.to.contract()
- {
- String create.date(10)
- extern domain tcdate temp.date
- long ed,em,ey
- long sd,sm,sy
-
- sd = lval(x.i.sdat(7;2))
- sm = lval(x.i.sdat(5;2))
- sy = lval(x.i.sdat(1;4))
-
- ed = lval(x.i.edat(7;2))
- em = lval(x.i.edat(5;2))
- ey = lval(x.i.edat(1;4))
-
-
-
- gapi.error.code=""
- if mode = "2" then
- select tssma220.edat,tssma220.sdat,tssma220.cpac
- from tssma220
- where tssma220._index1 = {:x.i.ccon}
- selectdo
- if (tssma220.sdat <> date.to.num(sy,sm,sd) or tssma220.edat <> date.to.num(ey,em,ed) or x.i.cpac <> tssma220.cpac )then
- select tssma221.ccon,tssma221.invn
- from tssma221
- where tssma221._index1 = {:x.i.ccon}
- selectdo
- if (tssma220.sdat <> date.to.num(sy,sm,sd) or tssma220.edat <> date.to.num(ey,em,ed)) then
- gapi.error.code = "The installments for this contract are already maintained.So the dates can not be changed."
- else
- if tssma221.invn <> 0 then
- gapi.error.code = "The invoices are generated for this contract.So the service package can not be changed."
- endif
- endif
- endselect
- endif
- endselect
- endif
- if isspace(gapi.error.code) then
- f2120mgal.put.Contract( x.i.ccon )
-
- if mode <> "1" then
- return.val = f2120mgal.find()
- endif
- if mode = "2" then
- temp.cont.date = "20"&x.i.ccon(5;2)&x.i.ccon(3;2)
- endif
- if mode = "1" then
- temp.date = date.num()
- create.date = convert.date.to.string(temp.date)
- temp.cont.date = create.date(7;4)&create.date(4;2)
- endif
- check.emp.code()
- if not isspace(gapi.error.code) then
-
- f2120mgal.end()
- endif
- get.fin.comp()
- if mode <> "3" and isspace(gapi.error.code) then
- f2120mgal.put.tssma220.desc(x.i.desc)
- f2120mgal.put.Search_Argument(x.i.sear)
- f2120mgal.put.tssma220.ncmp(tcgbb008.fico)
- f2120mgal.put.Customer(x.i.cuno)
- f2120mgal.put.Technician_Code(x.i.refa)
- f2120mgal.put.Postal_Address(x.i.ccor)
- f2120mgal.put.Contract_Status(ltoe(x.i.ctst))
- f2120mgal.put.Effective_Date(date.to.num(lval(x.i.sdat(1;4)),lval(x.i.sdat(5;2)),lval(x.i.sdat(7;2))))
- f2120mgal.put.Expiry_Date(date.to.num(lval(x.i.edat(1;4)),lval(x.i.edat(5;2)),lval(x.i.edat(7;2))))
- f2120mgal.put.Contract_Price(x.i.pric)
- f2120mgal.put.Invoicing_Type(ltoe(x.i.citp))
- f2120mgal.put.tssma220.ccrs(x.i.ccrs)
- f2120mgal.put.tssma220.ccur(x.i.ccur)
- f2120mgal.put.tssma220.clan(x.i.clan)
- f2120mgal.put.tssma220.cpac(x.i.cpac)
- f2120mgal.put.tssma220.cpay(i.cpay)
- f2120mgal.put.Price_List(x.i.cplt)
- f2120mgal.put.tssma220.cpro(x.i.cpro)
- f2120mgal.put.tssma220.ctpc(x.i.ctpc)
- f2120mgal.put.tssma220.cvat(x.i.cvat)
- if mode = "1" then
- f2120mgal.insert(0,gapi.error.code)
- if not isspace(gapi.error.code) then
- gapi.message.code = f2120mgal.get.last.message.code()
- f2120mgal.end()
- endif
- f2120mgal.save(gapi.error.code1)
- new.ccon = ""
- tssma220.ncmp = 0
- new.ccon = f2120mgal.get.Contract()
- tssma220.ncmp = f2120mgal.get.tssma220.ncmp()
- else
- f2120mgal.update(0,gapi.error.code)
- if not isspace(gapi.error.code) then
- gapi.message.code = f2120mgal.get.last.message.code()
- f2120mgal.end()
- endif
- f2120mgal.save(gapi.error.code1)
- endif
- if (not isspace(gapi.error.code) or not isspace(gapi.error.code1)) then
- gapi.message.code = f2120mgal.get.last.message.code()
- f2120mgal.end()
- else
- if mode = "1" then
- f2120mgal.handle.sub.process("tssmal102s000","ADD")
- f2120mgal.Maintain_Extension_to_Service_Contract(err)
- if isspace(err) then
- fl102s000.put.Contract(x.i.ccon)
- fl102s000.insert(1,err)
- if isspace(err) then
- fl102s000.save(err)
- if not isspace(err) then
- gapi.error.code = "Contract generated as " & x.i.ccon & "error in localization " & err
- else
- fl102s000.end()
- endif
- else
- gapi.error.code = "Contract generated as " & x.i.ccon & "error in localization " & err
-
- endif
- else
- gapi.error.code = "Contract generated as " & x.i.ccon & "error in localization " & err
- endif
- fl102s000.end()
- endif
-
- endif
- endif
- endif
-
- }
-
- function update.tsgal059()
- {
-
- db.retry.point()
- select tsgal059.rlog,tsgal059.excp
- from tsgal059 for update
- where tsgal059._index1 = {:seq1}
- | and tsgal059._compnr = 779
- selectdo
- if (not isspace(gapi.error.code) or not isspace(gapi.error.code1)) then
-
- gapi.message.code = strip$(gapi.error.code)&" :"&strip$(gapi.error.code1)
-
- tsgal059.rlog = "N"
- else
- if mode = "1" then
- gapi.error.code = "Successful in maintaining contract:"&x.i.ccon
- endif
- if mode = "2" then
- gapi.error.code = "Successfully updated contract:"&x.i.ccon
- endif
- if mode = "3" then
- gapi.error.code = "Successfully deleted contract:"&x.i.ccon
- endif
- tsgal059.rlog = "Y"
- endif
- tsgal059.excp = gapi.error.code
- db.update(ttsgal059,db.retry)
- commit.transaction()
- endselect
- }
-
-
-