Exemplo n.º 1
0
def print_daily_fuel_report(move_seq, printer_no):
    data_1, data_2 = get_daily_info_list(move_seq)
    report_1 = xls.EditExcelTemplate(FUEL_CONTROL_REPORT_1)
    report_2 = xls.EditExcelTemplate(FUEL_CONTROL_REPORT_2)

    # parse data
    for i in data_1:
        report_1.write_workbook(4, 1, i[0])
        report_1.write_workbook(7, 2, i[1])
        report_1.write_workbook(8, 2, i[2])
        report_1.write_workbook(9, 2, i[3])
        report_1.write_workbook(16, 1, i[4])
        report_1.write_workbook(16, 3, i[5])
        report_1.write_workbook(20, 3, i[6])
        report_1.write_workbook(21, 3, i[7])

    for i in data_2:
        report_2.write_workbook(5, 4, i[0])
        report_2.write_workbook(9, 4, i[1])
        report_2.write_workbook(10, 4, i[2])
        report_2.write_workbook(11, 4, i[3])
        report_2.write_workbook(21, 4, i[4])
        report_2.write_workbook(7, 7, i[5])

    report_1.save_excel()
    report_1.print_excel(printer_no=printer_no)
    report_1.delete_file(report_1.report_path)
    report_1.set_answer('printer_name', config.PRINTER_NAMES[printer_no])

    report_2.save_excel()
    report_2.print_excel(printer_no=printer_no)
    report_2.delete_file(report_2.report_path)
    report_2.set_answer('printer_name', config.PRINTER_NAMES[printer_no])

    return [report_1.get_answer(), report_2.get_answer()]
Exemplo n.º 2
0
def write_battery_list(from_date, to_date, printer_no):
    row = 7

    data = get_battery_list(from_date, to_date)
    report = xls.EditExcelTemplate(REPORT_NAME)

    # copy style for all rows in report
    style = report.ws['A7']._style

    # parse data
    for i in data:
        # write data from 1 till 11 columns
        for j in range(11):
            report.write_workbook_style(row, j + 1, i[j], style)
        row += 1
        report.add_row(row)

    # write header info
    import datetime
    current_date = datetime.date.today()
    report.write_workbook(3, 3, current_date)

    report.save_excel()
    report.print_excel_file(printer_name=printer_no)
    report.delete_file(report.report_path)

    report.set_answer('printer_name', printer_no)

    return report.get_answer()
Exemplo n.º 3
0
def print_monthly_fuel_report(month, printer_no):
    data = get_monthly_info_list(month)
    report = xls.EditExcelTemplate(FUEL_CONTROL_REPORT_3)

    # parse data
    for i in data:
        report.write_workbook(10, 5, i[0])
        report.write_workbook(10, 6, i[1])
        report.write_workbook(10, 7, i[2])
        report.write_workbook(12, 1, i[3])

        report.write_workbook(20, 3, i[4])
        report.write_workbook(20, 5, i[5])
        report.write_workbook(20, 6, i[6])
        report.write_workbook(20, 7, i[5]+i[6]-i[7])
        report.write_workbook(20, 8, i[7])
        report.write_workbook(21, 3, i[8])
        report.write_workbook(21, 5, i[9])
        report.write_workbook(21, 6, i[10])
        report.write_workbook(21, 7, i[9]+i[10]-i[11])
        report.write_workbook(21, 8, i[11])
        report.write_workbook(22, 3, i[12])
        report.write_workbook(22, 5, i[13])
        report.write_workbook(22, 6, i[14])
        report.write_workbook(22, 7, i[13]+i[14]-i[15])
        report.write_workbook(22, 8, i[15])
        report.write_workbook(23, 3, i[16])
        report.write_workbook(23, 5, i[17])
        report.write_workbook(23, 6, i[18])
        report.write_workbook(23, 7, i[17]+i[18]-i[19])
        report.write_workbook(23, 8, i[19])
        report.write_workbook(24, 3, i[20])
        report.write_workbook(24, 5, i[21])
        report.write_workbook(24, 6, i[22])
        report.write_workbook(24, 7, i[21]+i[22]-i[23])
        report.write_workbook(24, 8, i[23])
        report.write_workbook(25, 3, i[24])
        report.write_workbook(25, 5, i[25])
        report.write_workbook(25, 6, i[26])
        report.write_workbook(25, 7, i[25]+i[26]-i[27])
        report.write_workbook(25, 8, i[27])

        report.write_workbook(27, 1, i[28])
        report.write_workbook(27, 7, i[29])
        report.write_workbook(32, 1, i[30])
        report.write_workbook(32, 7, i[31])
        report.write_workbook(35, 1, i[32])
        report.write_workbook(35, 7, i[33])
        report.write_workbook(38, 1, i[34])
        report.write_workbook(38, 7, i[35])

    report.save_excel()
    report.print_excel(printer_no=printer_no)
    report.delete_file(report.report_path)
    report.set_answer('printer_name', config.PRINTER_NAMES[printer_no])

    return report.get_answer()
