Exemplo n.º 1
0
def dialogaction(action, var):
    printVar("doaction", action, var)

    if action == "addpayment":
        op = H.getResOp()
        custOp = H.getHotelCustomers()
        add = ReservationPaymentDetail()
        #         ho = ServiceInjector.getInstanceHotel()

        ho = H.getInstanceObjectId()
        hins = ho.getOObject("AppInstanceTest", "hotel", "user")

        print hins
        cust = HotelCustomer()
        cust.setName("guest")
        custOp.addElem(hins, cust)

        add.setDescription("Beverage")
        add.setGuestName("guest")
        add.setPrice(toB(1))
        add.setPriceList(toB(155))
        # important: after decimal point !!!
        add.setPriceTotal(toB(1.1))
        add.setQuantity(2)
        add.setRoomName("P10")
        da = datetime.date(2013, 3, 2)
        add.setServDate(toDate(da))
        add.setVat("7%")
        op.addResAddPayment(hins, "2013/R/2", add)
Exemplo n.º 2
0
    def run(self, var):
        (ma, li) = dutil.doctoMap(self._xml)
        self._total = ma["total"]
        P = PAID(var, self._rese_name)
        b = util.newBill(var)
        #        b.setGensymbol(True);
        b.setPayer(self._cust_name)
        b.setReseName(self._rese_name)
        b.setIssueDate(cutil.toDate(cutil.today()))
        for m in li:
            idp = m["id"]
            if idp == 0: continue
            if P.onList(idp):
                var["JERROR_MESSAGE"] = "@billalreadypaid"
                self.res = False
                return
            b.getPayList().add(idp)

        if b.getPayList().size() == 0:
            var["JERROR_MESSAGE"] = "@nothingischecked"
            self.res = False
            return

        self._b = util.BILLLIST(var).addElem(b)
        b_name = self._b.getName()
        key = B.addNewBlob(rutil.getFinnDocRealm(var, b_name), "BILLXML",
                           self._xml)
        if self._paymentmethod != None:
            _addPayment(var, b_name, self._total, self._paymentmethod)
Exemplo n.º 3
0
    def run(self,var) :
        (ma,li) = dutil.doctoMap(self._xml)
        self._total = ma["total"]
        P = PAID(var,self._rese_name)
        b = util.newBill(var)
#        b.setGensymbol(True);
        b.setPayer(self._cust_name)
        b.setReseName(self._rese_name)
        b.setIssueDate(cutil.toDate(cutil.today()))
        for m in li :
            idp = m["id"]
            if idp == 0 : continue
            if P.onList(idp) :
                var["JERROR_MESSAGE"] = "@billalreadypaid"
                self.res = False
                return
            b.getPayList().add(idp)
         
        if b.getPayList().size() == 0 :
            var["JERROR_MESSAGE"] = "@nothingischecked"
            self.res = False
            return
      
        self._b = util.BILLLIST(var).addElem(b)
        b_name = self._b.getName()
        key = B.addNewBlob(rutil.getFinnDocRealm(var,b_name),"BILLXML",self._xml)
        if self._paymentmethod != None :
            _addPayment(var,b_name,self._total,self._paymentmethod)
Exemplo n.º 4
0
def dialogaction(action,var) :
     printVar("doaction",action,var)

     if action == "addpayment" :
         op = H.getResOp()
         custOp = H.getHotelCustomers()
         add = ReservationPaymentDetail()
#         ho = ServiceInjector.getInstanceHotel()

         ho = H.getInstanceObjectId()
         hins = ho.getOObject("AppInstanceTest","hotel","user")
         
         print hins
         cust = HotelCustomer()
         cust.setName("guest")
         custOp.addElem(hins,cust)
         
         add.setDescription("Beverage")
         add.setGuestName("guest")
         add.setPrice(toB(1))
         add.setPriceList(toB(155))
         # important: after decimal point !!!
         add.setPriceTotal(toB(1.1))
         add.setQuantity(2)
         add.setRoomName("P10")
         da = datetime.date(2013, 3, 2)
         add.setServDate(toDate(da))
         add.setVat("7%")
         op.addResAddPayment(hins, "2013/R/2", add)

         
Exemplo n.º 5
0
def dialogclickaction(action, var):
    op = ElemOp()
    print action
    if action == "before":
        id = var["JDATELINE_LINE"]
        date = var["JDATELINE_DATE"]
        print id, date
        var["id"] = id
        var["datecol"] = date
        var["JCOPY_id"] = True
        var["JCOPY_datecol"] = True
        print id, date
        elem = op.findElem(id, date)
        info = None
        numb = 0
        if elem:
            info = elem.getInfo()
            numb = elem.getNumb()
        var["JCOPY_info"] = True
        var["info"] = info
        var["JCOPY_color"] = True
        var["color"] = str(numb)

    if action == "addinfo":
        id = var["id"]
        date = var["datecol"]
        info = var["info"]
        col = var["color"]

        op.addormodifElem(id, toDate(date), int(col), info)
        var["JREFRESH_DATELINE_dateline"] = ""
        var["JCLOSE_DIALOG"] = True
