Exemplo n.º 1
0
    def csv_ext(rec, only_old_data):
        ret = None
        err = None
        if len(rec) < 6:
            err = ';'.join(rec + [f'мало данных: {len(rec)}'])
        else:
            if ':'.join([rec[0], rec[1], rec[2]]) != '::':
                if rec[0] == '' or rec[1] == '' or rec[2] == '':
                    err = ';'.join(rec + ['плохой ключ'])
                else:
                    memo = MemoTime.replace('memo', rec[1])
                    notice = rec[2] if rec[2].isdigit(
                    ) and rec[2] != '0' else '1'
                    key = ':'.join([rec[0], memo, notice])

                    path_no = int(rec[3]) if rec[3] else 1
                    in_date = utils.date_format(rec[4])
                    in_time = utils.time_format(rec[5])
                    end_date = utils.date_format(rec[6])
                    end_time = utils.time_format(rec[7])

                    ret = (
                        key,
                        rec[0],
                        memo,
                        notice,
                        path_no,
                        in_date,
                        in_time,
                        end_date,
                        end_time,
                    )

        return ret, err
Exemplo n.º 2
0
    def csv_ext(rec, only_old_data):
        ret = None
        err = None
        if len(rec) < 4:
            err = ';'.join(rec + [f'мало данных: {len(rec)}'])
        elif rec[0] != '':
            cargo = int(rec[1]) if rec[1] else 0
            getcontext().prec = 4
            cargo_net = str(Decimal(rec[2])) if rec[2] else '0.0'
            doc_date = utils.date_format(rec[3])
            ret = (
                rec[0],
                cargo,
                cargo_net,
                doc_date,
            )

        return ret, err
Exemplo n.º 3
0
    def csv_ext(rec, only_old_data):
        ret = None
        err = None
        if len(rec) < 11:
            return ret, ';'.join(rec) + f': мало данных ({len(rec)})'

        if rec[0] != '':
            key = rec[0]
            if only_old_data is False and key in BaseTable.separator_set:
                return ret, err
            if key in RwbReceipt.large_trash:
                return ret, f'{key} исключается(мусор)'

            key = key.replace('.', '*')
            while len(rec) < 16:
                rec.append('')
            doc_date = utils.date_format(rec[2])
            sender = int(rec[3]) if rec[3] else 0
            recipient = int(rec[4]) if rec[4] else 0
            cargo = int(rec[6]) if rec[6] else 0

            qty = int(rec[7]) if rec[7] else 0
            getcontext().prec = 4
            cargo_net = str(Decimal(rec[8])) if rec[8] else '0.0'
            contract = int(rec[11]) if rec[11] else 0
            customer = int(rec[12]) if rec[12] else 0
            recipient2 = int(rec[14]) if rec[14] else 0
            station = int(rec[15]) if rec[15] else 0

            ret = (
                key,
                doc_date,
                sender,
                recipient,
                cargo,
                qty,
                cargo_net,
                contract,
                customer,
                recipient2,
                station,
            )

        return ret, err