Exemplo n.º 4
0
def write_empty_tn_print(print_date, consignor, consignee, cargo_name_1,
                         cargo_name_2, cargo_reception, cargo_delivery,
                         driver_name, power_of_attorney, carrier_name,
                         truck_brand, truck_reg_no, printer_no):
    report = xls.EditExcelTemplate(REPORT_NAME)
    answer = list()
    answer.append(cargo_name_2)
    answer.append(cargo_delivery)
    answer.append(truck_reg_no)
    answer.append(truck_brand)
    answer.append(driver_name)
    answer.append(carrier_name)
    answer.append('')

    p_date = '{year}-{month}-{day}'.format(year=print_date[:4],
                                           month=print_date[4:6],
                                           day=print_date[6:])

    row_shift = 119
    for i in range(4):
        report.write_workbook(4 + row_shift * i, 23, p_date)
        report.write_workbook(7 + row_shift * i, 4, consignor)
        report.write_workbook(7 + row_shift * i, 19, consignee)
        report.write_workbook(12 + row_shift * i, 5, cargo_name_1)
        report.write_workbook(12 + row_shift * i, 20, cargo_name_2)
        report.write_workbook(26 + row_shift * i, 20, truck_brand)
        report.write_workbook(35 + row_shift * i, 3, cargo_reception)
        report.write_workbook(35 + row_shift * i, 20, cargo_delivery)
        # report.write_workbook(37 + row_shift * i, 3, in_date)
        report.write_workbook(37 + row_shift * i, 20, p_date)
        # report.write_workbook(39 + row_shift * i, 3, in_date)
        #report.write_workbook(39 + row_shift * i, 11, out_date)
        report.write_workbook(39 + row_shift * i, 20, p_date)
        report.write_workbook(39 + row_shift * i, 32, p_date)
        # report.write_workbook(46 + row_shift * i, 6, power_of_attorney)
        report.write_workbook(49 + row_shift * i, 3, driver_name)
        report.write_workbook(49 + row_shift * i, 20, driver_name)
        report.write_workbook(65 + row_shift * i, 3, p_date)
        report.write_workbook(65 + row_shift * i, 11, carrier_name)
        report.write_workbook(72 + row_shift * i, 5, carrier_name)
        report.write_workbook(74 + row_shift * i, 5, driver_name)
        report.write_workbook(78 + row_shift * i, 12, truck_brand)
        report.write_workbook(78 + row_shift * i, 26, truck_reg_no)
        # report.write_workbook(100 + row_shift * i, 5, carrier_contract)
        report.write_workbook(111 + row_shift * i, 10, p_date)
        report.write_workbook(111 + row_shift * i, 22, carrier_name)
        report.write_workbook(111 + row_shift * i, 35, p_date)
        # report.write_workbook(112 + row_shift * i, 5, operator_name)
        report.write_workbook(112 + row_shift * i, 22, driver_name)
    report.save_excel()
    report.print_excel_file(printer_name=printer_no)
    report.delete_file(report.report_path)

    return answer
Exemplo n.º 5
0
def write_waybill(from_date, to_date, truck_no, printer_no):
    header_info, driver_info, fuel_info = get_waybill(from_date, to_date,
                                                      truck_no)

    report = xls.EditExcelTemplate(REPORT_NAME)

    # write header
    for i in header_info:
        report.write_workbook(row_dest=5, column_dest=6, value=i[0])
        report.write_workbook(row_dest=7, column_dest=2, value=i[1])
        report.write_workbook(row_dest=17, column_dest=4, value=i[2])
        report.write_workbook(row_dest=19, column_dest=4, value=i[3])

    # write driver information
    row = 31
    row_to_jump = [
        64,
        103,
    ]

    for i in driver_info:
        if row in row_to_jump:
            row += 6
        report.write_workbook(row_dest=row, column_dest=3, value=i[2])
        report.write_workbook(row_dest=row, column_dest=5, value=i[3])

        row += 1

    # write fuel information
    row = 31
    for i in fuel_info:
        if row in row_to_jump:
            row += 6

        report.write_workbook(row_dest=row, column_dest=2, value=i[0])
        report.write_workbook(row_dest=row, column_dest=6, value=i[1])
        report.write_workbook(row_dest=row, column_dest=7, value=i[2])
        report.write_workbook(row_dest=row, column_dest=8, value=i[3])
        report.write_workbook(row_dest=row, column_dest=9, value=i[4])

        row += 3

    report.save_excel()
    report.print_excel_file(printer_name=printer_no)
    report.delete_file(report.report_path)
    report.set_answer('printer_name', printer_no)

    return report.get_answer()
