示例#1
0
    def post_crear_entrega_de_cuenta():
        cash = request.forms.get('cash', 0)
        gastos = request.forms.get('gastos', 0)
        deposito = request.forms.get('deposito', 0)
        turned_cash = request.forms.get('valor', 0)
        diff = request.forms.get('diff', 0)
        date = request.forms.get('date')

        cash = get_cents_with_default(cash)
        gastos = get_cents_with_default(gastos)
        deposito = get_cents_with_default(deposito)
        turned_cash = get_cents_with_default(turned_cash)
        diff = get_cents_with_default(diff)
        date = parse_iso(date).date()

        userid = get_user(request)['username']
        if request.forms.get('submit') == 'Crear':
            stat = AccountStat(
                date=date,
                total_spend=gastos,
                turned_cash=turned_cash,
                deposit=deposito,
                created_by=userid
            )
            dbapi.create(stat)
            dbapi.db_session.flush()
        else:
            dbapi.update(AccountStat(date=date),
                         {'revised_by': userid, 'turned_cash': turned_cash,
                          'deposit': deposito, 'diff': diff})

        redirect('/app/crear_entrega_de_cuenta?fecha={}'.format(date.isoformat()))
示例#2
0
    def eliminar_factura():
        almacen_id = int(request.forms.get('almacen_id'))
        codigo = request.forms.get('codigo').strip()
        ref = request.forms.get('motivo')
        if not ref:
            abort(400, 'escriba el motivo')
        user = get_user(request)
        db_instance = get_inv_db_instance(dbapi.db_session, almacen_id, codigo)
        if db_instance is None:
            alm = dbapi.get(almacen_id, Store)
            db_instance = dbapi.db_session.query(NNota).filter_by(
                almacen_ruc=alm.ruc, codigo=codigo).first()
        if db_instance is None:
            return eliminar_factura_form('Factura no existe')

        comment = Comment(
            user_id=user['username'],
            timestamp=datetime.datetime.now(),
            comment=ref,
            objtype='notas',
            objid=str(db_instance.id),
        )
        dbapi.create(comment)
        doc = invapi.get_doc_from_file(db_instance.items_location)
        doc.meta.status = db_instance.status

        try:
            invapi.delete(doc)
        except ValueError:
            abort(400)

        redirect('/app/nota/{}'.format(db_instance.id))
示例#3
0
    def eliminar_factura():
        almacen_id = int(request.forms.get('almacen_id'))
        codigo = request.forms.get('codigo').strip()
        ref = request.forms.get('motivo')
        if not ref:
            abort(400, 'escriba el motivo')
        user = get_user(request)
        db_instance = get_inv_db_instance(dbapi.db_session, almacen_id, codigo)
        if db_instance is None:
            alm = dbapi.get(almacen_id, Store)
            db_instance = dbapi.db_session.query(NNota).filter_by(
                almacen_ruc=alm.ruc, codigo=codigo).first()
        if db_instance is None:
            return eliminar_factura_form('Factura no existe')

        comment = Comment(
            user_id=user['username'],
            timestamp=datetime.datetime.now(),
            comment=ref,
            objtype='notas',
            objid=str(db_instance.id),
        )
        dbapi.create(comment)
        doc = invapi.get_doc_from_file(db_instance.items_location)
        doc.meta.status = db_instance.status

        try:
            invapi.delete(doc)
        except ValueError:
            abort(400)

        redirect('/app/nota/{}'.format(db_instance.id))
示例#4
0
 def post_revisar_inv():
     bodega_id = request.forms.get('bodega_id', None)
     if bodega_id is None:
         abort(400, 'bodega_id no existe')
     prod_ids = request.forms.getlist('prod_id')
     rev = revisionapi.save(bodega_id,
                            get_user(request)['username'], prod_ids)
     redirect('/app/revision/{}'.format(rev.uid))
示例#5
0
 def post_comment():
     comment = json.loads(request.body.read())
     c = Comment()
     c.objid = comment['objid']
     c.objtype = comment['objtype']
     c.user_id = get_user(request)['username']
     c.timestamp = datetime.datetime.now()
     c.comment = comment['comment']
     dbapi.create(c)
     dbapi.db_session.commit()
     return {'comment': c.uid}
