def main(): dbapi = DBApiGeneric(sessionmanager) transactionapi = InventoryApi(FileService(TRANSACTION_PATH)) with dbapi.session: for ig in dbapi.search(ProdItemGroup): trans = transactionapi.list_transactions(ig.uid, START, END) print json_dumps([ig, list(trans)])
def make_test_dbapi(): engine = create_engine('sqlite:///:memory:', echo=True) sessionfactory = sessionmaker(bind=engine) Base.metadata.create_all(engine) manager = SessionManager(sessionfactory) dbapi = DBApiGeneric(manager) return dbapi
def setUpClass(cls): engine = create_engine('sqlite:///:memory:', echo=False) sessionfactory = sessionmaker(bind=engine) session = sessionfactory() Base.metadata.create_all(engine) cls.clientes = [ NCliente(codigo='123', nombres='nombre1 nombre2', apellidos='apellido1 apellido2', direccion='direccion', telefono='12345567', ciudad='ciudad', tipo=1, cliente_desde=datetime.date.today()) ] for c in cls.clientes: session.add(c) session.commit() cls.sessionmanager = SessionManager(sessionfactory) cls.dbapi = DBApiGeneric(cls.sessionmanager)
def setUpClass(cls): engine = create_engine('sqlite:///:memory:', echo=False) sessionfactory = sessionmaker(bind=engine) Base.metadata.create_all(engine) cls.sessionmanager = SessionManager(sessionfactory) cls.dbapi = DBApiGeneric(cls.sessionmanager) # make bodega and almacen bodegas = [ Bodega(id=1, nombre='Menorista'), Bodega(id=2, nombre='Mayorista'), ] stores = [ Store(almacen_id=1, nombre="1", bodega_id=1), Store(almacen_id=2, nombre="2", bodega_id=2) ] with cls.sessionmanager: map(cls.dbapi.create, bodegas) map(cls.dbapi.create, stores)
def setUpClass(cls): engine = create_engine('sqlite:///:memory:', echo=False) sessionfactory = sessionmaker(bind=engine) session = sessionfactory() Base.metadata.create_all(engine) cls.sessionmanager = SessionManager(sessionfactory) filemanager = FileService('/tmp') cls.transaction_api = TransactionApi('/tmp/transactions') cls.prod_api = DBApiGeneric(cls.sessionmanager) cls.trans_api = DocumentApi(cls.sessionmanager, filemanager, cls.prod_api, Transferencia) cls.inv_api = DocumentApi(cls.sessionmanager, filemanager, cls.prod_api, Invoice) cls.productos = [('0', 'prueba 0', Decimal('20.23'), Decimal('10'), 0), ('1', 'prueba 1', Decimal('20.23'), Decimal('10'), 0), ('2', 'prueba 2', Decimal('20.23'), Decimal('10'), 0), ('3', 'prueba 3', Decimal('20.23'), Decimal('10'), 0), ('4', 'prueba 4', Decimal('20.23'), Decimal('10'), 0), ('5', 'prueba 5', Decimal('20.23'), Decimal('10'), 0)] with cls.sessionmanager as s: b = NBodega(nombre='test1', nivel=0) s.add(b) store = NStore(nombre='store1', ruc='123') store.bodega = b s.add(store) store2 = NStore(nombre='store2', ruc='123') store2.bodega = b s.add(store2) s.commit() with cls.sessionmanager: for p in cls.productos: pass
import sys from henry.product.dao import * from henry.base.dbapi import DBApiGeneric from henry.coreconfig import sessionmanager from decimal import Decimal plist = {'upi': None, 'precio1': 48, 'precio2': 48, 'pid': None, 'multiplicador': Decimal('1.000'), 'almacen_id': 1, 'threshold': 0, 'nombre': u'ENCAJE 309', 'codigo': u'ENC309', 'unidad': None} actions = [] with open(sys.argv[1]) as f: for line in f.readlines(): actions.append(eval(line)) dbapi = DBApiGeneric(sessionmanager) plist = PriceList.deserialize(plist) def make_dict(pricelist): return { 'prod': { 'prod_id': pricelist.prod_id, 'name': pricelist.nombre, 'desc': pricelist.nombre, 'base_unit': 'unidad', }, 'items': [{ 'multiplier': 1, 'unit': 'unidad', 'prices':{ 1: { 'display_name': pricelist.nombre, 'price1': pricelist.precio1 / 100.0, 'price2': (pricelist.precio2 or pricelist.precio1) / 100.0, 'cant': pricelist.cant_mayorista,
from henry.product.dao import PriceList from henry.base.serialization import json_dumps from henry.base.dbapi import DBApiGeneric from henry.coreconfig import sessionmanager dbapi = DBApiGeneric(sessionmanager) with dbapi.session: for p in dbapi.search(PriceList): print json_dumps(p.serialize())
from henry.accounting.web import make_wsgi_app as accwsgi from henry.accounting.web import make_wsgi_api as accapi from henry.product.web import make_wsgi_app as prodapp from henry.product.web import make_wsgi_api as prod_api_app from henry.inventory.web import make_inv_wsgi from henry.invoice.websites import make_invoice_wsgi from henry.base.dbapi import DBApiGeneric from henry.constants import USE_ACCOUNTING_APP from henry.config import (BEAKER_SESSION_OPTS, jinja_env, transapi, revisionapi, imagefiles, paymentapi, BODEGAS_EXTERNAS) from henry.coreconfig import (dbcontext, auth_decorator, sessionmanager, actionlogged, invapi, pedidoapi) from henry.web import webmain as app from henry.api.api_endpoints import api dbapi = DBApiGeneric(sessionmanager) userapp = userwsgi(dbcontext, auth_decorator, jinja_env, dbapi, actionlogged) invoiceapp = make_invoice_wsgi(dbapi, auth_decorator, actionlogged, invapi, pedidoapi, jinja_env) invapp = make_inv_wsgi(dbapi, jinja_env, actionlogged, auth_decorator, transapi, revisionapi, BODEGAS_EXTERNAS) papp = prodapp(dbcontext, auth_decorator, jinja_env, dbapi, imagefiles) create_prod_api = prod_api_app( '/app/api', sessionmanager=sessionmanager, auth_decorator=auth_decorator, dbcontext=dbcontext, dbapi=dbapi) app.merge(api) app.merge(userapp) app.merge(invoiceapp)