Exemplo n.º 6
0
def print_trip_ticket(reg_emp_list, date, printer_no):
    delete_files = []
    set_duplex(printer_no, 2)
    for reg_emp in str.split(reg_emp_list, ','):
        if reg_emp == '':
            continue
        report = xls.EditExcelTemplate(TRIP_TICKET)
        data = get_trip_ticket_list(reg_emp, date)
        row = 12
        # parse data
        for emp_no, local_nm, check_date, area, start_dt, end_dt in data:
            if row == 12:
                report.write_workbook(7, 5, local_nm)
                barcode_image_path = create_barcode(case_no=emp_no, code='code39', label_type='user_id')
                img = xls_image(barcode_image_path)
                report.insert_image(img, 'S2')
                img1 = xls_image(barcode_image_path)
                report.insert_image(img1, 'S68')
            report.write_workbook(row, 1, check_date)
            report.write_workbook(row, 5, area)
            report.write_workbook(row, 16, start_dt)
            report.write_workbook(row, 20, end_dt)
            row += 1
            if row == 26:
                row = 40
        report.save_excel()
        report.print_excel(printer_no=printer_no)
        delete_files.append(report.report_path)
        delete_files.append(barcode_image_path)
    # delete all files
    for x in delete_files:
        report.delete_file(x)

    report.set_answer('printer_name', config.PRINTER_NAMES[printer_no])

    return report.get_answer()
Exemplo n.º 7
0
def print_lp_tn(pool_seq, print_date, vendor, transporter, truck, driver, qty,
                bqty, printer_no):
    set_duplex(printer_no, 2)
    report = xls.EditExcelTemplate(LP_TN)
    copies = 0
    data = get_lp_tn_list(pool_seq, print_date, vendor, transporter, truck,
                          driver, qty, bqty)
    for reg_dt, vend_name, vend_addr, tel_no, vend_tel_no, qty, bqty, vend_addr2, drv_nm, drv_contract, trpr_nm, address, contract, brand, ton, truck_cd, vend_contract, pay_det, paper_qty in data:
        copies = paper_qty
        report.write_workbook(3, 61, reg_dt)
        report.write_workbook(
            7, 2,
            'ООО “ГЛОВИС РУС“,197374,г. Санкт-Петербург, ул. Савушкина, д.126, лит.Б, пом.62-Н, ИНН 7805464287, КПП 781401001 по поручению '
            + vend_name + ' ' + vend_addr)
        report.write_workbook(7, 53, vend_name + ', ' + vend_addr)
        report.write_workbook(9, 2, tel_no)
        report.write_workbook(9, 53, vend_tel_no)
        text_for_boxes = ''
        if (qty != '0') and (bqty != '0'):
            text_for_boxes = qty + ' транспортировочных тележек и ящики пластиковые ' + bqty + ' штук'
        elif (qty != '0'):
            text_for_boxes = qty + ' транспортировочных тележек'
        else:
            text_for_boxes = 'Ящики пластиковые ' + bqty + ' штук'
        report.write_workbook(14, 2, text_for_boxes)
        report.write_workbook(33, 53, vend_name + ' ' + vend_addr2)
        report.write_workbook(35, 2, reg_dt)
        report.write_workbook(35, 53, reg_dt)
        report.write_workbook(37, 2, reg_dt)
        report.write_workbook(37, 53, reg_dt)
        report.write_workbook(39, 2, reg_dt)
        report.write_workbook(39, 53, reg_dt)
        report.write_workbook(41, 2, text_for_boxes)
        report.write_workbook(41, 53, text_for_boxes)
        report.write_workbook(43, 28, drv_nm)
        report.write_workbook(43, 87, drv_nm)
        report.write_workbook(59, 2, reg_dt)
        report.write_workbook(59, 16, drv_nm)
        report.write_workbook(59, 72, drv_contract)
        text_for_transporter = ''
        if contract != ' ':
            text_for_transporter = trpr_nm + ' ' + address + ' по поручению ООО “ГЛОВИС РУС“,197374,г. Санкт-Петербург, ул. Савушкина, д.126, лит.Б, пом.62-Н, ИНН 7805464287, КПП 781401001'
        else:
            text_for_transporter = trpr_nm + ' ' + address
        report.write_workbook(62, 2, text_for_transporter)
        report.write_workbook(62, 53, drv_nm)
        report.write_workbook(71, 4, brand)
        report.write_workbook(71, 41, ton)
        report.write_workbook(71, 79, truck_cd)
        if contract != ' ':
            report.write_workbook(
                91, 2, '"На основании договора ' + contract + ' между ' +
                trpr_nm + ' и ООО “ГЛОВИС РУС" и на основании договора ' +
                vend_contract + ' между ' + vend_name + ' и ООО “ГЛОВИС РУС”')
        report.write_workbook(99, 2,
                              vend_name + ' ' + vend_addr + ' ' + pay_det)
        report.write_workbook(102, 53, trpr_nm)
        report.write_workbook(103, 62, drv_nm)
        report.write_workbook(104, 19, reg_dt)
        report.write_workbook(104, 53, drv_contract)
        report.write_workbook(104, 99, reg_dt)
    report.save_excel()
    # print report
    for x in range(copies):
        report.print_excel(printer_no)
    report.delete_file(report.report_path)
    report.set_answer('printer_name', config.PRINTER_NAMES[printer_no])
    return report.get_answer()
