def _getMonthStat(var,name) : G = GETSTAT(var,name) G.readQuery() per = {} y = None m = None dstart = con.incDays(G.dstart,-1) while (dstart != G.dend) : dstart = con.incDays(dstart) if y != None and y == dstart.year and m == dstart.month : continue y = dstart.year m = dstart.month dpocz = datetime.date(y,m,1) dkon = datetime.date(y,m,con.lastDay(y,m)) per[(y,m)] = (con.nofDays(dpocz,dkon)+1,0,0) for r in G.seq : status = util.resStatus(r[0]) date = con.toJDate(r[1].getResDate()) key = (date.year,date.month) (nofdays,staydays,resdays) = per[key] if status == 1 : staydays = staydays + 1 if status == 2 : resdays = resdays + 1 per[key] = (nofdays,staydays,resdays) return per
def readBlobList(self,var): self.readList(var) l = var["JLIST_MAP"][self._bloblist] for k in l : bkey = k["blob_key"] d = B.getModifTime(__getO(var),bkey).getCreationDate() dd = con.toJDate(d) k["blob_date"] = dd
def _toMap(map,li): ma = {} for e in map.entrySet() : k= e.getKey() if li != None and not k in li : continue v = e.getValue() if type(v) == Date : v = con.toJDate(v) ma[k] = v return ma
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 getVar(map,dialogname,xml,listv): """ Set map with values read from xml string for dialog form. Retrieves values from XML string and set values to the map (key->value). Retrieves values only for list of keys (not for all found in XML string) Args: map : A map being set. Can be empty or contains some values already. In case of conflict new value will overwrite existing value. dialogname : Dialog name where form is available. xml : XML string to be analyzed. listv : List of keys to be set to the map. Only keys found in the list are set. Others are ignored. """ iXml = Holder.getXMLTransformer(); v = DialogVariables(); iXml.fromXML(dialogname,v,xml); for vname in listv : val = v.getValue(vname) if val == None or val.getValue() == None: map[vname] = None continue if val.getType() == TT.STRING : map[vname] = val.getValueS() continue if val.getType() == TT.BIGDECIMAL : b = val.getValueBD() map[vname] = con.BigDecimalToDecimal(b) continue if val.getType() == TT.BOOLEAN : b = val.getValueB() map[vname] = b continue if val.getType() == TT.INT : map[vname] = val.getValue() continue if val.getType() == TT.DATE : map[vname] = con.toJDate(val.getValue()) continue if val.getType() == TT.DATETIME : map[vname] = con.toJDateTime(val.getValue()) continue
def getVar(map,dialogname,xml,listv): """ Set map with values read from xml string for dialog form. Retrieves values from XML string and set values to the map (key->value). Retrieves values only for list of keys (not for all found in XML string) Args: map : A map being set. Can be empty or contains some values already. In case of conflict new value will overwrite existing value. dialogname : Dialog name where form is available. xml : XML string to be analyzed. listv : List of keys to be set to the map. Only keys found in the list are set. Others are ignored. """ iXml = Holder.getXMLTransformer(); v = DialogVariables(); iXml.fromXML(dialogname,v,xml); for vname in listv : val = v.getValue(vname) if val == None or val.getValue() == None: map[vname] = None continue if val.getType() == TT.STRING : map[vname] = val.getValueS() continue if val.getType() == TT.BIGDECIMAL : b = val.getValueBD() map[vname] = con.BigDecimalToDecimal(b) continue if val.getType() == TT.BOOLEAN : b = val.getValueB() map[vname] = b continue if val.getType() == TT.INT or val.getType() == TT.LONG : map[vname] = val.getValue() continue if val.getType() == TT.DATE : map[vname] = con.toJDate(val.getValue()) continue if val.getType() == TT.DATETIME : map[vname] = con.toJDateTime(val.getValue()) continue
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 _XbuildElemXML(var,ma,r,CV=None): da = con.toJDate(r.getServDate()) roomname = r.getRoomName() desc = util.ROOMLIST(var).findElem(roomname).getDescription() rate = r.getPrice() amount = r.getNoP() total = r.getPriceTotal() ma["date"] =da ma["roomnumber"] = roomname ma["description"] = desc ma["dailyrate"] = rate ma["amount"] = amount ma["total"] = total ma["id"] = r.getId() if CV != None : vats = rutil.getVatName(var,r) (netto,vatv,vatlevel) = CV.calculateVatValue(con.BigDecimalToDecimal(total),vats) ma["netvalue"] = netto ma["taxvalue"] = vatv ma["taxlevel"] = vatlevel ma["tax"] = vats ma["grossvalue"] = con.addDecimal(netto,vatv)
def selectSQL(sql, param, li): cone = __getConnection() st = cone.prepareStatement(sql) __resolvePos(st, param) res = st.executeQuery() resli = [] if type(li) != list: li = [li] while res.next(): ma = {} for l in li: val = None if l[2] == cutil.STRING: val = res.getString(l[1]) elif l[2] == cutil.LONG: val = res.getLong(l[1]) elif l[2] == cutil.DECIMAL: val = res.getDouble(l[1]) else: d = res.getDate(l[1]) val = con.toJDate(d) ma[l[0]] = val resli.append(ma) cone.close() return resli
def _XbuildElemXML(var, ma, r, CV=None): da = con.toJDate(r.getServDate()) roomname = r.getRoomName() desc = util.ROOMLIST(var).findElem(roomname).getDescription() rate = r.getPrice() amount = r.getNoP() total = r.getPriceTotal() ma["date"] = da ma["roomnumber"] = roomname ma["description"] = desc ma["dailyrate"] = rate ma["amount"] = amount ma["total"] = total ma["id"] = r.getId() if CV != None: vats = rutil.getVatName(var, r) (netto, vatv, vatlevel) = CV.calculateVatValue(con.BigDecimalToDecimal(total), vats) ma["netvalue"] = netto ma["taxvalue"] = vatv ma["taxlevel"] = vatlevel ma["tax"] = vats ma["grossvalue"] = con.addDecimal(netto, vatv)
def toJDate(value): return con.toJDate(value)
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 calculateDates(arrival, departure, l): return calculateJDates(arrival, departure, con.toJDate(l.getServDate()))