fusion devis et facture dans un chantier
This commit is contained in:
@@ -25,19 +25,23 @@ def execute_query(request, query, params):
|
||||
mark_changed(request.dbsession)
|
||||
transaction.commit()
|
||||
|
||||
def get_devis_byName(request, societe, name):
|
||||
numero = to_int(name)
|
||||
|
||||
def get_dossiers_byName(request, societe, name):
|
||||
# lires tous les dossiers d'un chantier
|
||||
|
||||
if numero > 0:
|
||||
query = """SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol, nochantier, web
|
||||
FROM devis WHERE societe=:societe AND no_id >=:name AND web = 'W' LIMIT 300;;""" % (societe, name)
|
||||
elif len(name) == 0:
|
||||
query = """SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol, nochantier, web
|
||||
FROM devis WHERE societe=:societe AND web = 'W' ORDER BY no_id DESC LIMIT 300;"""
|
||||
else:
|
||||
query = """(SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol , nochantier, web
|
||||
FROM devis WHERE societe=:societe AND c_nom LIKE ':name%' AND web = 'W' LIMIT 500)"""
|
||||
results = request.dbsession.execute(query, {'societe': societe, 'name': name}).fetchall()
|
||||
query = """select * from (
|
||||
SELECT date,'DD' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, 0 AS montant, status, nosin, societe , no_id as nochantier
|
||||
FROM dem_devis WHERE societe=:societe AND c_nom LIKE :name
|
||||
UNION
|
||||
SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, societe , nochantier
|
||||
FROM devis WHERE societe=:societe AND c_nom LIKE :name
|
||||
UNION
|
||||
SELECT date,'FA' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, societe , nochantier
|
||||
FROM facture WHERE societe=:societe AND c_nom LIKE :name
|
||||
) a
|
||||
order by date, TYPE
|
||||
"""
|
||||
results = request.dbsession.execute(query, {'societe': societe, 'name': name+'%'}).fetchall()
|
||||
return results
|
||||
|
||||
def get_devfac_by_no(request,nodossier):
|
||||
@@ -235,3 +239,14 @@ def update_devis_cloture(request, nodevis, status, logged_in):
|
||||
query = "UPDATE devis SET STATUS = :status, USERMAJ = :logged_in WHERE societe=:societe AND no_id=:nochantier;"
|
||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'status': status, 'logged_in': logged_in})
|
||||
|
||||
def update_devis_nochantier(request, societe, no_devis, nochantier):
|
||||
# extraire type de doc et no de doc à mettre à jour
|
||||
type = no_devis[0:2]
|
||||
no_id = no_devis[3:]
|
||||
if type == 'DE':
|
||||
# maj le numero du dossier du devis
|
||||
query = "UPDATE devis SET nochantier = :nochantier WHERE societe=:societe AND no_id=:no_id;"
|
||||
else:
|
||||
# maj le numero du dossier de la facture
|
||||
query = "UPDATE facture SET nochantier = :nochantier WHERE societe=:societe AND no_id=:no_id;"
|
||||
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'no_id': no_id})
|
||||
|
||||
Reference in New Issue
Block a user