def print(self):
     printer.write_string_to_printer(str(self))
     sleep(5)
     #printer.write_string_to_printer(str(self.print_no_fiscal()))
     self.print_date = datetime.now()
     db_session.add(self)
     db_session.commit()
Beispiel #2
0
def print_today():
    today = datetime.now().strftime('0%y%m%d')
    tomorrow = (datetime.now() + timedelta(days=1)).strftime('0%y%m%d')
    yesterday = (datetime.now() - timedelta(days=1)).strftime('0%y%m%d')
    printer.write_string_to_printer('Rs%s%s' % (today, tomorrow))
    sleep(1)
    return redirect(url_for('index'))
Beispiel #3
0
def create_factura(cliente,productos):
    session = session_maker()
    try:
        factura,productos,cliente = db_worker.create_factura(session,cliente,productos)
    except Exception as e:
            raise(e)
            session.rollback()
    printer.write_string_to_printer(str(factura))
    return factura,productos,cliente
Beispiel #4
0
def create_nota():
    session = session_maker()
#   return str(request.form['factura[cliente][empresa]'])
    if request.json and 'nota' in request.json:
        factura_id = request.json['nota']['factura_id']
        legacy_id = request.json['nota']['legacy_id']
    else:
        abort(400)
    try:
        nota = db_worker.create_nota(session,factura_id,legacy_id)
    except Exception as e:
            raise(e)
            session.rollback()
    printer.write_string_to_printer(str(nota))
    return str(nota)
Beispiel #5
0
def make_factura():
    session = session_maker()
    print(request.json)
    if request.json and 'factura' in request.json:
        productos = request.json['factura']['productos']
        cliente =  request.json['factura']['cliente']
    elif request.form:
        cliente = parse_cliente_from_post(request)
        productos = parse_productos_from_post(request)
    else:
        abort(400)
    try:
        factura,productos,cliente = db_worker.create_factura(session,cliente,productos)
    except Exception as e:
            raise(e)
            session.rollback()
    printer.write_string_to_printer(str(factura))
    return str(factura)
Beispiel #6
0
def make_factura():
    print(request.json)
    session = db_worker.session_maker()
    if request.json and 'factura' in request.json:
        productos = request.json['factura']['productos']
        cliente = request.json['factura']['cliente']
    elif request.form:
        cliente = parse_cliente_from_post(request)
        productos = parse_productos_from_post(request)
    else:
        abort(400)
    try:
        factura, productos, cliente = db_worker.create_factura(
            session, cliente, productos)
    except Exception as e:
        raise(e)
        session.rollback()
    printer.write_string_to_printer(str(factura))
    return str(factura)
Beispiel #7
0
def print_report():
    if request.form['submit'] == 'ReporteX':
        printer.write_string_to_printer('I0X')
    elif request.form['submit'] == 'ReporteZ':
        printer.write_string_to_printer('I0Z')
    elif request.form['submit'] == 'ReportDate':
        start_date = request.form['start_date']
        end_date = request.form['end_date']
        sd = start_date[1:4] + start_date[5:7] + start_date[8:10]
        ed = end_date[1:4] + end_date[5:7] + end_date[8:10]
        cmd = 'Rf'+ sd + ed
        print(cmd)
        printer.write_string_to_printer(cmd)
    else:
        print('WRONG VALUE')
    return redirect(url_for('.index'))
Beispiel #8
0
 def print(self):
     printer.write_string_to_printer(str(self))
     self.print_date = datetime.now()
     db_session.add(self)
     db_session.commit()
Beispiel #9
0
def reporteZ():
    printer.write_string_to_printer('I0Z')
    return redirect(url_for('index'))
Beispiel #10
0
def print_report(report):
    if report not in ['x', 'y']:
        abort(400)

    printer.write_string_to_printer('I0X' if report == 'x' else 'I0Z')
    return dumps(f'{report.upper()} Report printed successfully')
Beispiel #11
0
def print_credit_note():
    json_req = loads(request.json)
    string = parse_credit_note(json_req['credit_note'])
    printer.write_string_to_printer(string)
    return dumps({"printed_credit_note": string})
Beispiel #12
0
def print_invoice():
    json_req = loads(request.json)
    string = parse_invoice(json_req['invoice'])
    printer.write_string_to_printer(string)
    return dumps({"printed_invoice": string})