示例#6
0
def post_comment():
    comment = json_loads(request.body.read())
    c = NComment()
    c.objid = comment['objid']
    c.objtype = comment['objtype']
    c.user_id = get_user(request)['username']
    c.timestamp = datetime.datetime.now()
    c.comment = comment['comment']
    sessionmanager.session.add(c)
    sessionmanager.session.commit()
    return {'comment': c.uid}
示例#7
0
    def post_crear_entrega_de_cuenta():
        cash = request.forms.get('cash', 0)
        gastos = request.forms.get('gastos', 0)
        deposito = request.forms.get('deposito', 0)
        turned_cash = request.forms.get('valor', 0)
        diff = request.forms.get('diff', 0)
        date = request.forms.get('date')

        cash = get_cents_with_default(cash)
        gastos = get_cents_with_default(gastos)
        deposito = get_cents_with_default(deposito)
        turned_cash = get_cents_with_default(turned_cash)
        diff = get_cents_with_default(diff)
        date = parse_iso(date).date()

        userid = get_user(request)['username']
        if request.forms.get('submit') == 'Crear':
            stat = AccountStat(date=date,
                               total_spend=gastos,
                               turned_cash=turned_cash,
                               deposit=deposito,
                               created_by=userid)
            dbapi.create(stat)
            dbapi.db_session.flush()
        else:
            dbapi.update(
                AccountStat(date=date), {
                    'revised_by': userid,
                    'turned_cash': turned_cash,
                    'deposit': deposito,
                    'diff': diff
                })
            now = datetime.datetime.now()
            todo1 = Todo(objtype=ObjType.ACCOUNT,
                         objid=date,
                         status='PENDING',
                         msg='Papeleta de deposito de {}: ${}'.format(
                             date,
                             Decimal(deposito) / 100),
                         creation_date=now,
                         due_date=now)
            todo2 = Todo(objtype=ObjType.ACCOUNT,
                         objid=date,
                         status='PENDING',
                         msg='Papeleta de deposito de {}: ${}'.format(
                             date,
                             Decimal(turned_cash) / 100),
                         creation_date=now,
                         due_date=now)
            dbapi.create(todo1)
            dbapi.create(todo2)

        redirect('/app/crear_entrega_de_cuenta?fecha={}'.format(
            date.isoformat()))
示例#8
0
def post_comment():
    comment = json_loads(request.body.read())
    c = NComment()
    c.objid = comment['objid']
    c.objtype = comment['objtype']
    c.user_id = get_user(request)['username']
    c.timestamp = datetime.datetime.now()
    c.comment = comment['comment']
    sessionmanager.session.add(c)
    sessionmanager.session.commit()
    return {'comment': c.uid}
示例#9
0
 def revisiones_main():
     user = get_user(request)
     if 'level' not in user:
         userdb = dbapi.db_session.query(NUsuario).filter(
             NUsuario.username == user['username']).first()
         user['level'] = userdb.level
         beaker = request.environ['beaker.session']
         beaker['login_info'] = user
         beaker.save()
     level = user['level']
     print level
     if level < 2:
         return 'no autorizado'
     temp = jinja_env.get_template('inventory/revisiones.html')
     return temp.render()
示例#10
0
 def postregar_cheque():
     checkid = request.forms.checkid
     new_date = parse_iso(request.forms.new_date).date()
     session = dbapi.db_session
     check = session.query(NCheck).filter_by(uid=checkid).first()
     comment = NComment(
         timestamp=datetime.datetime.now(),
         user_id=get_user(request)['username'],
         comment='Cheque postponer desde {} hasta {}'.format(
             check.checkdate.isoformat(), new_date.isoformat()),
         objtype=ObjType.CHECK,
         objid=str(checkid),
     )
     session.add(comment)
     check.checkdate = new_date
     session.flush()
     redirect('/app/ver_cheque/{}'.format(checkid))
