Пример #1
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)
Пример #2
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)
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                
Пример #5
0
def removeDecimalFooter(var, list, name):
    footerdef = "JFOOTER_" + list + "_" + name
    currentfooter = var[footerdef]
    val = var[name]
    currentfooter = con.minusDecimal(currentfooter, val)
    setFooter(var, list, name, currentfooter)
Пример #6
0
def minusDecimal(sum1, sum2, afterdot=2):
    return con.minusDecimal(sum1, sum2, afterdot)
Пример #7
0
def removeDecimalFooter(var, list, name) :
    footerdef = "JFOOTER_" + list + "_" + name
    currentfooter = var[footerdef]
    val = var[name]
    currentfooter = con.minusDecimal(currentfooter, val)
    setFooter(var, list, name, currentfooter)
Пример #8
0
def minusDecimal(sum1, sum2, afterdot=2):
   return con.minusDecimal(sum1, sum2, afterdot) 
Пример #9
0
def calcBalance(debet, credit):
    if debet == None: return (None, credit)
    if credit == None: return (debet, None)
    if credit == debet: return (None, None)
    if debet > credit: return (con.minusDecimal(debet, credit), None)
    return (None, con.minusDecimal(credit, debet))
Пример #10
0
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)
Пример #11
0
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)