Exemplo n.º 6
0
def dialogclickaction(action,var) :
   op = ElemOp()
   print action
   if action == "before" :
       id = var["JDATELINE_LINE"]
       date = var["JDATELINE_DATE"]
       print id,date
       var["id"] = id
       var["datecol"] = date
       var["JCOPY_id"] = True       
       var["JCOPY_datecol"] = True
       print id,date
       elem = op.findElem(id, date)
       info = None
       numb = 0
       if elem :
           info = elem.getInfo()
           numb = elem.getNumb()
       var["JCOPY_info"] = True
       var["info"] = info
       var["JCOPY_color"] = True
       var["color"] = str(numb)
       
   if action == "addinfo" :
       id = var["id"]
       date = var["datecol"]
       info = var["info"]
       col = var["color"]
       
       op.addormodifElem(id,toDate(date),int(col),info)
       var["JREFRESH_DATELINE_dateline"] = ""
       var["JCLOSE_DIALOG"] = True
Exemplo n.º 7
0
def _addPayment(var,billName,total,paymentmethod):
    r = util.RESFORM(var).findElem(rutil.getReseName(var))       
    RR = resstat.getResStatusR(var,r)
    li = []
    if RR.advancepaymentleft > 0 :
        payment = min(total,RR.advancepaymentleft) 
        li.append((payment,True))
        total = con.minusDecimal(total,payment)
    if total > 0 : li.append((total,False))
    
    for l in li :    
        p = util.newBillPayment()
        p.setBillName(billName)
        p.setPaymentMethod(paymentmethod)
        p.setDateOfPayment(cutil.toDate(cutil.today()))
        p.setPaymentTotal(con.toB(l[0]))         
        if (l[1]) : p.setAdvancepayment(True)
        util.PAYMENTOP(var).addPaymentForBill(billName,p)
Exemplo n.º 8
0
def _addPayment(var, billName, total, paymentmethod):
    r = util.RESFORM(var).findElem(rutil.getReseName(var))
    RR = resstat.getResStatusR(var, r)
    li = []
    if RR.advancepaymentleft > 0:
        payment = min(total, RR.advancepaymentleft)
        li.append((payment, True))
        total = con.minusDecimal(total, payment)
    if total > 0: li.append((total, False))

    for l in li:
        p = util.newBillPayment()
        p.setBillName(billName)
        p.setPaymentMethod(paymentmethod)
        p.setDateOfPayment(cutil.toDate(cutil.today()))
        p.setPaymentTotal(con.toB(l[0]))
        if (l[1]): p.setAdvancepayment(True)
        util.PAYMENTOP(var).addPaymentForBill(billName, p)
Exemplo n.º 9
0
def weekhelper(action, var):

    if action == "select" and var["list_lineset"]:
        var["week"] = var["weekbeg"]
        var['JCOPY_week'] = True
        var["JCLOSE_DIALOG"] = True

    if action == "before":
        da = datetime.date(YEAR, 1, 1)
        td = datetime.timedelta(1)
        while da.weekday() != 0:
            da = da - td
        list = []
        while True:
            if da.weekday() == 0:
                list.append({"weekbeg": toDate(da)})
                if da.year > YEAR: break
            da = da + td
        var["JLIST_MAP"] = {"list": list}
Exemplo n.º 10
0
def weekhelper(action,var):
    
    if action == "select" and var["list_lineset"] :
      var["week"] = var["weekbeg"]
      var['JCOPY_week'] = True
      var["JCLOSE_DIALOG"] = True
    
    if action == "before" :
        da = datetime.date(YEAR,1,1)
        td = datetime.timedelta(1)
        while da.weekday() != 0 :
            da = da - td
        list= []
        while True :
            if da.weekday() == 0 : 
                list.append({"weekbeg" : toDate(da)})
                if da.year > YEAR : break
            da = da + td
        var["JLIST_MAP"] = {"list" : list}  
            
Exemplo n.º 11
0
def toDate(value):
    return cutil.toDate(value)
Exemplo n.º 12
0
def toDate(value):
    return cutil.toDate(value)
Exemplo n.º 13
0
 def findElem(self, id, dt):
     return self.op.findElem(id, toDate(dt))
