def create(data): created_ids = [] for i in data: if DB().insert(i, 'ci_item') is False: return False created_ids.append( DB().selectFV("SELECT MAX(id) as id FROM ci_item;")) return created_ids
def create(data): created_ids = [] for i in data: if DB().insert(i, 'material') is False: return False created_ids.append( DB().selectFV("SELECT MAX(id) as id FROM material;")['id']) return created_ids
def get(client_id): return DB().SelectById(client_id, ['id', 'name', 'phone', 'fax', 'contact'], 'client')
def remove(ci_id): return DB().remove(ci_id, 'id')
def create(data): return DB().insert(data, 'client')
def get(material_id): return DB().SelectById(material_id, ['id', 'ncm', 'name', 'description'], 'material')
def all(): return DB().selectAll(['id', 'ncm', 'name'], 'material')
def all(): return DB().selectAll(['id', 'name', 'phone', 'fax', 'contact'], 'client')
def all(): return DB().selectAll(['id', 'name', 'city', 'type'], 'transport')
def get(company_id): return DB().SelectById(company_id, ['id', 'name', 'cnpj', 'logo', 'phone', 'address'], 'company')
def remove(company_id): return DB().remove(company_id, 'company')
def create(data): return DB().insert(data, 'adress')
def create(data): return DB().insert(data, 'company')
def all(): return DB().selectAll(['id', 'client_id', 'type', 'adress'], 'adress')
def remove(address_id): return DB().remove(address_id, 'adress')
def get(address_id): return DB().SelectById(address_id, ['id', 'client_id', 'type', 'adress'], 'adress')
def update(client_id, params): return DB().update(client_id, params, 'client')
def get(ci_item_id): return DB().SelectById(ci_item_id, [ 'id', 'commercial_invoice_id', 'measurement_unit_id', 'material_id' ], 'ci_item')
def remove(client_id): return DB().remove(client_id, 'client')
def all(): return DB().selectAll([ 'id', 'commercial_invoice_id', 'measurement_unit_id', 'material_id' ], 'ci_item')
def all(): return DB().selectAll(['id', 'name', 'cnpj', 'logo', 'phone', 'address'], 'company')
def getHome(): return DB().selectFA("SELECT commercial_invoice.id, created_at, name as client_name FROM commercial_invoice, client WHERE client_id = client.id AND commercial_invoice.removed = 0;")
def remove(ci_item_id): return DB().remove(ci_item_id, 'ci_item')
def create(data): return DB().insert(data, 'commercial_invoice')
def update(material_id, data): return DB().update(material_id, data, 'material')
def get(ci_model_id): return DB().SelectById(ci_model_id, ['id', 'transport_id', 'client_id'], 'commercial_invoice')
def remove(material_id): return DB().remove(material_id, 'material')
def remove(ci_model_id): return DB().remove(ci_model_id, 'commercial_invoice')
def all(): return DB().selectAll(['id', 'transport_id', 'cliente_id'], 'commercial_invoice')
def getTransport(ci_id): transport_id = DB().selectFV("SELECT transport_id FROM commercial_invoice WHERE id = {} AND removed = 0;".format(ci_id)) return DB().runFetchRow("SELECT name, city, type FROM transport WHERE id = {} AND removed = 0;".format(transport_id['transport_id']))