示例#1
0
class BankParcer(object):
    """Get xml file """
    def __init__(self):
        """@todo: to be defined1. """
        self.c = Config()
        self.soap = soap()

    def xml2dict_summary_bank(self, bank_id, date=datetime.now().date()):
        if bank_id == '0':
            xml = self.soap.get_data('0', bank_id, date)
        else:
            xml = self.soap.get_data('1', bank_id, date)
        tree = ElementTree(fromstring(xml.encode('utf-8')))
        root = ElementTree.getroot(tree)
        children = root.getchildren()
        for item in children:
            summary = item.attrib
        return summary

    def xml2dict_ext_bank(self, bank_id, date=str(datetime.now().date())):
        """@todo:  Выборка расширеной информации"""
        if bank_id == '0':
            xml = self.soap.get_data('0', bank_id, date)
        else:
            xml = self.soap.get_data('1', bank_id, date)
        tree = ElementTree(fromstring(xml.encode('utf-8')))
        root = ElementTree.getroot(tree)
        eb = root.getchildren()
        data_list = []
        for items in eb[0].getchildren():
            data_list.append(items.attrib)
        return data_list

    def sum_of_all(self, date=datetime.now().date()):
        bankid = self.c.bank_id()
        kost_list = []
        for keys in bankid:
            if keys != '__name__' and keys != '1':
                if keys == '0':
                    xml = self.soap.get_data('0', keys, date)
                else:
                    xml = self.soap.get_data('1', keys, date)
                tree = ElementTree(fromstring(xml.encode('utf-8')))
                root = ElementTree.getroot(tree)
                children = root.getchildren()
                for item in children:
                    if item.attrib.has_key('kassa_konech_ost'):
                        kost_list.append(
                            item.attrib['kassa_konech_ost'].encode(
                                'ascii', 'ignore'))
                    if item.attrib.has_key('bank_konech_ost'):
                        kost_list.append(item.attrib['bank_konech_ost'].encode(
                            'ascii', 'ignore'))
        sum = 0
        locale.setlocale(locale.LC_ALL, 'ru_UA.UTF-8')
        for item in kost_list:
            sum = sum + float(atof(item))
        return currency(sum, symbol=False, grouping=True)
示例#2
0
class BankParcer(object):

    """Get xml file """

    def __init__(self):
        """@todo: to be defined1. """
        self.c = Config()
        self.soap = soap()

    def xml2dict_summary_bank(self, bank_id, date=datetime.now().date()):
        if bank_id == '0':
            xml = self.soap.get_data('0',bank_id, date)
        else:
            xml = self.soap.get_data('1',bank_id, date)            
        tree = ElementTree(fromstring(xml.encode('utf-8')))
        root = ElementTree.getroot(tree)
        children = root.getchildren()
        for item in children:
            summary = item.attrib
        return summary

    def xml2dict_ext_bank(self, bank_id, date=str(datetime.now().date())):
        """@todo:  Выборка расширеной информации"""
        if bank_id == '0':
            xml = self.soap.get_data('0',bank_id, date)
        else:
            xml = self.soap.get_data('1',bank_id, date)  
        tree = ElementTree(fromstring(xml.encode('utf-8')))
        root = ElementTree.getroot(tree)
        eb = root.getchildren()
        data_list=[]
        for items in eb[0].getchildren():
            data_list.append(items.attrib)
        return data_list

    def sum_of_all(self, date=datetime.now().date()):
        bankid = self.c.bank_id()
        kost_list = []
        for keys in bankid:
            if keys != '__name__' and keys != '1':
                if keys == '0':
                    xml = self.soap.get_data('0',keys, date)
                else:
                    xml = self.soap.get_data('1',keys, date)
                tree = ElementTree(fromstring(xml.encode('utf-8')))
                root = ElementTree.getroot(tree)                
                children = root.getchildren()
                for item in children:
                    if item.attrib.has_key('kassa_konech_ost'):
                        kost_list.append(item.attrib['kassa_konech_ost'].encode('ascii','ignore'))
                    if item.attrib.has_key('bank_konech_ost'):
                        kost_list.append( item.attrib['bank_konech_ost'].encode('ascii','ignore'))
        sum = 0
	locale.setlocale( locale.LC_ALL, 'ru_UA.UTF-8' )
        for item in kost_list:
            sum = sum + float(atof(item))
        return currency(sum, symbol=False, grouping=True)
示例#3
0
 def __init__(self):
     """@todo: to be defined1. """
     self.c = Config()
     self.soap = soap()
示例#4
0
 def __init__(self):
     """@todo: to be defined1. """
     self.c = Config()
     self.soap = soap()