def setAdvaData(self,reservation) : reservation.setAdvanceDeposit(con.toB(self.var[self.__advapay])) reservation.setTermOfAdvanceDeposit(con.toDate(self.var[self.__advadate])) if self.__resepay : reservation.setAdvancePayment(con.toB(self.var[self.__resepay])) if self.__resedate : pdate = self.var[self.__resedate] if pdate == None : pdate = con.today() reservation.setDateofadvancePayment(con.toDate(pdate))
def setAdvaData(self, reservation): reservation.setAdvanceDeposit(con.toB(self.var[self.__advapay])) reservation.setTermOfAdvanceDeposit( con.toDate(self.var[self.__advadate])) if self.__resepay: reservation.setAdvancePayment(con.toB(self.var[self.__resepay])) if self.__resedate: pdate = self.var[self.__resedate] if pdate == None: pdate = con.today() reservation.setDateofadvancePayment(con.toDate(pdate))
def _calculatePaymentBy(var,li) : nodays = D.getDataHI(41) if nodays == None : return arrival = None departure = None for l in li : (arrival,departure) = calculateJDates(arrival,departure,l["resday"]) paymentby = con.incDays(arrival,0-nodays) if paymentby <= con.today() : paymentby = None var["advance_duedate"] = paymentby cutil.setCopy(var,"advance_duedate")
def _XbuildHeaderXML(var,ma,nog,r,custname): (arrival,departure,roomname,rate,numberofnights) = rutil.getReseDate(var,r) room = util.ROOMLIST(var).findElem(roomname) p = util.CUSTOMERLIST(var).findElem(custname); _XaddMapElem(ma,["name1","name2","address","city"],p,["firstname","surname","street","city"]) ma["country"] = _getCountryName(var,p.getAttr("country")) ma["roomnumber"] = roomname ma["dailyrate"] = rate ma["roomtype"] = room.getDescription() ma["arrivaldate"] = arrival ma["departuredate"] = departure ma["nofguests"] = nog ma["resid"] = r.getName() ma["issuedate"] = con.toJDate(r.getCreationDate()) ma["saledate"] = con.today() ma["addinfo"] = "" ma["amount"] = numberofnights ma["description"] = ""
def _XbuildHeaderXML(var, ma, nog, r, custname): (arrival, departure, roomname, rate, numberofnights) = rutil.getReseDate(var, r) room = util.ROOMLIST(var).findElem(roomname) p = util.CUSTOMERLIST(var).findElem(custname) _XaddMapElem(ma, ["name1", "name2", "address", "city"], p, ["firstname", "surname", "street", "city"]) ma["country"] = _getCountryName(var, p.getAttr("country")) ma["roomnumber"] = roomname ma["dailyrate"] = rate ma["roomtype"] = room.getDescription() ma["arrivaldate"] = arrival ma["departuredate"] = departure ma["nofguests"] = nog ma["resid"] = r.getName() ma["issuedate"] = con.toJDate(r.getCreationDate()) ma["saledate"] = con.today() ma["addinfo"] = "" ma["amount"] = numberofnights ma["description"] = ""
def elempayment(action, var): cutil.printVar("elempayment", action, var) if action == "before" and var["JCRUD_DIALOG"] == "crud_add": var["paymentdate"] = cutil.today() b = BILLLIST(var).findElem(_getPayName(var)) sumtotal = rutil.countTotal(var, b, rutil.getPayments(var)) sumpay = rutil.countPayments(var, _getPayName(var)) acc = con.minusDecimal(sumtotal, sumpay) if acc < 0: acc = None var["paymenttotal"] = acc cutil.setCopy(var, ["paymentdate", "paymenttotal"]) if action == "crud_add" and not var["JCRUD_AFTERCONF"]: var["JYESNO_MESSAGE"] = "Do you want to add payment to this bill ?" var["JMESSAGE_TITLE"] = "" return if action == "crud_add" and var["JCRUD_AFTERCONF"]: p = util.newBillPayment() p.setBillName(_getPayName(var)) p.setPaymentMethod(var["paymethod"]) p.setDateOfPayment(con.toDate(con.today())) p.setPaymentTotal(con.toB(var["paymenttotal"])) PAYMENTOP(var).addPaymentForBill(_getPayName(var), p) var["JCLOSE_DIALOG"] = True _setChanged(var) return if action == "crud_remove" and not var["JCRUD_AFTERCONF"]: var["JYESNO_MESSAGE"] = "Are you sure to remove payment to this bill ?" var["JMESSAGE_TITLE"] = "" return if action == "crud_remove" and var["JCRUD_AFTERCONF"]: id = var["id"] PAYMENTOP(var).removePaymentForBill(_getPayName(var), id) _setChanged(var) var["JCLOSE_DIALOG"] = True
def elempayment(action,var) : cutil.printVar("elempayment",action,var) if action == "before" and var["JCRUD_DIALOG"] == "crud_add" : var["paymentdate"] = cutil.today() b = BILLLIST(var).findElem(_getPayName(var)) sumtotal = rutil.countTotal(var,b,rutil.getPayments(var)) sumpay = rutil.countPayments(var,_getPayName(var)) acc = con.minusDecimal(sumtotal,sumpay) if acc < 0 : acc = None var["paymenttotal"] = acc cutil.setCopy(var,["paymentdate","paymenttotal"]) if action == "crud_add" and not var["JCRUD_AFTERCONF"] : var["JYESNO_MESSAGE"] = "Do you want to add payment to this bill ?" var["JMESSAGE_TITLE"] = "" return if action == "crud_add" and var["JCRUD_AFTERCONF"] : p = util.newBillPayment() p.setBillName(_getPayName(var)) p.setPaymentMethod(var["paymethod"]) p.setDateOfPayment(con.toDate(con.today())) p.setPaymentTotal(con.toB(var["paymenttotal"])) PAYMENTOP(var).addPaymentForBill(_getPayName(var),p) var["JCLOSE_DIALOG"] = True _setChanged(var) return if action == "crud_remove" and not var["JCRUD_AFTERCONF"] : var["JYESNO_MESSAGE"] = "Are you sure to remove payment to this bill ?" var["JMESSAGE_TITLE"] = "" return if action == "crud_remove" and var["JCRUD_AFTERCONF"] : id = var["id"] PAYMENTOP(var).removePaymentForBill(_getPayName(var),id) _setChanged(var) var["JCLOSE_DIALOG"] = True
def today(): return con.today()
def dialogaction(action,var) : cutil.printVar("search for rooms",action,var) if action == "before" : var["search_from"] = con.today() var["searchby_days"] = True var["search_nop"] = 2 var["search_days"] = 1 cutil.setCopy(var,["search_from","searchby_days","search_nop","search_days"]) if var["JUPDIALOG_START"] != None : html = var["JUPDIALOG_START"] var["search_html"] = html cutil.setCopy(var,"search_html") cutil.hideButton(var,"tores",True) cutil.hideButton(var,"toresrese",False) if action=="search" : if not _validate(var) : return roo = rutil.searchForRooms(var,var["search_from"],var["search_to"]) alist = None if var["search_html"] != None : (m,alist) = xmlutil.toMap(var["search_html"]) print alist li = [] for l in roo : found = False if alist != None : for re in alist : if re["resroomname"] != l : continue da = re["resday"] if da < var["search_from"] : continue if da >= var["search_to"] : continue print found found = True break if found : continue map = {"search_roomid" : l} util.addRoom(var,l,map,"search_roomcapa","search_roomdesc") ss = util.getServicesForRoom(var,l) if ss != None: map["search_roomservice"] = ss[0][0].getName() map["search_roompricelist"] = ss[1][0] (price,pricechild,priceextra) = rutil.getPriceList(var,ss[1][0],ss[0][0].getName()) perperson = ss[0][0].isPerperson() map["search_price"] = price total= rutil.calculatePrice(perperson,var["search_nop"],0,0,price,pricechild,priceextra) map["search_priceperson"] = total map["search_pricetotal"] = con.mulIntDecimal(var["search_days"],total) li.append(map) cutil.setJMapList(var,LISTID,li) if action == "seton" and var[LISTID+"_lineset"] : _goto(var) if action == "tores" and var[LISTID+"_lineset"] : if not _validate(var) : return _goto(var) var["JCLOSE_DIALOG"] = True diallaunch.newreservation(var,var["search_roomid"],var["search_from"],var["search_days"],var["search_nop"],var["search_roomservice"],var["search_roompricelist"]) if action == "toresrese" and var[LISTID+"_lineset"] : if not _validate(var) : return _goto(var) var["JCLOSE_DIALOG"] = _setStartRes(var)
def getResStatusRese(var, r, room=None, today=None): """ Calculates and returns the status of the reservation Args: var r ReservationForm room room symbol today Returns: 0 reservation scheduled 1 reservation confirmed 2 reservation advance paid 3 reservation advanced expired 4 customer not arrived 5 vacant not paid 6 vacant paid 7 vacant excess payment 8 occupied, not paid 9 occupied, advance paid 10 occupied paid 11 occupied excess paid 12 canceled """ S = RESSTATUS() if today == None: today = con.today() S.forday = today # print today sym = r.getName() re = util.resStatus(r) if re == 0: return (12, S) li = rutil.getPayments(var, sym) for l in li: if room != None and room != l.getRoomName(): continue (S.arrival, S.departure) = rutil.calculateDates(S.arrival, S.departure, l) if today < S.arrival and re != 1: advance = r.getAdvanceDeposit() resstatusset = False if advance == None: resstatusset = True else: term = con.toJDate(r.getTermOfAdvanceDeposit()) if term != None: if today < term: resstatusset = True if resstatusset: if re == 2: return (1, S) if re == 3: return (0, S) # internal error, not expected # TO DO return (0, S) if r.getAdvancePayment() == None: return (3, S) if r.getAdvancePayment() < r.getAdvanceDeposit(): return (3, S) return (2, S) if re != 1: return (4, S) sta = None # 0 - not paid # 1 - paid # 2 - excess paid # 3 - advance paid for l in li: add = False re = con.toJDate(l.getResDate()) if util.isRoomService(l.getServiceType()) and re < today: add = True if not util.isRoomService(l.getServiceType()) and re <= today: add = True # print sym,add,l.getPriceTotal() if add: S.sumcost = con.addDecimal( S.sumcost, con.BigDecimalToDecimal(l.getPriceTotal())) S.costlist.append(l) else: if S.sumcostafter == None: S.sumcostafter = 0.0 S.sumcostafter = con.addDecimal( S.sumcostafter, con.BigDecimalToDecimal(l.getPriceTotal())) S.costlistafter.append(l) S.advancepayment = con.BigDecimalToDecimal(r.getAdvancePayment()) if S.advancepayment != None and S.advancepayment >= S.sumcost: sta = 3 else: bli = util.RESOP(var).findBillsForReservation(sym) for b in bli: (suma, advanced) = rutil.countPaymentsA(var, b.getName()) S.sumpay = con.addDecimal(S.sumpay, suma) S.advancepaymentused = con.addDecimal(S.advancepaymentused, advanced) S.sumpay = con.addDecimal(S.sumpay, S.advancepayment) # print sym,S.sumcost,S.sumpay if S.sumcost == S.sumpay and S.sumcost > 0.0: sta = 1 elif S.sumcost > S.sumpay: sta = 0 elif S.sumcost == 0 and S.sumpay == 0: sta = 0 else: sta = 2 S.advancepaymentleft = con.minusDecimal(S.advancepayment, S.advancepaymentused) if today <= S.departure: if sta == 0: return (8, S) if sta == 3: return (9, S) if sta == 2: return (11, S) return (10, S) if sta == 0: return (5, S) if sta == 3: return (6, S) if sta == 2: return (7, S) return (6, S)
def getResStatusRese(var,r,room=None,today=None) : """ Calculates and returns the status of the reservation Args: var r ReservationForm room room symbol today Returns: 0 reservation scheduled 1 reservation confirmed 2 reservation advance paid 3 reservation advanced expired 4 customer not arrived 5 vacant not paid 6 vacant paid 7 vacant excess payment 8 occupied, not paid 9 occupied, advance paid 10 occupied paid 11 occupied excess paid 12 canceled """ S = RESSTATUS() if today == None : today = con.today() S.forday = today # print today sym = r.getName() re = util.resStatus(r) if re == 0 : return (12,S) li = rutil.getPayments(var,sym) for l in li : if room != None and room != l.getRoomName() : continue (S.arrival,S.departure) = rutil.calculateDates(S.arrival,S.departure,l) if today < S.arrival and re != 1 : advance = r.getAdvanceDeposit() resstatusset = False if advance == None : resstatusset = True else : term = con.toJDate(r.getTermOfAdvanceDeposit()) if term != None : if today < term : resstatusset = True if resstatusset : if re == 2 : return (1,S) if re == 3 : return (0,S) # internal error, not expected # TO DO return (0,S) if r.getAdvancePayment() == None : return (3,S) if r.getAdvancePayment() < r.getAdvanceDeposit() : return (3,S) return (2,S) if re != 1 : return (4,S) sta = None # 0 - not paid # 1 - paid # 2 - excess paid # 3 - advance paid for l in li : add = False re = con.toJDate(l.getResDate()) if util.isRoomService(l.getServiceType()) and re < today : add = True if not util.isRoomService(l.getServiceType()) and re <= today : add = True # print sym,add,l.getPriceTotal() if add : S.sumcost = con.addDecimal(S.sumcost,con.BigDecimalToDecimal(l.getPriceTotal())) S.costlist.append(l) else : if S.sumcostafter == None : S.sumcostafter = 0.0 S.sumcostafter = con.addDecimal(S.sumcostafter,con.BigDecimalToDecimal(l.getPriceTotal())) S.costlistafter.append(l) S.advancepayment = con.BigDecimalToDecimal(r.getAdvancePayment()) if S.advancepayment != None and S.advancepayment >= S.sumcost : sta = 3 else : bli = util.RESOP(var).findBillsForReservation(sym) for b in bli : (suma,advanced) = rutil.countPaymentsA(var,b.getName()) S.sumpay = con.addDecimal(S.sumpay,suma) S.advancepaymentused = con.addDecimal(S.advancepaymentused,advanced) S.sumpay = con.addDecimal(S.sumpay,S.advancepayment) # print sym,S.sumcost,S.sumpay if S.sumcost == S.sumpay and S.sumcost > 0.0 : sta = 1 elif S.sumcost > S.sumpay : sta = 0 elif S.sumcost == 0 and S.sumpay == 0 : sta = 0 else : sta = 2 S.advancepaymentleft = con.minusDecimal(S.advancepayment,S.advancepaymentused) if today <= S.departure : if sta == 0 : return (8,S) if sta == 3 : return (9,S) if sta == 2 : return (11,S) return (10,S) if sta == 0 : return (5,S) if sta == 3 : return (6,S) if sta == 2 : return (7,S) return (6,S)
def dialogaction(action, var): cutil.printVar("search for rooms", action, var) if action == "before": var["search_from"] = con.today() var["searchby_days"] = True var["search_nop"] = 2 var["search_days"] = 1 cutil.setCopy( var, ["search_from", "searchby_days", "search_nop", "search_days"]) if var["JUPDIALOG_START"] != None: html = var["JUPDIALOG_START"] var["search_html"] = html cutil.setCopy(var, "search_html") cutil.hideButton(var, "tores", True) cutil.hideButton(var, "toresrese", False) if action == "search": if not _validate(var): return roo = rutil.searchForRooms(var, var["search_from"], var["search_to"]) alist = None if var["search_html"] != None: (m, alist) = xmlutil.toMap(var["search_html"]) print alist li = [] for l in roo: found = False if alist != None: for re in alist: if re["resroomname"] != l: continue da = re["resday"] if da < var["search_from"]: continue if da >= var["search_to"]: continue print found found = True break if found: continue map = {"search_roomid": l} util.addRoom(var, l, map, "search_roomcapa", "search_roomdesc") ss = util.getServicesForRoom(var, l) if ss != None: map["search_roomservice"] = ss[0][0].getName() map["search_roompricelist"] = ss[1][0] (price, pricechild, priceextra) = rutil.getPriceList(var, ss[1][0], ss[0][0].getName()) perperson = ss[0][0].isPerperson() map["search_price"] = price total = rutil.calculatePrice(perperson, var["search_nop"], 0, 0, price, pricechild, priceextra) map["search_priceperson"] = total map["search_pricetotal"] = con.mulIntDecimal( var["search_days"], total) li.append(map) cutil.setJMapList(var, LISTID, li) if action == "seton" and var[LISTID + "_lineset"]: _goto(var) if action == "tores" and var[LISTID + "_lineset"]: if not _validate(var): return _goto(var) var["JCLOSE_DIALOG"] = True diallaunch.newreservation(var, var["search_roomid"], var["search_from"], var["search_days"], var["search_nop"], var["search_roomservice"], var["search_roompricelist"]) if action == "toresrese" and var[LISTID + "_lineset"]: if not _validate(var): return _goto(var) var["JCLOSE_DIALOG"] = _setStartRes(var)