Exemplo n.º 4
0
    def csv_ext(rec, only_old_data):
        ret = None
        err = None

        if len(rec) < 22:
            err = ';'.join(rec) + f': мало данных ({len(rec)})'
        else:
            if ''.join(rec[2:35]) == '':
                return ret, err
            if rec[0] in BaseTable.separator_set:
                return ret, err

            key = ':'.join([rec[0], rec[1]])
            if rec[0] == '' or rec[1] == '':
                err = ';'.join(rec + [f'плохой ключ: {key}'])
            if rec[0] in RwbReceiptCarTime.trash or rec[
                    1] in RwbReceiptCarTime.trash:
                return ret, f'{key} содержит мусор'
            if not rec[1].isdigit():
                return ret, f'{key} - ошибка в номере вагона'
            if key in RwbReceiptCarTime.large_trash:
                return ret, f'{key} ошибки в данных'

            while len(rec) < 35:
                rec.append('')

            rwbill = rec[0].replace('.', '*')
            key = ':'.join([rwbill, rec[1]])

            doc_date = utils.date_format(rec[4])
            doc_time = utils.time_format(rec[5])
            get_date = utils.date_format(rec[6])
            get_time = utils.time_format(rec[7])

            if rwbill == '916436' and rec[32] == '':
                rec[32] = '59014.4'
                doc_date = '2002-07-29'
                doc_time = '21:00'
                get_date = '2002-07-29'
                get_time = '21:00'
            if rwbill == '916448' and rec[32] == '':
                rec[32] = '59038.13'
                doc_date = '2002-08-22'
                doc_time = '4:00'
                get_date = '2002-08-23'
                get_time = '14:35'
            if rwbill == 'Е916413' and rec[32] == '':
                rec[32] = '58981.1'
                doc_date = '2002-06-25'
                doc_time = '13:00'
                get_date = '2002-06-25'
                get_time = '13:00'
            memo = RwbReceiptCarTime.replace('memo', rec[33])
            notice = rec[34] if rec[34].isdigit() and rec[34] != '0' else '1'

            if doc_date == utils.t2000() and get_date != utils.t2000():
                doc_date = get_date
                doc_time = get_time
            if get_date == utils.t2000() and doc_date != utils.t2000():
                get_date = doc_date
                get_time = doc_time

            put_date = utils.date_format(rec[12])
            put_time = utils.time_format(rec[13])

            doc_out_date = utils.date_format(rec[24])
            doc_out_time = utils.time_format(rec[25])
            out_date = utils.date_format(rec[26])
            out_time = utils.time_format(rec[27])
            if out_date == utils.t2000() and doc_out_date != utils.t2000():
                out_date = doc_out_date
                out_time = doc_out_time

            ret = (
                key,
                rwbill,
                rec[1],
                doc_date,
                doc_time,
                get_date,
                get_time,
                rec[32],
                memo,
                notice,
                put_date,
                put_time,
                doc_out_date,
                doc_out_time,
                out_date,
                out_time,
            )

        return ret, err
Exemplo n.º 5
0
    def csv_ext(rec, only_old_data):
        ret = None
        err = None
        if len(rec) < 10:
            err = ';'.join(rec + [f'мало данных: {len(rec)}'])
        else:
            key = ':'.join([rec[0], rec[2]])
            if key == ':':
                return ret, err
            if rec[0] == '' or rec[2] == '':
                err = f'плохой ключ: {key}'
            if only_old_data is False and rec[0] in BaseTable.separator_set:
                return ret, err
            if key in RwbReceiptCar.trash() and rec[1] == 'б/н':
                return ret, f'накладная+вагон {key} имеют дубль'
            if not rec[2].isdigit():
                return ret, f'вагон {key} - дефектный номер вагона'
            if rec[0] in RwbReceiptCar.large_trash:
                return ret, f'{key} исключается(мусор)'
            while len(rec) < 36:
                rec.append('')
            if rec[21].isdigit() and int(rec[21]) == 2:
                return ret, f'{key} вагон не принят'

            # if rec[0]=='ЭГ337863':
            #     err = ';'.join(rec)
            #     return ret, f'{err} XXX'

            rwbill = rec[0].replace('.', '*')
            key = ':'.join([rwbill, rec[2]])
            get_date = utils.date_format(rec[5])
            get_time = utils.time_format(rec[6])

            store_section = int(rec[8]) if rec[8] else 0
            section_no = rec[22]
            getcontext().prec = 4
            cargo_net = str(Decimal(rec[9])) if rec[9] else '0.0'
            cargo_net_fact = str(Decimal(rec[10])) if rec[10] else '0.0'
            npp = int(rec[19]) if rec[19] and rec[19].isdigit() else 0

            contract = int(rec[14]) if rec[14] else 0
            gtd = rec[15]
            sert_to = rec[17]
            condition = int(
                rec[20]
            ) if rec[20] else 0  # dicts_defects (5 == 'ПЕРЕАДРЕСОВАН', ....)

            custom_no = rec[31]
            custom_net = str(Decimal(rec[32])) if rec[32] else '0.0'
            custom_gtd = rec[33]
            contract_trade = int(rec[34]) if rec[34] else 0
            owner = int(rec[35]) if rec[35] else 0

            ret = (
                key,
                rwbill,
                rec[1],
                rec[2],
                get_date,
                get_time,
                store_section,
                section_no,
                cargo_net,
                cargo_net_fact,
                npp,
                contract,
                gtd,
                sert_to,
                condition,
                custom_no,
                custom_net,
                custom_gtd,
                contract_trade,
                owner,
            )

        return ret, err