def _ListOfBills(var) : rese = rutil.getReseName(var) assert rese != None bList = util.RESOP(var).findBillsForReservation(rese) seq = [] pli = rutil.getPayments(var) sumtotal = 0.0 footerpayments = 0.0 sumsell = 0.0 CU = util.CUSTOMERLIST(var) for b in bList : C = cbill.BILLCALC(var,b) C.calc() bName = b.getName() assert bName != None payer = b.getPayer() customer = CU.findElem(payer) assert customer != None da = b.getIssueDate() tot = C.getTotal() sell = C.getCharge() paysum = C.getPayment() sumtotal = cutil.addDecimal(sumtotal,tot) footerpayments = cutil.addDecimal(footerpayments,paysum) sumsell = cutil.addDecimal(sumsell,sell) ma = { "billname" : bName, "billtotal" : tot, "payments" : paysum, "sell" : sell } cust.toCustomerVar(ma,customer,"payer_") seq.append(ma) cutil.setJMapList(var,BILLIST,seq) cutil.setFooter(var,BILLIST,"billtotal",sumtotal) cutil.setFooter(var,BILLIST,"payments",footerpayments) cutil.setFooter(var,BILLIST,"sell",sumsell)
def countPaymentsA(var, billName): pList = util.PAYMENTOP(var).getPaymentsForBill(billName) suma = 0.0 advanced = 0.0 for p in pList: total = p.getPaymentTotal() if p.isAdvancepayment(): advanced = cutil.addDecimal(advanced, con.BigDecimalToDecimal(total)) else: suma = cutil.addDecimal(suma, con.BigDecimalToDecimal(total)) return (suma, advanced)
def elemaction(action, var): printVar("elem action", action, var) if action == "before": da = var["week"] li = R.getList(da) var["JLIST_MAP"] = {"listpay": li} sum = None for l in li: b = l["pay"] sum = addDecimal(sum, b) var["JFOOTER_COPY_listpay_pay"] = True var["JFOOTER_listpay_pay"] = sum if var["JCRUD_DIALOG"] != "crud_remove": setStandEditMode(var, "listpay", ["pay"]) if action == "signalchange" and var["JCRUD_DIALOG"] == "crud_add": da = var["week"] if da == None: return if da.weekday() != 0: var["JERROR_week"] = "Date should be the Monday" return li = R.getListOfEntries() for l in li: if l[1] == da: var["JERROR_week"] = "Already used" return list = [] td = datetime.timedelta(1) for i in range(5): list.append({"date": da, "pay": None}) da = da + td var["JLIST_MAP"] = {"listpay": list} setStandEditMode(var, "listpay", ["pay"]) var["JFOOTER_COPY_listpay_pay"] = True var["JFOOTER_listpay_pay"] = None if action == "columnchangeaction": modifDecimalFooter(var, "listpay", "pay") if action == "crud_add": da = var["week"] R.addList(da, var["JLIST_MAP"]["listpay"]) var["JCLOSE_DIALOG"] = True if action == "crud_change": da = var["week"] R.changeList(da, var["JLIST_MAP"]["listpay"]) var["JCLOSE_DIALOG"] = True if action == "crud_remove": da = var["week"] R.removeList(da) var["JCLOSE_DIALOG"] = True
def elemaction(action,var): printVar("elem action",action,var) if action == "before" : da = var["week"] li = R.getList(da) var["JLIST_MAP"] = { "listpay" : li} sum = None for l in li : b = l["pay"] sum = addDecimal(sum,b) var["JFOOTER_COPY_listpay_pay"] = True var["JFOOTER_listpay_pay"] = sum if var["JCRUD_DIALOG"] != "crud_remove" : setStandEditMode(var,"listpay",["pay"]) if action == "signalchange" and var["JCRUD_DIALOG"] == "crud_add": da = var["week"] if da == None : return if da.weekday() != 0 : var["JERROR_week"] = "Date should be the Monday" return li = R.getListOfEntries() for l in li : if l[1] == da : var["JERROR_week"] = "Already used" return list = [] td = datetime.timedelta(1) for i in range(5) : list.append({"date" : da, "pay" : None}) da = da + td var["JLIST_MAP"] = { "listpay" : list} setStandEditMode(var,"listpay",["pay"]) var["JFOOTER_COPY_listpay_pay"] = True var["JFOOTER_listpay_pay"] = None if action == "columnchangeaction" : modifDecimalFooter(var,"listpay","pay") if action == "crud_add" : da = var["week"] R.addList(da, var["JLIST_MAP"]["listpay"]) var["JCLOSE_DIALOG"] = True if action == "crud_change" : da = var["week"] R.changeList(da, var["JLIST_MAP"]["listpay"]) var["JCLOSE_DIALOG"] = True if action == "crud_remove" : da = var["week"] R.removeList(da) var["JCLOSE_DIALOG"] = True
def doaction(action, var): printVar("footeredit", action, var) if action == "before": # cutil.setJMapList(var,"list",[]) cutil.setAddEditMode(var, "list", ["leftk", "amount", "rightk"]) li = F.readList(var) leftf = None rightf = None for l in li: if l["leftk"]: leftf = cutil.addDecimal(leftf, l["amount"]) if l["rightk"]: rightf = cutil.addDecimal(rightf, l["amount"]) cutil.setFooter(var, "list", "leftk", leftf) cutil.setFooter(var, "list", "rightk", rightf) if action == "editlistrowaction": var["JLIST_EDIT_ACTIONOK_list"] = True if var["JLIST_EDIT_ACTION_list"] == "REMOVE": cutil.removeTextFooter(var, "list", "leftk", "amount") cutil.removeTextFooter(var, "list", "rightk", "amount") if action == "save": li = var["JLIST_MAP"]["list"] k = 0 for m in li: m["id"] = k k = k + 1 F.saveList(var) if action == "columnchangeaction" and ( (var["changefield"] == "leftk" or var["changefield"] == "rightk")): cutil.modifTextFooter(var, "list", var["changefield"], "amount") if action == "columnchangeaction" and var["changefield"] == "amount": cutil.modifTextDecimalFooter(var, "list", "leftk", "amount") cutil.modifTextDecimalFooter(var, "list", "rightk", "amount")
def _ListOfBills(var): rese = rutil.getReseName(var) assert rese != None bList = util.RESOP(var).findBillsForReservation(rese) seq = [] pli = rutil.getPayments(var) sumtotal = 0.0 footerpayments = 0.0 sumsell = 0.0 CU = util.CUSTOMERLIST(var) for b in bList: C = cbill.BILLCALC(var, b) C.calc() bName = b.getName() assert bName != None payer = b.getPayer() customer = CU.findElem(payer) assert customer != None da = b.getIssueDate() tot = C.getTotal() sell = C.getCharge() paysum = C.getPayment() sumtotal = cutil.addDecimal(sumtotal, tot) footerpayments = cutil.addDecimal(footerpayments, paysum) sumsell = cutil.addDecimal(sumsell, sell) ma = { "billname": bName, "billtotal": tot, "payments": paysum, "sell": sell } cust.toCustomerVar(ma, customer, "payer_") seq.append(ma) cutil.setJMapList(var, BILLIST, seq) cutil.setFooter(var, BILLIST, "billtotal", sumtotal) cutil.setFooter(var, BILLIST, "payments", footerpayments) cutil.setFooter(var, BILLIST, "sell", sumsell)
def doaction(action,var) : printVar("footeredit",action,var) if action == "before" : # cutil.setJMapList(var,"list",[]) cutil.setAddEditMode(var,"list",["leftk","amount","rightk"]) li = F.readList(var) leftf = None rightf = None for l in li : if l["leftk"] : leftf = cutil.addDecimal(leftf,l["amount"]) if l["rightk"] : rightf = cutil.addDecimal(rightf,l["amount"]) cutil.setFooter(var,"list","leftk",leftf) cutil.setFooter(var,"list","rightk",rightf) if action == "editlistrowaction" : var["JLIST_EDIT_ACTIONOK_list"] = True if var["JLIST_EDIT_ACTION_list"] == "REMOVE" : cutil.removeTextFooter(var,"list","leftk","amount") cutil.removeTextFooter(var,"list","rightk","amount") if action == "save" : li = var["JLIST_MAP"]["list"] k = 0 for m in li : m["id"] = k k = k + 1 F.saveList(var) if action == "columnchangeaction" and ((var["changefield"] == "leftk" or var["changefield"] == "rightk")) : cutil.modifTextFooter(var,"list",var["changefield"],"amount") if action == "columnchangeaction" and var["changefield"] == "amount" : cutil.modifTextDecimalFooter(var,"list","leftk","amount") cutil.modifTextDecimalFooter(var,"list","rightk","amount")
def addMa(self,ma,r,idp) : se = r.getServiceType() resdate = None servdate= None if util.isRoomService(se) : resdate = r.getResDate() else : servdate = r.getResDate() total = r.getPriceTotal() self.sumf = cutil.addDecimal(self.sumf,cutil.BigDecimalToDecimal(total)) guest = r.getGuestName() room = r.getRoomName() service = r.getService() q = r.getQuantity() ma1 = { "idp" : idp, "room" : room, "resday" : resdate, "service" : service, "servday":servdate, "servdescr" : r.getDescription(),"guest_name" : guest, \ "total" : total, "quantity" : q, "vat" : rutil.getVatName(self.var,r) } ma.update(ma1) self.li.append(ma)
def addMa(self, ma, r, idp): se = r.getServiceType() resdate = None servdate = None if util.isRoomService(se): resdate = r.getResDate() else: servdate = r.getResDate() total = r.getPriceTotal() self.sumf = cutil.addDecimal(self.sumf, cutil.BigDecimalToDecimal(total)) guest = r.getGuestName() room = r.getRoomName() service = r.getService() q = r.getQuantity() ma1 = { "idp" : idp, "room" : room, "resday" : resdate, "service" : service, "servday":servdate, "servdescr" : r.getDescription(),"guest_name" : guest, \ "total" : total, "quantity" : q, "vat" : rutil.getVatName(self.var,r) } ma.update(ma1) self.li.append(ma)
def walk(self,idp,pa) : to = cutil.BigDecimalToDecimal(pa.getPriceTotal()) self.total = cutil.addDecimal(self.total,to)
def doaction(action,var) : cutil.printVar("create bill",action,var) if action == "before" : _createPosList(var) # payer rese = rutil.getReseName(var) R = util.RESFORM(var) r = R.findElem(rese) payername = r.getCustomerName() cust.setCustData(var,payername,PAY) var["paynow"] = True cutil.setCopy(var,["paynow","paymethod",DOCTYPE]) var["paymethod"] = util.HOTELDEFADATA().getDataH(3) var[DOCTYPE] = util.HOTELDEFADATA().getDataH(5) RR = resstat.getResStatusR(var,r) var["advance_pay_left"] = RR.advancepaymentleft var["advance_pay"] = RR.advancepayment cutil.setCopy(var,["advance_pay","advance_pay_left"]) if action == "guestdetail" : cust.showCustomerDetails(var,var["guest_name"]) if action == "columnchangeaction" : total = var["total"] footerf = var["JFOOTER_billlist_total"] if var["add"] : footerf = cutil.addDecimal(footerf,total) else : footerf = cutil.minusDecimal(footerf,total) cutil.setFooter(var,"billlist","total",footerf) if action == "accept" : pli = [] for m in var["JLIST_MAP"][NOPAID] : if m["add"] : pli.append(m["idp"]) if len(pli) == 0 : var["JERROR_MESSAGE"] = "@nothingischecked" return if var["paynow"] : if cutil.checkEmpty(var,["paymethod"]): return if not var["paynow"] : if cutil.checkEmpty(var,["paymethod","paymentdate"]): return cust.saveCustomerData(var,var["payer_name"],PAY) xml = rpdf.buildXMLForStay(var,rutil.getReseName(var),var["payer_name"],pli) diallaunch.displayDocument(var,xml) if action == "acceptdocument" and var["JUPDIALOG_BUTTON"] == "accept" : util.HOTELDEFADATA().putDataH(3,var["paymethod"]) util.HOTELDEFADATA().putDataH(5,var[DOCTYPE]) xml = var["JUPDIALOG_RES"] H = HOTELBILLSAVE(var,xml) if H.doTransRes() : var["JCLOSE_DIALOG"] = True if action == "payerdetails" : var["JAFTERDIALOG_ACTION"] = "acceptdetails" cust.customerDetailsActive(var,PAY) if action == "acceptdetails" and var["JUPDIALOG_BUTTON"] == "accept" : xml = var["JUPDIALOG_RES"] util.xmlToVar(var,xml,CLIST,PAY) cutil.setCopy(var,CLIST,None,PAY)
def walk(self, idp, pa): to = cutil.BigDecimalToDecimal(pa.getPriceTotal()) self.total = cutil.addDecimal(self.total, to)
def countPayments(var, billName): (suma, advanced) = countPaymentsA(var, billName) return cutil.addDecimal(suma, advanced)