# Path: chIceCash.py
# def _round(V,n):
#     fmt = "%."+str(n)+"f"
#     return fmt % round(V,n)
#     
#     z=str(V.__format__(".4f")).split(".")
#     if len(z)<2:
#         return str(V)
#     else:
#         d=int(z[0])
#         f=z[1].ljust(n,"0")
#     l=len(f)
#     a=[]
#     for i in range(l):
#         a.append(int(f[i]))
#     r=range(l)[n:]
#     r.reverse()
#     x=range(l)[:n]
#     x.reverse()
#     ost=0
#     for i in r:
#         a[i]+=ost
#         if a[i]>=5:
#             ost=1
#         else:
#             ost=0
#     for i in x:
#         a[i]+=ost
#         if a[i]>9:
#             a[i]=0
#             ost=1
#         else:
#             ost=0
#             break
#     d+=ost
#     s=""
#     for i in range(n):
#         s+=str(a[i])
#     if n>0:
#         s="."+s
#     result=str(d)+s
#     return result


import my
import os
import re
import tbIceCash as tbs
import datetime
from chIceCash import _round
from md5 import md5
        for n in ('end_date','end_time','begin_date','begin_time','date'):
            self.Zet[n]=str(self.Zet[n])

        self.Zet_ct=[]
        if not full:
            return True

        calcCt=self.get(self.tb_trsc_hd._calc_ct(idbegin,idend))
        fd=['section','idgroup','code','alco','paramf1','paramf2','paramf3','discount','bonus','bonus_discount','isfiscal']
        for d in calcCt:
            ct={}
            for i in range(len(d)):
                ct[fd[i]]=d[i]
            self.Zet_ct.append(ct)
        return True

    def _trsc_last(self,_if=""):
        d=self.get(self.tb_trsc_hd._last(self.idplace,self.nkassa,_if))
        if len(d)==0:
            self.trsc=None
            return 0
        else:
            self.trsc=d[0]
            return d[0][0]

    def _trsc_filter(self,dt1,dt2,tm1,tm2,ncheck,tcheck,tpay,tclose,dcard,bcard,fiscal,error,discount,bonus,summa,alco,code,group):
        r=self.get(self.tb_trsc_hd._filter(self.idplace,self.nkassa,dt1,dt2,tm1,tm2,ncheck,tcheck,tpay,tclose,dcard,bcard,fiscal,error,discount,bonus,summa,alco,code,group))
        self.f_checks=[]
        for n in r:
            data=self.tb_trsc_hd.result2values(n,tostr=True)

# Path: chIceCash.py
# def _round(V,n):
#     fmt = "%."+str(n)+"f"
#     return fmt % round(V,n)
#     
#     z=str(V.__format__(".4f")).split(".")
#     if len(z)<2:
#         return str(V)
#     else:
#         d=int(z[0])
#         f=z[1].ljust(n,"0")
#     l=len(f)
#     a=[]
#     for i in range(l):
#         a.append(int(f[i]))
#     r=range(l)[n:]
#     r.reverse()
#     x=range(l)[:n]
#     x.reverse()
#     ost=0
#     for i in r:
#         a[i]+=ost
#         if a[i]>=5:
#             ost=1
#         else:
#             ost=0
#     for i in x:
#         a[i]+=ost
#         if a[i]>9:
#             a[i]=0
#             ost=1
#         else:
#             ost=0
#             break
#     d+=ost
#     s=""
#     for i in range(n):
#         s+=str(a[i])
#     if n>0:
#         s="."+s
#     result=str(d)+s
#     return result


# Path: dbIceCash.py
import my
import os
import re
import tbIceCash as tbs
import datetime
from chIceCash import _round
from md5 import md5

        for n in ('end_date','end_time','begin_date','begin_time','date'):
            self.Zet[n]=str(self.Zet[n])

        self.Zet_ct=[]
        if not full:
            return True

        calcCt=self.get(self.tb_trsc_hd._calc_ct(idbegin,idend))
        fd=['section','idgroup','code','alco','paramf1','paramf2','paramf3','discount','bonus','bonus_discount','isfiscal']
        for d in calcCt:
            ct={}
            for i in range(len(d)):
                ct[fd[i]]=d[i]
            self.Zet_ct.append(ct)
        return True

    def _trsc_last(self,_if=""):
        d=self.get(self.tb_trsc_hd._last(self.idplace,self.nkassa,_if))
        if len(d)==0:
            self.trsc=None
            return 0
        else:
            self.trsc=d[0]
            return d[0][0]

    def _trsc_filter(self,dt1,dt2,tm1,tm2,ncheck,tcheck,tpay,tclose,dcard,bcard,fiscal,error,discount,bonus,summa,alco,code,group):
        r=self.get(self.tb_trsc_hd._filter(self.idplace,self.nkassa,dt1,dt2,tm1,tm2,ncheck,tcheck,tpay,tclose,dcard,bcard,fiscal,error,discount,bonus,summa,alco,code,group))
        self.f_checks=[]
        for n in r:
            data=self.tb_trsc_hd.result2values(n,tostr=True)

            data['vir']=_round(float(data['summa'])-float(data['discount_sum'])-float(data['bonus_discount']),2)