Exemplo n.º 14
0
def dialogaction(action, var):

    cutil.printVar("test48", action, var)

    if action == "test1":
        resename = var["resename"]
        R = util.RESFORM(var)
        ROP = util.RESOP(var)
        RR = R.findElem(resename)
        print RR
        lg = ROP.getResGuestList(resename)
        for g in lg:
            print g.getGuestName()
        gName = lg[0].getGuestName()
        print gName
        dli = RR.getResDetail()
        for l in dli:
            print g.getRoomName()
        roomName = dli[0].getRoomName()
        print roomName
        S = util.SERVICES(var)
        se = util.newOtherService(var)
        se.setName("addse")
        se.setVat("free")
        ase = S.addElem(se)
        rpa = util.newResAddPayment()
        rpa.setGuestName(gName)
        rpa.setRoomName(roomName)
        rpa.setResDate(con.javaDate(2015, 12, 23))
        rpa.setPriceList(con.toB(100.56))
        rpa.setPrice(con.toB(50))
        rpa.setPriceTotal(con.toB(200))
        rpa.setService(ase.getName())
        arpa = ROP.addResAddPayment(resename, rpa)
        print arpa.getName(), arpa.getId(), " ", arpa.getResDate()
        assert arpa.getId() != None
        li = cutil.JOURNAL(var).getList()
        for l in li:
            print l.getId()
        J = li[0]
        print J.getName(), J.getJournalType(), J.getJournalTypeSpec(
        ), J.getJournalElem1(), J.getJournalElem2()
        assert "ADDPAYMENT" == J.getJournalType()
        assert resename == J.getJournalElem1()
        assert arpa.getId() == int(J.getJournalElem2())
        var["OK"] = True

    if action == "test2":
        bname = var["bname"]
        p = util.newBillPayment()
        p.setBillName(bname)
        p.setPaymentMethod("Cache")
        p.setDateOfPayment(cutil.toDate(cutil.today()))
        p.setPaymentTotal(con.toB(1000))
        addP = util.PAYMENTOP(var).addPaymentForBill(bname, p)
        li = cutil.JOURNAL(var).getList()
        for l in li:
            print l.getId(), l.getJournalType(), l.getJournalElem1(
            ), l.getJournalElem2(), l.getCreationDate()
        J = li[0]
        print J.getName(), J.getJournalType(), J.getJournalTypeSpec(
        ), J.getJournalElem1(), J.getJournalElem2(),
        assert "ADDBILLPAYMENT" == J.getJournalType()
        assert addP.getId() == int(J.getJournalElem1())
        assert bname == J.getJournalElem2()
        # now remove
        util.PAYMENTOP(var).removePaymentForBill(bname, addP.getId())
        li = cutil.JOURNAL(var).getList()
        for l in li:
            print l.getId(), l.getJournalType(), l.getJournalElem1(
            ), l.getJournalElem2(), l.getCreationDate()
        J = li[0]
        print J.getName(), J.getJournalType(), J.getJournalTypeSpec(
        ), J.getJournalElem1(), J.getJournalElem2()
        assert "REMOVEBILLPAYMENT" == J.getJournalType()
        assert addP.getId() == int(J.getJournalElem1())
        assert bname == J.getJournalElem2()
        var["OK"] = True

    if action == "test3":
        li = cutil.JOURNAL(var).getList()
        JM = journalmess.JournalMess(var)
        for l in li:
            print l.getId(), l.getJournalType(), l.getJournalElem1(
            ), l.getJournalElem2(), l.getCreationDate()
            print "mess=", JM.getJournalDescr(l)
            assert None != JM.getJournalDescr(l)
        J = li[1]
        print J.getName(), J.getJournalType(), J.getJournalTypeSpec(
        ), J.getJournalElem1(), J.getJournalElem2()
        billname = J.getJournalElem2()
        print billname
        # remove bill and test message with removed bill
        util.BILLLIST(var).deleteElemByName(billname)
        li = cutil.JOURNAL(var).getList()
        JM = journalmess.JournalMess(var)
        for l in li:
            print l.getId(), l.getJournalType(), l.getJournalElem1(
            ), l.getJournalElem2(), l.getCreationDate()
            print "mess=", JM.getJournalDescr(l)
            assert None != JM.getJournalDescr(l)
        var["OK"] = True

    if action == "test4":
        li = cutil.JOURNAL(var).getList()
        JM = journalmess.JournalMess(var)
        for l in li:
            print l.getId(), l.getJournalType(), l.getJournalElem1(
            ), l.getJournalElem2(), l.getCreationDate()
            print "mess=", JM.getJournalDescr(l)
            assert None != JM.getJournalDescr(l)
        var["OK"] = True
Exemplo n.º 15
0
def createResQueryElem(roomname, dfrom, dto):
    q = ResQuery()
    q.setFromRes(cutil.toDate(dfrom))
    q.setToRes(cutil.toDate(dto))
    q.setRoomName(roomname)
    return q
Exemplo n.º 16
0
 def findElem(self,id,dt):
     return self.op.findElem(id,toDate(dt))