示例#11
0
 def postregar_cheque():
     checkid = request.forms.checkid
     new_date = parse_iso(request.forms.new_date).date()
     session = dbapi.db_session
     check = session.query(NCheck).filter_by(uid=checkid).first()
     comment = NComment(
         timestamp=datetime.datetime.now(),
         user_id=get_user(request)['username'],
         comment='Cheque postponer desde {} hasta {}'.format(
             check.checkdate.isoformat(), new_date.isoformat()),
         objtype=ObjType.CHECK,
         objid=str(checkid),
     )
     session.add(comment)
     check.checkdate = new_date
     session.flush()
     redirect('/app/ver_cheque/{}'.format(checkid))
示例#12
0
    def eliminar_factura():
        almacen_id = int(request.forms.get('almacen_id'))
        codigo = request.forms.get('codigo').strip()
        ref = request.forms.get('motivo')
        if not ref:
            abort(400, 'escriba el motivo')
        user = get_user(request)
        db_instance = get_inv_db_instance(dbapi.db_session, almacen_id, codigo)
        if db_instance is None:
            alm = dbapi.get(almacen_id, Store)
            db_instance = dbapi.db_session.query(NNota).filter_by(
                almacen_ruc=alm.ruc, codigo=codigo).first()
        if db_instance is None:
            return eliminar_factura_form('Factura no existe')

        if db_instance.status == Status.DELETED:
            # already deleted
            redirect('/app/nota/{}'.format(db_instance.id))

        old_status = db_instance.status

        comment = Comment(
            user_id=user['username'],
            timestamp=datetime.datetime.now(),
            comment=ref,
            objtype='notas',
            objid=str(db_instance.id),
        )
        dbapi.create(comment)
        doc = invapi.get_doc_from_file(db_instance.items_location)
        doc.meta.status = db_instance.status

        try:
            invapi.delete(doc)
        except ValueError:
            abort(400)

        if workqueue is not None:
            obj = doc_to_workobject(doc, objtype=WorkObject.INV, action=WorkObject.DELETE)
            workqueue(work=json_dumps(obj))
            if old_status == Status.COMITTED:
                obj = doc_to_workobject(doc, objtype=WorkObject.INV_TRANS, action=WorkObject.DELETE)
                workqueue(work=json_dumps(obj))
        redirect('/app/nota/{}'.format(db_instance.id))
示例#13
0
    def post_crear_entrega_de_cuenta():
        cash = request.forms.get('cash', 0)
        gastos = request.forms.get('gastos', 0)
        deposito = request.forms.get('deposito', 0)
        turned_cash = request.forms.get('valor', 0)
        diff = request.forms.get('diff', 0)
        date = request.forms.get('date')

        cash = get_cents_with_default(cash)
        gastos = get_cents_with_default(gastos)
        deposito = get_cents_with_default(deposito)
        turned_cash = get_cents_with_default(turned_cash)
        diff = get_cents_with_default(diff)
        date = parse_iso(date).date()

        userid = get_user(request)['username']
        if request.forms.get('submit') == 'Crear':
            stat = AccountStat(
                date=date,
                total_spend=gastos,
                turned_cash=turned_cash,
                deposit=deposito,
                created_by=userid
            )
            dbapi.create(stat)
            dbapi.db_session.flush()
        else:
            dbapi.update(AccountStat(date=date),
                         {'revised_by': userid, 'turned_cash': turned_cash,
                          'deposit': deposito, 'diff': diff})
            now = datetime.datetime.now()
            todo1 = Todo(objtype=ObjType.ACCOUNT, objid=date, status='PENDING',
                         msg='Papeleta de deposito de {}: ${}'.format(date, Decimal(deposito) / 100),
                         creation_date=now, due_date=now)
            todo2 = Todo(objtype=ObjType.ACCOUNT, objid=date, status='PENDING',
                         msg='Papeleta de deposito de {}: ${}'.format(date, Decimal(turned_cash) / 100),
                         creation_date=now, due_date=now)
            dbapi.create(todo1)
            dbapi.create(todo2)

        redirect('/app/crear_entrega_de_cuenta?fecha={}'.format(date.isoformat()))