def run(self,var) : # double check (under semaphore) that reservation is not already changed to STAY resName = var["resename"] R = util.RESFORM(var) ROP = util.RESOP(var) CUST = util.CUSTOMERLIST(var) r = R.findElem(resName) if not var["isstay"] and util.resStatus(r) == 1 : var["JERROR_MESSAGE"] = M("ALREADYCHECKEDINMESS") var["JMESSAGE_TITLE"] = M("ALREADYCHECKEDINTITLE") return a = cutil.createArrayList() for custo in var["JLIST_MAP"][CHECKINLIST] : if cutil.allEmpty(custo,cust.getCustFieldIdWithout()) : continue cid = custo["name"] if cid == None : c = cust.newCustomer(var) else : c = CUST.findElem(cid) cust.customerDataFromVar(c,custo) if cid == None : cid = CUST.addElem(c).getName() else : CUST.changeElem(c) cust.saveDefaCustomer(custo) rGuest = util.newResGuest(var) rGuest.setGuestName(cid) rid = custo["roomid"] rGuest.setRoomName(rid) a.add(rGuest) ROP.setResGuestList(resName,a) if var["isstay"] : cutil.JOURNAL(var).addJournalElem(util.JOURNAL_CHANGELISTOFGUEST,None,resName) var["JCLOSE_DIALOG"] = True
def modifyAdvaData(self, resename=None): if resename == None: resename = rutil.getReseName(self.var) R = util.RESFORM(self.var) reservation = R.findElem(resename) self.setAdvaData(reservation) R.changeElem(reservation) cutil.JOURNAL(self.var).addJournalElem( util.JOURNAL_CHANGEADVANCEPAYMENT, None, resename)
def dialogaction(action, var): cutil.printVar("test64", action, var) if action == "test1": li = cutil.JOURNAL(var).getList() JM = cutil.JOURNALMESS() for l in li: print l.getJournalType(), JM.getEntryDescr(l) assert JM.getEntryDescr(l) != None assert 3 == len(li) var["OK"] = True
def dialogaction(action, var): cutil.printVar("test46", action, var) if action == "test1": li = cutil.JOURNAL(var).getList() for j in li: print j.getCreationPerson(), j.getJournalType(), j.getOObjectId() da = j.getCreationDate() print da, type(da) assert "user" == j.getCreationPerson() assert 1 == len(li) var["OK"] = True if action == "test2": li = cutil.JOURNAL(var).getList() logout = False for j in li: print j.getCreationPerson(), j.getJournalType() assert "user" == j.getCreationPerson() if j.getJournalType() == "LOGOUT": logout = True assert 3 == len(li) assert logout var["OK"] = True if action == "test3": jou = cutil.JOURNAL(var).getList() print len(jou) li = [] for j in jou: ma = { "name": j.getName(), "date": j.getCreationDate(), "hotelname": j.getOObjectId(), "journaltype": j.getJournalType(), "user": j.getCreationPerson() } li.append(ma) cutil.setJMapList(var, "list", li) assert 3 == len(li) var["OK"] = True if action == "test4": jou = cutil.JOURNAL(var).getList() print len(jou) li = [] for j in jou: da = j.getCreationDate() print da, type(da) jda = con.toJDateTime(da) # jda = jd.replace(tzinfo=l) # print "jda=",jda,type(jda) tda = time.time() print tda, type(tda) jjda = datetime.datetime.fromtimestamp(time.time()) print jjda, type(jjda) ma = { "name": j.getName(), "date": da, "hotelname": j.getOObjectId(), "journaltype": j.getJournalType(), "user": j.getCreationPerson(), "jdate": jda } li.append(ma) cutil.setJMapList(var, "list1", li) # assert 3 == len(li) var["OK"] = True
def dialogaction(action, var): cutil.printVar("rese mail", action, var) if action == "before": xml = var["JUPDIALOG_START"] (ma, alist) = xmlutil.toMap(xml) rese = ma["resename"] mtype = ma["mailtype"] (C, rform) = _getCust(var, ma) var["to"] = C.getAttr("email") var["from"] = cmail.MAILFROM(var).getFrom() var["xml"] = xml (arrival, departure, roomname, rate, non) = rutil.getReseDate(var, rform) xml = rpdf.buildXMLReservation(var, rese) if mtype == 0: var["subject"] = M("confirmationmailsubject").format( con.toS(arrival), con.toS(departure)) var["content"] = pdfutil.xsltHtmlS("xslt/resconfirmation.xslt", xml) elif mtype == 1: var["subject"] = M("sendpdfmailsubject").format( con.toS(arrival), con.toS(departure)) var["content"] = pdfutil.xsltHtmlS("xslt/sendinvoicepdf.xslt", xml) else: assert False cutil.setCopy(var, ["subject", "to", "from", "content", "xml"]) seq = [] if alist != None: for l in alist: (realm, key, filename) = cutil.splitsubmitres(l["blobid"]) seq.append({"filename": filename, "realm": realm, "key": key}) cutil.setJMapList(var, ALIST, seq) return if action == "sendmail" and var["JYESANSWER"]: H = hmail.HotelMail(var) xml = var["xml"] (ma, templ) = xmlutil.toMap(xml) rese = ma["resename"] (C, rform) = _getCust(var, ma) custname = C.getName() mtype = ma["mailtype"] to = var["to"] fromc = var["from"] cmail.MAILFROM(var).saveFrom(fromc) content = var["content"] subject = var["subject"] C.setAttr("email", to) util.CUSTOMERLIST(var).changeElem(C) attachL = None li = var["JLIST_MAP"][ALIST] attachL = None for l in li: attachL = cmail.createAttachList(attachL, l["realm"], l["key"], l["filename"]) hh = H.sendMail(mtype, rese, custname, subject, content, to, fromc, attachL) ressend = H.getCMail(hh.getName()).getSendResult() if ressend == None: var["JOK_MESSAGE"] = "@okmailsent" var["JCLOSE_DIALOG"] = True else: var["JERROR_MESSAGE"] = ressend var["JMESSAGE_TITLE"] = "@errormailsent" cutil.JOURNAL(var).addJournalElem(util.JOURNAL_SENDCONFMAIL, None, hh.getName(), rese) if action == "sendmail": return cmailaction.mailattachaction(action, var)
def __init__(self, var): self.var = var self.service = H.getResOp() self.J = cutil.JOURNAL(var)
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
def dialogaction(action, var): cutil.printVar("test47", action, var) if action == "test1": S = util.SERVICES(var) print S se = util.newHotelService(var) se.setName("SERV") se.setDescription("Usluga hotelowe") se.setVat("vat22") S.addElem(se) li = cutil.JOURNAL(var).getList() found = False for l in li: print l.getJournalType(), l.getJournalTypeSpec( ), l.getJournalElem1() if l.getJournalType() == "SERVICE": found = True assert l.getJournalTypeSpec() == "ADD" assert l.getJournalElem1() == "SERV" assert found var["OK"] = True if action == "test2": S = util.SERVICES(var) print S se = util.newHotelService(var) se.setName("SERV") se.setDescription("Usluga hotelowe") se.setVat("vat22") S.addElem(se) se.setDescription("Wow") S.changeElem(se) li = cutil.JOURNAL(var).getList() for l in li: print l.getJournalType(), l.getJournalTypeSpec( ), l.getJournalElem1() l = li[0] assert l.getJournalTypeSpec() == "MODIF" assert l.getJournalElem1() == "SERV" assert l.getJournalType() == "SERVICE" var["OK"] = True if action == "test3": S = util.SERVICES(var) print S se = util.newHotelService(var) se.setName("SERV") se.setDescription("Usluga hotelowe") se.setVat("vat22") se = S.addElem(se) S.deleteElem(se) li = cutil.JOURNAL(var).getList() for l in li: print l.getJournalType(), l.getJournalTypeSpec( ), l.getJournalElem1() l = li[0] assert l.getJournalTypeSpec() == "REMOVE" assert l.getJournalElem1() == "SERV" assert l.getJournalType() == "SERVICE" var["OK"] = True if action == "test4": dialogaction("test2", var) li = cutil.JOURNAL(var).getList() JM = journalmess.JournalMess(var) var["OK"] = False for l in li: print l.getJournalType(), l.getJournalTypeSpec( ), l.getJournalElem1() print "mess=", JM.getJournalDescr(l) assert JM.getJournalDescr(l) != None print JM.getListOfType() var["OK"] = True if action == "test5": dialogaction("test3", var) li = cutil.JOURNAL(var).getList() JM = journalmess.JournalMess(var) var["OK"] = False for l in li: print l.getJournalType(), l.getJournalTypeSpec( ), l.getJournalElem1() print "mess=", JM.getJournalDescr(l) assert JM.getJournalDescr(l) != None print JM.getListOfType() var["OK"] = True