Exemplo n.º 8
0
def write_tn_print(print_date, consignee_id, cargo_delivery_id,
                   cargo_receipt_id, idx, in_cont_no, printer_no):
    data = get_tn_print(print_date, consignee_id, cargo_delivery_id,
                        cargo_receipt_id, idx, in_cont_no)
    report = xls.EditExcelTemplate(REPORT_NAME)
    answer = []

    # parse data
    for report_date, cargo_receipt, consignor, consignee, cargo_delivery, \
        out_ct, in_date, out_date, out_date_sign, \
        carrier_name, carrier, carrier_contract, cargo_receipt_name, \
        operator_name, in_drv_nm, out_drv_nm, out_cmnt, \
        truck_brand, truck_reg_no in data:

        row_shift = 119
        for i in range(4):
            report.write_workbook(4 + row_shift * i, 23, report_date)
            report.write_workbook(7 + row_shift * i, 4, consignor)
            report.write_workbook(7 + row_shift * i, 19, consignee)
            report.write_workbook(12 + row_shift * i, 20, out_ct)
            report.write_workbook(26 + row_shift * i, 20, truck_brand)
            report.write_workbook(35 + row_shift * i, 3, cargo_receipt)
            report.write_workbook(35 + row_shift * i, 20, cargo_delivery)
            report.write_workbook(37 + row_shift * i, 3, in_date)
            report.write_workbook(37 + row_shift * i, 20, report_date)
            report.write_workbook(39 + row_shift * i, 3, in_date)
            report.write_workbook(39 + row_shift * i, 11, out_date)
            report.write_workbook(39 + row_shift * i, 20, report_date)
            report.write_workbook(39 + row_shift * i, 32, report_date)
            report.write_workbook(46 + row_shift * i, 6, operator_name)
            report.write_workbook(49 + row_shift * i, 3, out_drv_nm)
            report.write_workbook(49 + row_shift * i, 20, out_drv_nm)
            report.write_workbook(65 + row_shift * i, 3, report_date)
            report.write_workbook(65 + row_shift * i, 11, carrier_name)
            report.write_workbook(72 + row_shift * i, 5, carrier)
            report.write_workbook(74 + row_shift * i, 5, out_drv_nm)
            report.write_workbook(78 + row_shift * i, 12, truck_brand)
            report.write_workbook(78 + row_shift * i, 26, truck_reg_no)
            report.write_workbook(100 + row_shift * i, 5, carrier_contract)
            report.write_workbook(111 + row_shift * i, 10, report_date)
            report.write_workbook(111 + row_shift * i, 22, carrier_name)
            report.write_workbook(111 + row_shift * i, 35, report_date)
            report.write_workbook(112 + row_shift * i, 5, operator_name)
            report.write_workbook(112 + row_shift * i, 22, out_drv_nm)

            if out_cmnt:
                report.write_workbook(117 + row_shift * i, 5, out_cmnt)
                report.write_workbook(117 + row_shift * i, 31, out_date_sign)

        answer.append(out_ct)
        answer.append(cargo_delivery)
        answer.append(truck_reg_no)
        answer.append(truck_brand)
        answer.append(out_drv_nm)
        answer.append(carrier_name)
        answer.append(out_cmnt)

    report.save_excel()
    report.print_excel_file(printer_name=printer_no)
    report.delete_file(report.report_path)

    return answer