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 ttssma916
- table ttsgal059
- long ccon.cnt,seq1
- domain tssma.ccon temp.ccon.f,temp.ccon.t
- extern domain tdstr3 ctcdf
- long return.val
- string gapi.error.code(151),gapi.error.code1(151),gapi.error.code2(151),gapi.error.code11(100)
- string gapi.message.code(30)
- 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,instAmt
- domain tccomp i.comp
- extern domain tssma.ccon x.i.ccon
- domain tccpay i.cpay
- domain tssma.desc x.i.desc
- domain tcamnt totInst
- domain tcamnt x.i.pric
- extern domain tssma.bkyr x.i.bkyr,tmp.bkyr
- extern domain tssma.seqn x.i.seqn,tmp.seqn
- domain tssma.cper x.i.cper
- domain tssma.disc x.i.disc
- domain tssma.disc x.i.cppc
- domain tcamnt x.i.cpam
- domain tssma.nprd x.i.nprf
- domain tssma.prci status
- long x.i.slci
- long x.i.prci
- string x.i.prdt(10)
- domain tcinvn x.i.invn
- string x.i.invd(10)
- domain tcamnt x.i.ldam
- domain tcamnt x.i.nprc
- 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)
- extern String spool.fileout(100)
- extern domain tcdate inv.date
- domain tcbool flg.stat
- string lUser(20), mode(5)
- long err1
- string err2(50),err3(50),err(50),msg(100),ind(2)
-
- extern long seq.id11,ret
- extern string file(150)
- string ddt1(10),ddt2(10)
- String str(500)
-
-
- #include "iccboiapifunc"
- #include <bic_text>
- #pragma used dll ottstpapihand
- function main()
- {
- mode = strip$(shiftl$(argv$(1)))
- x.i.ccon=argv$(2)
- x.i.desc=argv$(3)
- x.i.seqn=lval(argv$(4))
- x.i.bkyr=lval(argv$(5))
- x.i.pric=val(argv$(6))
- x.i.cper=lval(argv$(7))
- test1=argv$(8)
- x.i.slci=lval(argv$(9))
- x.i.disc=val(argv$(10))
- seq1 = lval(argv$(82))
-
- | check.tsgal059309()
- long indexval
- indexval = string.scan(test1,"%s|%s",ctcdf,test2)
- test1 = test2
-
- generate.contract.installment()
-
- string lflname_itxt(100)
-
- lflname_itxt ="/tmp/tssma2121m_itxt" & "." & x.i.ccon
- string command(50)
- command = "rm " & lflname_itxt
- shell(command,64)
-
-
- file.ptr1 = seq.open(lflname_itxt,"w")
- seq.puts(test1,file.ptr1)
- seq.close(file.ptr1)
-
- db.retry.point()
- select tssma221.*
- from tssma221 for update
- where tssma221._index1 = {:x.i.ccon,:x.i.bkyr,:x.i.seqn}
- selectdo
- if not isspace(test1) then
- ret = text.write("tssma221.itxt","2","tssma221.itxt","text","","","text","text",lflname_itxt)
- endif
- db.update(ttssma221,db.retry)
- commit.transaction()
- endselect
-
- command = "rm " & lflname_itxt
- shell(command,64)
-
-
-
- }
-
-
-
- function update.tsgal059()
- {
-
- db.retry.point()
- select tsgal059.*
- from tsgal059 for update
- where tsgal059._index1 = {:seq1}
- | and tsgal059._compnr = 779
- selectdo
- tsgal059.rlog = ind
- tsgal059.excp = gapi.error.code&gapi.error.code1
- db.update(ttsgal059,db.retry)
- commit.transaction()
- endselect
- }
-
- function generate.contract.installment()
- {
- if mode = "1" and x.i.pric < 0 then
- f2120mgal.put.Contract( x.i.ccon )
- return.val = f2120mgal.find()
- f2120mgal.put.Invoicing_Type(ltoe(3))
- f2120mgal.update(0,gapi.error.code11)
- f2120mgal.save(gapi.error.code11)
- f2120mgal.end()
- endif
- f2121m000.put.Contract(x.i.ccon)
- f2121m000.put.Year(x.i.bkyr)
- f2121m000.set.view()
- f2121m000.put.Sequence_Number(x.i.seqn)
-
-
- if mode <> "1" then
- return.val = f2121m000.find()
- status = f2121m000.get.Processing_Status()
- endif
- if mode <> "3" then
- f2121m000.put.Period(x.i.cper)
- f2121m000.put.tssma221.desc(x.i.desc)
- f2121m000.put.Installment_Amount(x.i.pric)
- f2121m000.put.Discount(x.i.disc)
- | f2121m000.put.Perc._Forecast_Costs(x.i.cppc)
- | f2121m000.put.Amount_Forecast_Costs(x.i.cpam)
- | f2121m000.put.Number_of_Periods(x.i.nprf)
- f2121m000.put.Advice_Status(ltoe(x.i.slci))
-
- if mode = "1" then
- f2121m000.insert(1,gapi.error.code)
- else
- if status = tssma.prci.free then
- f2121m000.update(1,gapi.error.code)
- else
- gapi.error.code = "Installment already Processed.Changing not allowed."
- endif
- endif
- if not isspace(gapi.error.code) then
- gapi.message.code = f2121m000.get.last.message.code()
- f2121m000.end()
- ind = "N"
-
- update.tsgal059()
- else
- CalculateInstallment()
- instAmt = f2121m000.get.Contract_Price()
- if mode = "1" then
- gapi.error.code = "Contract " & x.i.ccon & "Year " &str$(x.i.bkyr) & "Sequence " & str$(x.i.seqn)
- endif
- if totInst < instAmt then
- gapi.error.code = gapi.error.code & "Note! Installment Total ( " & STR$(totInst) & " ) Not Equal To Contract Price ( " & STR$(instAmt) & " )"
- endif
- if totInst > instAmt then
- gapi.error.code = gapi.error.code & "Note! Installment Total ( " & STR$(totInst) & " ) Greater Than Contract Price ( " & STR$(instAmt) & " )"
- endif
-
- f2121m000.end()
- | fl115sgal.put.Service_Contract(x.i.ccon)
- | fl115sgal.put.Year(x.i.bkyr)
- | fl115sgal.put.Sequence(x.i.seqn)
- | fl115sgal.put.Period(x.i.cper)
- | ctcdf ="036"
- | fl115sgal.put.Category_Code(ctcdf)
- | string err(200)
- | fl115sgal.insert(1,err)
- | if isspace(err) then
- | fl115sgal.save(err)
- | if not isspace(err) then
- | gapi.error.code1 = "Lines created localization error :" & err
- | else
- | fl115sgal.end()
- | endif
- | else
- | gapi.error.code1 = "Lines created localization error :" & err
- | endif
- | if not isspace(err) then
- | gapi.message.code = fl115sgal.get.last.message.code()
- | fl115sgal.end()
- | endif
-
- string err(200)
- fl115sgal.put.Service_Contract(x.i.ccon)
- fl115sgal.put.Year(x.i.bkyr)
- fl115sgal.put.Sequence(x.i.seqn)
-
- select tssma916.*
- from tssma916
- where tssma916._index1 = {:x.i.ccon,:x.i.bkyr,:x.i.seqn}
- selectdo
- return.val = fl115sgal.find()
- fl115sgal.put.Period(x.i.cper)
- ctcdf ="036"
- fl115sgal.put.Category_Code(ctcdf)
- fl115sgal.put.base.dt(date.num() - 1)
- fl115sgal.update(1,err)
- selectempty
- fl115sgal.put.Period(x.i.cper)
- ctcdf ="036"
- fl115sgal.put.Category_Code(ctcdf)
- fl115sgal.insert(1,err)
- endselect
- if isspace(err) then
- fl115sgal.save(err)
- if not isspace(err) then
- gapi.error.code1 = "Lines created localization error :" & err
- else
- fl115sgal.end()
- endif
- else
- gapi.error.code1 = "Lines created localization error :" & err
- endif
- if not isspace(err) then
- gapi.message.code = fl115sgal.get.last.message.code()
- fl115sgal.end()
- endif
-
- ind = "Y"
- update.tsgal059()
-
- if (x.i.pric < 0 )then
- if isspace(gapi.error.code1) then
- spool.fileout = "tssma2472m000."&strip$(shiftl$(tsgal059.wlog))
- file = "invoice_number"&str$(get.compnr())&strip$(shiftl$(tsgal059.wlog))&dte$()
- seq.id11 = seq.open(file,"w")
-
- gapi.error.code2 = ""
- inv.date = date.num()
- | spool.fileout = "tssma2472m000.system"
- f2472m000.put.Include_Printed_Invoices(ltoe(2))
- f2472m000.put.Invoice_Date(inv.date)
- f2472m000.put.Contract_from(x.i.ccon)
- f2472m000.put.Contract_to(x.i.ccon)
- f2472m000.put.Contract_Type_from("")
- f2472m000.put.Contract_Type_to("ZZZ")
- f2472m000.put.Customer_from("")
- f2472m000.put.Customer_to("ZZZZZZ")
- f2472m000.put.Finance_Company(0)
- f2472m000.put.ncmp.t(999)
- f2472m000.put.Final_Invoices(ltoe(1))
- f2472m000.put.Print_Invoice_Analysis(ltoe(2))
- f2472m000.put.Print_Installation_List(ltoe(2))
- stpapi.set.report("tssma2472m000","rtssma247201000","ASCIF",gapi.error.code2)
- stpapi.print.report("tssma2472m000",err)
- f2472m000.end()
-
- write.con.invoice()
- seq.close(seq.id11)
- endif
- endif
-
-
- endif
- else
- f2121m000.delete(0,gapi.error.code)
- f2121m000.end()
- endif
-
-
- }
-
-
- function write.con.invoice()
- {
-
- select tssma221.ccon,tssma221.bkyr,tssma221.seqn,tssma221.invn,tssma221.invd,tssma221.ttyp,tssma221.prci,tssma221.prdt,tssma221.ldam,tssma221.nprc
- from tssma221
- where tssma221._index1 = {:x.i.ccon}
- selectdo
- if tssma221.invd <> 0 then
- ddt1 = sprintf$("%D(%04Y%02m%02d)", tssma221.invd)
- else
- ddt1 = "00000000"
- endif
- if tssma221.prdt <> 0 then
- ddt2 = sprintf$("%D(%04Y%02m%02d)", tssma221.prdt)
- else
- ddt2 = "00000000"
- endif
- str = concat$("^",tssma221.ccon,tssma221.bkyr,tssma221.seqn,tssma221.invn,ddt1,tssma221.ttyp,tssma221.prci,ddt2,tssma221.ldam,tssma221.nprc)
- seq.puts(str,seq.id11)
- endselect
- }
-
- function CalculateInstallment()
- {
- totInst = 0.0
- select SUM(tssma221.nprc):totInst,tssma221.ccon,tssma221.bkyr
- from tssma221
- where tssma221._index1 = {:x.i.ccon, :x.i.bkyr}
- group by tssma221.ccon,tssma221.bkyr
- selectdo
- endselect
-
- }
-
- function Delete_Local_Data()
- {
- select tssma916.*
- from tssma916 for update
- where tssma916._index1 = {:x.i.ccon, :x.i.bkyr,:x.i.seqn}
- selectdo
- db.delete(ttssma916,db.retry)
- commit.transaction()
- endselect
-
- }
-
- function check.tsgal059309()
- {
- select tsgal059.logn,tsgal059.sess,tsgal059.rlog,tsgal059.indi
- from tsgal059
- where tsgal059._index5 = {:x.i.ccon,"tssma2120m000"}
- selectdo
- if (tsgal059.indi <> "Y") then
- restore.tsgal059309()
- else
- if (tsgal059.rlog <> "Y") then
- restore.tsgal059309()
- endif
- endif
-
- endselect
- }
-
- function restore.tsgal059309()
- {
- db.retry.point()
- select tsgal059.*
- from tsgal059 for update
- where tsgal059._index1 = {:seq1}
- selectdo
- tsgal059.indi = "N"
- db.update(ttsgal059,db.retry)
- commit.transaction()
- endselect
- }
-