diff --git a/back/infolica/routes.py b/back/infolica/routes.py index 5806e617..e104ceb3 100644 --- a/back/infolica/routes.py +++ b/back/infolica/routes.py @@ -98,6 +98,7 @@ def includeme(config): config.add_route('numeros_relations','/infolica/api/numeros_relations') config.add_route('numeros_relations_s','/infolica/api/numeros_relations/') config.add_route('numeros_relation_by_affaire_id','/infolica/api/affaire_numeros_relations/{id}') + config.add_route('new_ddp','/infolica/api/new_ddp') # config.add_route('numeros_relations_by_numeroBase','/infolica/api/numeros_relations_by_numeroBase_id') # config.add_route('numeros_relations_by_numeroBase_s','/infolica/api/numeros_relations_by_numeroBase_id/') config.add_route('numeros_differes','/infolica/api/numeros_differes') diff --git a/back/infolica/scripts/utils.py b/back/infolica/scripts/utils.py index 5e33e280..d7b14c03 100644 --- a/back/infolica/scripts/utils.py +++ b/back/infolica/scripts/utils.py @@ -317,7 +317,7 @@ def check_unread_preavis_remarks(cls, request, affaire_id, service_id=None): PreavisRemarque.lu_operateur_id == None, ) - if not service_id is None: + if service_id is not None: preavis_remarques = preavis_remarques.filter(Preavis.service_id == service_id) preavis_remarques = preavis_remarques.all() diff --git a/back/infolica/views/facture_emolument.py b/back/infolica/views/facture_emolument.py index 34a7eda3..861a3433 100644 --- a/back/infolica/views/facture_emolument.py +++ b/back/infolica/views/facture_emolument.py @@ -1,20 +1,18 @@ # -*- coding: utf-8 -*-- -from sqlalchemy.sql.elements import and_ -from pyramid.view import view_config -import pyramid.httpexceptions as exc -from pyramid.response import Response -from sqlalchemy import or_, func - +import datetime +import json +import math +import pyramid.httpexceptions as exc +import requests from infolica.models.constant import Constant -from infolica.models.models import Affaire, Facture, Numero, TableauEmoluments, VAffaire, VNumerosAffaires -from infolica.models.models import EmolumentAffaire, Emolument, EmolumentAffaireRepartition, FactureParametres -from infolica.scripts.utils import Utils +from infolica.models.models import Affaire, AffaireNumero, Cadastre, Emolument, EmolumentAffaire, EmolumentAffaireRepartition, Facture, FactureParametres, Numero, TableauEmoluments, VAffaire, VNumerosAffaires from infolica.scripts.authentication import check_connected -import json -import datetime -import requests -import math +from infolica.scripts.utils import Utils +from pyramid.response import Response +from pyramid.view import view_config +from sqlalchemy import func, or_ +from sqlalchemy.sql.elements import and_ ########################################################### # EMOLUMENTS @@ -25,7 +23,35 @@ def _round_nearest(x, a=0.05): return round(round(x / a) * a, -int(math.floor(math.log10(a)))) -@view_config(route_name='facture_parametres', request_method='GET', renderer='json') +def _numeros_emoluments_affaire(request, affaire_id): + affaire_numero_type_ancien_id = int(request.registry.settings["affaire_numero_type_ancien_id"]) + + num_aff = ( + request.dbsession.query(Numero.id, Numero.numero, Cadastre.nom) + .join(Cadastre, Cadastre.id == Numero.cadastre_id) + .join(AffaireNumero, AffaireNumero.numero_id == Numero.id) + .filter(AffaireNumero.affaire_id == affaire_id, AffaireNumero.type_id == affaire_numero_type_ancien_id) + .order_by(Cadastre.nom, Numero.numero) + .all() + ) + + num_emol = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.affaire_id == affaire_id).all() + + numeros = [] + for num_aff_i in num_aff: + numero_i = {"numero_id": num_aff_i.id, "numero": num_aff_i.numero, "cadastre": num_aff_i.nom, "emolument_affaire_id": None} + + for ne in num_emol: + if num_aff_i.id in ne.numeros_id: + numero_i["emolument_affaire_id"] = ne.id + break + + numeros.append(numero_i) + + return numeros + + +@view_config(route_name="facture_parametres", request_method="GET", renderer="json") def tableau_facture_parametres_view(request): """ Return actual parameters and values @@ -33,27 +59,29 @@ def tableau_facture_parametres_view(request): # Check connected if not check_connected(request): raise exc.HTTPForbidden() - + today = datetime.date.today() - results = request.dbsession.query(FactureParametres).filter( - FactureParametres.valable_de <= today, - or_( - FactureParametres.valable_a >= today, - FactureParametres.valable_a == None, + results = ( + request.dbsession.query(FactureParametres) + .filter( + FactureParametres.valable_de <= today, + or_( + FactureParametres.valable_a >= today, + FactureParametres.valable_a == None, + ), ) - ).all() + .all() + ) params = {} for result in results: - if not result.nom in params.keys(): + if result.nom not in params.keys(): params[result.nom] = result.valeur - return { 'facture_parametres': params } + return {"facture_parametres": params} - - -@view_config(route_name='emolument_affaire', request_method='GET', renderer='json') +@view_config(route_name="emolument_affaire", request_method="GET", renderer="json") def emolument_affaire_view(request): """ Return emolument_affaire @@ -62,123 +90,96 @@ def emolument_affaire_view(request): if not check_connected(request): raise exc.HTTPForbidden() - affaire_id = request.params['affaire_id'] if 'affaire_id' in request.params else None + affaire_id = request.params["affaire_id"] if "affaire_id" in request.params else None query = request.dbsession.query(EmolumentAffaire) - - if not affaire_id is None: + + if affaire_id is not None: query = query.filter(EmolumentAffaire.affaire_id == affaire_id) - + emolument_affaire = query.all() - - + # Récupérer les données des bâtiments result = [] for emolument_affaire_i in emolument_affaire: - query_bat = request.dbsession.query( - Emolument.batiment, - Emolument.batiment_f - ).filter( - Emolument.emolument_affaire_id == emolument_affaire_i.id - ).filter( - Emolument.batiment > 0 - ).group_by( - Emolument.batiment, - Emolument.batiment_f - ).order_by( - Emolument.batiment.asc() # Really important with respect to implementation of loading form_detail_batiment in front !! - ).all() - + query_bat = ( + request.dbsession.query(Emolument.batiment, Emolument.batiment_f) + .filter(Emolument.emolument_affaire_id == emolument_affaire_i.id) + .filter(Emolument.batiment > 0) + .group_by(Emolument.batiment, Emolument.batiment_f) + .order_by( + Emolument.batiment.asc() # Really important with respect to implementation of loading form_detail_batiment in front !! + ) + .all() + ) + batiment_f = [y for _, y in query_bat] numeros = [] numeros_id = [] if emolument_affaire_i.numeros_id and len(emolument_affaire_i.numeros_id) > 0: numeros_id = emolument_affaire_i.numeros_id - numeros = Utils.serialize_many(request.dbsession.query(VNumerosAffaires).filter( - and_( - VNumerosAffaires.numero_id.in_(tuple(emolument_affaire_i.numeros_id)), - VNumerosAffaires.affaire_id == emolument_affaire_i.affaire_id - ) - ).all()) - + numeros = Utils.serialize_many(request.dbsession.query(VNumerosAffaires).filter(and_(VNumerosAffaires.numero_id.in_(tuple(emolument_affaire_i.numeros_id)), VNumerosAffaires.affaire_id == emolument_affaire_i.affaire_id)).all()) + # Récupérer les liens sur la facture (répartition des montants) - facture_repartition = Utils.serialize_many( - request.dbsession.query(EmolumentAffaireRepartition).filter( - EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_i.id - ).all() - ) + facture_repartition = Utils.serialize_many(request.dbsession.query(EmolumentAffaireRepartition).filter(EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_i.id).all()) result.append( Utils._params( - id = emolument_affaire_i.id, - affaire_id = emolument_affaire_i.affaire_id, - pente_pc = emolument_affaire_i.pente_pc, - diff_visibilite_pc = emolument_affaire_i.diff_visibilite_pc, - trafic_pc = emolument_affaire_i.trafic_pc, - zi = emolument_affaire_i.zi , - indice_application = emolument_affaire_i.indice_application, - tva_pc = emolument_affaire_i.tva_pc, - remarque = emolument_affaire_i.remarque, - nb_batiments = len(batiment_f), - batiment_f = batiment_f, - numeros_id = numeros_id, - numeros = numeros, - facture_type_id = emolument_affaire_i.facture_type_id, - utilise = emolument_affaire_i.utilise, - facture_repartition = facture_repartition + id=emolument_affaire_i.id, + affaire_id=emolument_affaire_i.affaire_id, + pente_pc=emolument_affaire_i.pente_pc, + diff_visibilite_pc=emolument_affaire_i.diff_visibilite_pc, + trafic_pc=emolument_affaire_i.trafic_pc, + zi=emolument_affaire_i.zi, + indice_application=emolument_affaire_i.indice_application, + tva_pc=emolument_affaire_i.tva_pc, + remarque=emolument_affaire_i.remarque, + nb_batiments=len(batiment_f), + batiment_f=batiment_f, + numeros_id=numeros_id, + numeros=numeros, + facture_type_id=emolument_affaire_i.facture_type_id, + utilise=emolument_affaire_i.utilise, + facture_repartition=facture_repartition, ) ) - + return result -@view_config(route_name='emolument', request_method='GET', renderer='json') +@view_config(route_name="emolument", request_method="GET", renderer="json") def emolument_view(request): """ - Return emoluments of emoluments_affaire + Return emoluments of emoluments_affaire """ if not check_connected(request): raise exc.HTTPForbidden() today = datetime.date.today() - emolument_affaire_id = request.params['emolument_affaire_id'] if 'emolument_affaire_id' in request.params else None - emoluments_divers_tarifhoraire_id = int(request.registry.settings['emoluments_divers_tarifhoraire_id']) + emolument_affaire_id = request.params["emolument_affaire_id"] if "emolument_affaire_id" in request.params else None + emoluments_divers_tarifhoraire_id = int(request.registry.settings["emoluments_divers_tarifhoraire_id"]) - emol_affaire = request.dbsession.query(EmolumentAffaire).filter( - EmolumentAffaire.id==emolument_affaire_id - ).first() + emol_affaire = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.id == emolument_affaire_id).first() form_general = Utils.serialize_one(emol_affaire) if emol_affaire.utilise is True: today_last = today fact = request.dbsession.query(Facture).join(EmolumentAffaireRepartition).filter(EmolumentAffaireRepartition.emolument_affaire_id == emol_affaire.id).first() - today = fact.date + today = getattr(fact, "date", None) if today is None: today = request.dbsession.query(Affaire.date_envoi).filter(Affaire.id == emol_affaire.affaire_id).scalar() if today is None: today = today_last - nb_batiments = request.dbsession.query(func.max(Emolument.batiment)).filter( - Emolument.emolument_affaire_id==emolument_affaire_id - ).scalar() - if nb_batiments is None: nb_batiments = 0 + nb_batiments = request.dbsession.query(func.max(Emolument.batiment)).filter(Emolument.emolument_affaire_id == emolument_affaire_id).scalar() + if nb_batiments is None: + nb_batiments = 0 - - existing_emoluments_query = request.dbsession.query(Emolument).filter( - Emolument.emolument_affaire_id==emolument_affaire_id - ) + existing_emoluments_query = request.dbsession.query(Emolument).filter(Emolument.emolument_affaire_id == emolument_affaire_id) # emoluments - table = request.dbsession.query( - TableauEmoluments - ).filter( - TableauEmoluments.date_entree <= today, - or_( - TableauEmoluments.date_sortie > today, - TableauEmoluments.date_sortie == None - ) - ).order_by(TableauEmoluments.categorie_id, TableauEmoluments.sous_categorie_id, TableauEmoluments.ordre).all() + table = request.dbsession.query(TableauEmoluments).filter(TableauEmoluments.date_entree <= today, or_(TableauEmoluments.date_sortie > today, TableauEmoluments.date_sortie == None)).order_by(TableauEmoluments.categorie_id, TableauEmoluments.sous_categorie_id, TableauEmoluments.ordre).all() emoluments = [] divers_tarifhoraire = [] @@ -187,16 +188,16 @@ def emolument_view(request): last_sous_categorie_id = "" categorie = [] sous_categorie = [] - batiments_f = [0]*nb_batiments + batiments_f = [0] * nb_batiments for position in table: if position.id == emoluments_divers_tarifhoraire_id: - existing_emoluments = existing_emoluments_query.filter(Emolument.tableau_emolument_id==int(emoluments_divers_tarifhoraire_id)).all() + existing_emoluments = existing_emoluments_query.filter(Emolument.tableau_emolument_id == int(emoluments_divers_tarifhoraire_id)).all() for ee in existing_emoluments: position_ = { - 'nom': ee.position, - 'nombre': ee.nombre, - 'montant': ee.prix_unitaire, - 'prix': ee.montant, + "nom": ee.position, + "nombre": ee.nombre, + "montant": ee.prix_unitaire, + "prix": ee.montant, } divers_tarifhoraire.append(position_) continue @@ -213,16 +214,16 @@ def emolument_view(request): categorie = [] position_ = Utils.serialize_one(position) - position_['nombre'] = [0]*(nb_batiments +1) - position_['prix'] = [0]*(nb_batiments +1) - + position_["nombre"] = [0] * (nb_batiments + 1) + position_["prix"] = [0] * (nb_batiments + 1) + # check if emolument already exists un database - existing_emoluments = existing_emoluments_query.filter(Emolument.tableau_emolument_id==int(position_['id'])).all() + existing_emoluments = existing_emoluments_query.filter(Emolument.tableau_emolument_id == int(position_["id"])).all() for ee in existing_emoluments: - position_['nombre'][ee.batiment] = ee.nombre - position_['prix'][ee.batiment] = ee.montant - if ee.batiment > 0 and batiments_f[ee.batiment-1] == 0: - batiments_f[ee.batiment-1] = ee.batiment_f + position_["nombre"][ee.batiment] = ee.nombre + position_["prix"][ee.batiment] = ee.montant + if ee.batiment > 0 and batiments_f[ee.batiment - 1] == 0: + batiments_f[ee.batiment - 1] = ee.batiment_f sous_categorie.append(position_) @@ -232,61 +233,59 @@ def emolument_view(request): categorie.append(sous_categorie) emoluments.append(categorie) - form_general['batiment_f'] = batiments_f - form_general['nb_batiments'] = len(batiments_f) + form_general["batiment_f"] = batiments_f + form_general["nb_batiments"] = len(batiments_f) - return {'emoluments': json.dumps(emoluments), 'form_general': json.dumps(form_general), 'divers_tarifhoraire': json.dumps(divers_tarifhoraire)} + numeros = _numeros_emoluments_affaire(request, form_general["affaire_id"]) + return {"emoluments": json.dumps(emoluments), "form_general": json.dumps(form_general), "divers_tarifhoraire": json.dumps(divers_tarifhoraire), "numeros": json.dumps(numeros)} -@view_config(route_name='emolument', request_method='POST', renderer='json') +@view_config(route_name="emolument", request_method="POST", renderer="json") def emolument_new_view(request): """ Add new emolument """ # Check authorization - if not Utils.has_permission(request, request.registry.settings['affaire_facture_edition']): + if not Utils.has_permission(request, request.registry.settings["affaire_facture_edition"]): raise exc.HTTPForbidden() - emoluments_divers_tarifhoraire_id = int(request.registry.settings['emoluments_divers_tarifhoraire_id']) + emoluments_divers_tarifhoraire_id = int(request.registry.settings["emoluments_divers_tarifhoraire_id"]) - form_general = json.loads(request.params['form_general']) if 'form_general' in request.params else None - emoluments = json.loads(request.params['emoluments']) if 'emoluments' in request.params else None - divers_tarifhoraire = json.loads(request.params['divers_tarifhoraire']) if 'divers_tarifhoraire' in request.params else None + form_general = json.loads(request.params["form_general"]) if "form_general" in request.params else None + emoluments = json.loads(request.params["emoluments"]) if "emoluments" in request.params else None + divers_tarifhoraire = json.loads(request.params["divers_tarifhoraire"]) if "divers_tarifhoraire" in request.params else None # save form_general - if form_general['id'] is None: + if form_general["id"] is None: emol_affaire = EmolumentAffaire() emol_affaire = Utils.set_model_record(emol_affaire, form_general) request.dbsession.add(emol_affaire) request.dbsession.flush() else: - emol_affaire = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.id==form_general['id']).first() + emol_affaire = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.id == form_general["id"]).first() emol_affaire = Utils.set_model_record(emol_affaire, form_general) request.dbsession.flush() - # save form_general - existing_emoluments = request.dbsession.query(Emolument).filter( - Emolument.emolument_affaire_id==emol_affaire.id - ).all() + existing_emoluments = request.dbsession.query(Emolument).filter(Emolument.emolument_affaire_id == emol_affaire.id).all() for emol in existing_emoluments: request.dbsession.delete(emol) for category in emoluments: for scategory in category: for position in scategory: - for i in range(len(position['nombre'])): - if float(position['nombre'][i] or 0) > 0 or float(position['prix'][i] or 0) > 0: + for i in range(len(position["nombre"])): + if float(position["nombre"][i] or 0) > 0 or float(position["prix"][i] or 0) > 0: params = Utils._params( emolument_affaire_id=emol_affaire.id, - tableau_emolument_id=int(position['id']), - position=position['nom'], - prix_unitaire=_round_nearest(float(position['montant']) or 0), - nombre=float(position['nombre'][i] or '0'), + tableau_emolument_id=int(position["id"]), + position=position["nom"], + prix_unitaire=_round_nearest(float(position["montant"]) or 0), + nombre=float(position["nombre"][i] or "0"), batiment=i, - batiment_f=1 if i == 0 else float(form_general['batiment_f'][i-1]), - montant=_round_nearest(float(position['prix'][i]) or 0) + batiment_f=1 if i == 0 else float(form_general["batiment_f"][i - 1]), + montant=_round_nearest(float(position["prix"][i]) or 0), ) # save emolument @@ -295,20 +294,11 @@ def emolument_new_view(request): request.dbsession.add(record) - # save divers tarif horaire for dth in divers_tarifhoraire: - if dth['nom'] is not None and dth['nombre'] is not None and dth['montant'] is not None and \ - dth['nom'] != '' and dth['nombre'] != '' and dth['montant'] != '': + if dth["nom"] is not None and dth["nombre"] is not None and dth["montant"] is not None and dth["nom"] != "" and dth["nombre"] != "" and dth["montant"] != "": params = Utils._params( - emolument_affaire_id=emol_affaire.id, - tableau_emolument_id=emoluments_divers_tarifhoraire_id, - position=dth['nom'], - prix_unitaire=_round_nearest(float(dth['montant']) or 0), - nombre=float(dth['nombre']), - batiment=0, - batiment_f=1, - montant=_round_nearest(float(dth['prix']) or 0) + emolument_affaire_id=emol_affaire.id, tableau_emolument_id=emoluments_divers_tarifhoraire_id, position=dth["nom"], prix_unitaire=_round_nearest(float(dth["montant"]) or 0), nombre=float(dth["nombre"]), batiment=0, batiment_f=1, montant=_round_nearest(float(dth["prix"]) or 0) ) # save emolument @@ -317,53 +307,55 @@ def emolument_new_view(request): request.dbsession.add(record) - return {'emolument_affaire_id': emol_affaire.id} + return {"emolument_affaire_id": emol_affaire.id} -@view_config(route_name='emolument', request_method='DELETE', renderer='json') +@view_config(route_name="emolument", request_method="DELETE", renderer="json") def emolument_delete_view(request): """ Delete emolument """ # Check authorization - if not Utils.has_permission(request, request.registry.settings['affaire_facture_edition']): + if not Utils.has_permission(request, request.registry.settings["affaire_facture_edition"]): raise exc.HTTPForbidden() - emolument_affaire_id = request.params['emolument_affaire_id'] if 'emolument_affaire_id' in request.params else None + emolument_affaire_id = request.params["emolument_affaire_id"] if "emolument_affaire_id" in request.params else None # get emolument affaire - emol_affaire = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.id==emolument_affaire_id).first() + emol_affaire = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.id == emolument_affaire_id).first() # delete linked emoluments - existing_emoluments = request.dbsession.query(Emolument).filter( - Emolument.emolument_affaire_id==emol_affaire.id - ).all() + existing_emoluments = request.dbsession.query(Emolument).filter(Emolument.emolument_affaire_id == emol_affaire.id).all() for emol in existing_emoluments: request.dbsession.delete(emol) + # get emolument_affaire_repartition and delete them if exist + ear = request.dbsession.query(EmolumentAffaireRepartition).filter(EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_id).all() + for ear_i in ear: + request.dbsession.delete(ear_i) + + request.dbsession.flush() + # finally delete emolument affaire request.dbsession.delete(emol_affaire) return Utils.get_data_save_response(Constant.SUCCESS_DELETE.format(EmolumentAffaire.__tablename__)) - -@view_config(route_name='emolument_affaire_freeze', request_method='PUT', renderer='json') +@view_config(route_name="emolument_affaire_freeze", request_method="PUT", renderer="json") def update_emolument_affaire_freeze_view(request): """ Freeze emolument_affaire """ # Check authorization - if not Utils.has_permission(request, request.registry.settings['affaire_facture_edition']): + if not Utils.has_permission(request, request.registry.settings["affaire_facture_edition"]): raise exc.HTTPForbidden() params = request.params - - record_id = params['emolument_affaire_id'] if 'emolument_affaire_id' in params else None - record = request.dbsession.query(EmolumentAffaire).filter( - EmolumentAffaire.id == record_id - ).first() + record_id = params["emolument_affaire_id"] if "emolument_affaire_id" in params else None + + record = request.dbsession.query(EmolumentAffaire).filter(EmolumentAffaire.id == record_id).first() record = Utils.set_model_record(record, params) @@ -374,7 +366,8 @@ def update_emolument_affaire_freeze_view(request): ### EMOLUMENT AFFAIRE REPARTITION ### ####################################### -@view_config(route_name='emolument_affaire_repartiton', request_method='GET', renderer='json') + +@view_config(route_name="emolument_affaire_repartiton", request_method="GET", renderer="json") def emolument_affaire_repartiton_view(request): """ get emolument_affaire_repartiton @@ -384,127 +377,115 @@ def emolument_affaire_repartiton_view(request): raise exc.HTTPForbidden() records = request.dbsession.query(EmolumentAffaireRepartition) - + if "emolument_affaire_id" in request.params: records = records.filter(EmolumentAffaireRepartition.emolument_affaire_id == request.params["emolument_affaire_id"]) - + if "facture_id" in request.params: records = records.filter(EmolumentAffaireRepartition.facture_id == request.params["facture_id"]) - + records = records.all() - if len(records)>0: + if len(records) > 0: return Utils.serialize_many(records) else: return [] -@view_config(route_name='emolument_affaire_repartiton', request_method='POST', renderer='json') +@view_config(route_name="emolument_affaire_repartiton", request_method="POST", renderer="json") def emolument_affaire_repartiton_new_view(request): """ Add new emolument_affaire_repartiton """ # Check authorization - if not Utils.has_permission(request, request.registry.settings['affaire_facture_edition']): + if not Utils.has_permission(request, request.registry.settings["affaire_facture_edition"]): raise exc.HTTPForbidden() emolument_affaire_id = request.params["emolument_affaire_id"] if "emolument_affaire_id" in request.params else None emolument_facture_repartition = json.loads(request.params["emolument_facture_repartition"]) if "emolument_facture_repartition" in request.params else None # get records of current emolument_affaire_id - emolumentAffaireRepartition = request.dbsession.query(EmolumentAffaireRepartition).filter( - EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_id - ).all() - + emolumentAffaireRepartition = request.dbsession.query(EmolumentAffaireRepartition).filter(EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_id).all() # iterate through emolument_facture_repartition for efr_i in emolument_facture_repartition: # test if efr_i exists already in db record = None for idx, eaf_i in enumerate(emolumentAffaireRepartition): - if eaf_i.facture_id == efr_i['id']: + if eaf_i.facture_id == efr_i["id"]: # La relation existe déjà, la modifier record = emolumentAffaireRepartition.pop(idx) break - - if not record is None: - if float(record.repartition) != float(efr_i['emolument_repartition']): - if float(efr_i['emolument_repartition']) == 0: + + if record is not None: + if float(record.repartition) != float(efr_i["emolument_repartition"]): + if float(efr_i["emolument_repartition"]) == 0: # supprimer l'entrée car la répartition est nulle request.dbsession.delete(record) else: # enregistrer la nouvelle répartition - params = Utils._params( - facture_id = efr_i['id'], - emolument_affaire_id = emolument_affaire_id, - repartition = efr_i['emolument_repartition'] - ) + params = Utils._params(facture_id=efr_i["id"], emolument_affaire_id=emolument_affaire_id, repartition=efr_i["emolument_repartition"]) record = Utils.set_model_record(record, params) - + else: # Créer l'entrée inexistante et si la répartition est non nulle - if float(efr_i['emolument_repartition']) > 0: + if float(efr_i["emolument_repartition"]) > 0: record = EmolumentAffaireRepartition() - params = Utils._params( - facture_id = efr_i['id'], - emolument_affaire_id = emolument_affaire_id, - repartition = efr_i['emolument_repartition'] - ) + params = Utils._params(facture_id=efr_i["id"], emolument_affaire_id=emolument_affaire_id, repartition=efr_i["emolument_repartition"]) record = Utils.set_model_record(record, params) request.dbsession.add(record) # remove items in db not posted for item in emolumentAffaireRepartition: - request.dbsession.delete(item) + request.dbsession.delete(item) return Utils.get_data_save_response(Constant.SUCCESS_SAVE.format(EmolumentAffaireRepartition.__tablename__)) -@view_config(route_name='emolument_affaire_repartiton', request_method='DELETE', renderer='json') +@view_config(route_name="emolument_affaire_repartiton", request_method="DELETE", renderer="json") def emolument_affaire_repartiton_delete_view(request): """ Delete emolument_affaire_repartiton by emolument_affaire_id """ # Check authorization - if not Utils.has_permission(request, request.registry.settings['affaire_facture_edition']): + if not Utils.has_permission(request, request.registry.settings["affaire_facture_edition"]): raise exc.HTTPForbidden() emolument_affaire_id = request.params["emolument_affaire_id"] if "emolument_affaire_id" in request.params else None - records = request.dbsession.query(EmolumentAffaireRepartition).filter( - EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_id - ).all() + records = request.dbsession.query(EmolumentAffaireRepartition).filter(EmolumentAffaireRepartition.emolument_affaire_id == emolument_affaire_id).all() for record in records: request.dbsession.delete(record) - -@view_config(route_name='tableau_emoluments_new', request_method='GET', renderer='json') +@view_config(route_name="tableau_emoluments_new", request_method="GET", renderer="json") def tableau_emoluments_new_view(request): """ Get tableau of emoluments """ # Check authorization - if not Utils.has_permission(request, request.registry.settings['affaire_facture_edition']): + if not Utils.has_permission(request, request.registry.settings["affaire_facture_edition"]): raise exc.HTTPForbidden() + affaire_id = request.params["affaire_id"] if "affaire_id" in request.params else None + today = datetime.date.today() - emoluments_divers_tarifhoraire_id = int(request.registry.settings['emoluments_divers_tarifhoraire_id']) + emoluments_divers_tarifhoraire_id = int(request.registry.settings["emoluments_divers_tarifhoraire_id"]) # get active emoluments - table = request.dbsession.query( - TableauEmoluments - ).filter( - TableauEmoluments.date_entree <= today, - or_( - TableauEmoluments.date_sortie > today, - TableauEmoluments.date_sortie == None - ), - TableauEmoluments.id != emoluments_divers_tarifhoraire_id, # dont take into account diver-tarif-horaire which is generated by the front of the application - ).order_by(TableauEmoluments.categorie_id, TableauEmoluments.sous_categorie_id, TableauEmoluments.ordre).all() + table = ( + request.dbsession.query(TableauEmoluments) + .filter( + TableauEmoluments.date_entree <= today, + or_(TableauEmoluments.date_sortie > today, TableauEmoluments.date_sortie == None), + TableauEmoluments.id != emoluments_divers_tarifhoraire_id, # dont take into account diver-tarif-horaire which is generated by the front of the application + ) + .order_by(TableauEmoluments.categorie_id, TableauEmoluments.sous_categorie_id, TableauEmoluments.ordre) + .all() + ) result = [] c = 0 @@ -530,11 +511,12 @@ def tableau_emoluments_new_view(request): categorie.append(sous_categorie) result.append(categorie) - return result + numeros = _numeros_emoluments_affaire(request, affaire_id) + return {"emoluments": result, "numeros": numeros} -@view_config(route_name='export_emoluments_pdf', request_method='POST') +@view_config(route_name="export_emoluments_pdf", request_method="POST") def export_emoluments_pdf_view(request): """ Create PDF of emoluments @@ -546,21 +528,15 @@ def export_emoluments_pdf_view(request): now = datetime.datetime.now() # get request params - tableau_emoluments_id = request.params['tableau_emoluments_id'] if 'tableau_emoluments_id' in request.params else None - affaire_id = request.params['affaire_id'] if 'affaire_id' in request.params else None - tableau_emoluments_html = request.params['tableau_emoluments_html'] if 'tableau_emoluments_html' in request.params else None - tableau_recapitulatif_html = request.params['tableau_recapitulatif_html'] if 'tableau_recapitulatif_html' in request.params else None + tableau_emoluments_id = request.params["tableau_emoluments_id"] if "tableau_emoluments_id" in request.params else None + affaire_id = request.params["affaire_id"] if "affaire_id" in request.params else None + tableau_emoluments_html = request.params["tableau_emoluments_html"] if "tableau_emoluments_html" in request.params else None + tableau_recapitulatif_html = request.params["tableau_recapitulatif_html"] if "tableau_recapitulatif_html" in request.params else None # get facture_id - factures = request.dbsession.query( - Facture - ).join( - EmolumentAffaireRepartition - ).filter( - EmolumentAffaireRepartition.emolument_affaire_id == tableau_emoluments_id - ).all() - - #get affaire + factures = request.dbsession.query(Facture).join(EmolumentAffaireRepartition).filter(EmolumentAffaireRepartition.emolument_affaire_id == tableau_emoluments_id).all() + + # get affaire affaire = request.dbsession.query(VAffaire).filter(VAffaire.id == affaire_id).first() # get bf_emolument @@ -569,13 +545,10 @@ def export_emoluments_pdf_view(request): if numeros_id is not None: emolument_bf_html = [] for num_id in numeros_id: - emolument_bf_html.append( - str(request.dbsession.query(Numero).filter(Numero.id == num_id).first().numero) - ) + emolument_bf_html.append(str(request.dbsession.query(Numero).filter(Numero.id == num_id).first().numero)) emolument_bf_html = ", ".join(emolument_bf_html) - d = {"now": now.strftime("%d.%m.%Y, %H:%M:%S")} header_str = "" @@ -650,12 +623,12 @@ def export_emoluments_pdf_view(request): header_str += "

Tableau des émoluments de la mensuration officielle

" header_str += "

Affaire n° " + str(affaire_id) + " sur le cadastre: " + affaire.cadastre + "

" - + # numéros de BF s'ils sont rattachés if emolument_bf_html is not None and emolument_bf_html != "": header_str += "

Bien(s)-fonds n° " + emolument_bf_html + "

" header_str += "

Emolument n° " + str(tableau_emoluments_id) + "

" - + # edit facture_html if len(factures) == 0: factures_html = "Aucune facture rattachée à l'émolument" @@ -668,20 +641,33 @@ def export_emoluments_pdf_view(request): if factures_html == "" or factures_html == []: factures_html = "La facture n'a pas encore été envoyée" - header_str += '

Facture(s): ' + factures_html + "

" + header_str += "

Facture(s): " + factures_html + "

" + tableau_emoluments_html = header_str + tableau_emoluments_html + tableau_emoluments_html += '

Récapitulatif

' + tableau_emoluments_html += tableau_recapitulatif_html + "" + + filename = "Tableau_émoluments_" + str(tableau_emoluments_id) + "_Affaire_" + str(affaire_id) + ".pdf" + result = requests.post(request.registry.settings["weasyprint_baseurl"] + filename, data=tableau_emoluments_html) + + response = Response(result.content) + params = response.content_type_params + params["filename"] = filename + response.content_type = "application/pdf" + response.content_type_params = params + return response tableau_emoluments_html = header_str + tableau_emoluments_html tableau_emoluments_html += '

Récapitulatif

' tableau_emoluments_html += tableau_recapitulatif_html + "" filename = "Tableau_émoluments_" + str(tableau_emoluments_id) + "_Affaire_" + str(affaire_id) + ".pdf" - result = requests.post(request.registry.settings['weasyprint_baseurl'] + filename, data=tableau_emoluments_html) + result = requests.post(request.registry.settings["weasyprint_baseurl"] + filename, data=tableau_emoluments_html) response = Response(result.content) params = response.content_type_params - params['filename'] = filename - response.content_type = 'application/pdf' + params["filename"] = filename + response.content_type = "application/pdf" response.content_type_params = params return response diff --git a/back/infolica/views/numero.py b/back/infolica/views/numero.py index 5ccc95e4..6fe0a159 100644 --- a/back/infolica/views/numero.py +++ b/back/infolica/views/numero.py @@ -1,25 +1,35 @@ # -*- coding: utf-8 -*-- -from pyramid.view import view_config -import pyramid.httpexceptions as exc - -from sqlalchemy import and_, func, Integer, BigInteger -from sqlalchemy.dialects.postgresql import ARRAY, aggregate_order_by +import json +import os +import re +import shutil +from datetime import datetime +import openpyxl +import pyramid.httpexceptions as exc from infolica.exceptions.custom_error import CustomError from infolica.models.constant import Constant -from infolica.models.models import AffaireNumero, Numero, NumeroDiffere, NumeroEtat -from infolica.models.models import NumeroEtatHisto, NumeroType, VNumeros -from infolica.models.models import VNumerosAffaires, Affaire, Facture -from infolica.models.models import Cadastre -from infolica.scripts.utils import Utils +from infolica.models.models import (Affaire, AffaireNumero, Cadastre, Facture, + Numero, NumeroDiffere, NumeroEtat, + NumeroEtatHisto, NumeroType, VNumeros, + VNumerosAffaires) from infolica.scripts.authentication import check_connected -from datetime import datetime +from infolica.scripts.utils import Utils +from pyramid.view import view_config +from sqlalchemy import BigInteger, Integer, and_, func +from sqlalchemy.dialects.postgresql import ARRAY, aggregate_order_by + + +def _update_numero_etat(request, numero_id, etat_id): + num = request.dbsession.query(Numero).get(numero_id) + num.etat_id = etat_id + + num_histo = NumeroEtatHisto() + num_histo.numero_id = numero_id + num_histo.numero_etat_id = etat_id + num_histo.date = datetime.today() + return num -import os -import shutil -import openpyxl -import re -import json @view_config(route_name='numeros', request_method='GET', renderer='json') @@ -38,7 +48,7 @@ def numeros_view(request): etat_id = [int(a) for a in request.params['etat_id'].split(",")] if 'etat_id' in request.params else None query = request.dbsession.query(VNumeros) - + if numero: query = query.filter(VNumeros.numero == numero) if cadastre_id: @@ -263,7 +273,7 @@ def numeros_etat_histo_new_view(request, params=None): NumeroEtatHisto.numero_etat_id == params['numero_etat_id'] ).first() - if not numEtatHisto is None: + if numEtatHisto is not None: return # nouveau numero @@ -414,7 +424,7 @@ def affaire_numero_new_view(request, params=None): AffaireNumero.type_id == params['type_id'] ).first() - if not affaireNumero is None: + if affaireNumero is not None: return # nouveau affaire_numero @@ -485,7 +495,7 @@ def numero_differe_view(request): VNumeros.diff_req_ref, numeros_vigueur_check ) - + if role == "mo": user_id = request.params['user_id'] if 'user_id' in request.params else None @@ -496,23 +506,23 @@ def numero_differe_view(request): VNumeros.diff_entree.isnot(None), VNumeros.diff_sortie == None )) - + elif role == "secr": query = query.filter(and_( VNumeros.diff_req_radiation.isnot(True), VNumeros.diff_sortie.isnot(None), - VNumeros.etat_id.in_((numero_projet_id, numero_vigueur_id)) + VNumeros.etat_id.in_((numero_projet_id, numero_vigueur_id)) )) - + elif role == "coord": user_id = request.params['user_id'] if 'user_id' in request.params else None - + if user_id is not None: query = query.filter(VNumeros.diff_operateur_id == user_id) - + query = query.filter(and_( VNumeros.diff_sortie.isnot(None), - VNumeros.diff_controle == None + VNumeros.diff_controle == None )) result = query.group_by( @@ -597,7 +607,7 @@ def numero_differe_update_view(request): if "numero_diff_id" in request.params: numdiff_id = request.params["numero_diff_id"] record = request.dbsession.query(NumeroDiffere).filter(NumeroDiffere.id == numdiff_id).first() - + if "numero_id" in request.params: num_id = request.params["numero_id"] record = request.dbsession.query(NumeroDiffere).filter(NumeroDiffere.numero_id == num_id).first() @@ -655,7 +665,7 @@ def _getCadastre(request, cadastre_id): def _getAffairesIdFromNumeroId(request, numero_id, numero_type_id): affaires_id_agg = func.array_agg(AffaireNumero.affaire_id, type_=ARRAY(BigInteger)) - + affaires_id = request.dbsession.query( affaires_id_agg ).filter( @@ -677,7 +687,7 @@ def loadfile_bf_rp(request): affaire_id = request.params["affaire_id"] if "affaire_id" in request.params else None file = request.params["file"] if "file" in request.params else None - + if file is None: return exc.HTTPError('Le fichier est vide') @@ -688,7 +698,7 @@ def loadfile_bf_rp(request): if os.path.exists(file_path): os.remove(file_path) - + with open(file_path, 'wb') as output_file: shutil.copyfileobj(file.file, output_file) @@ -702,10 +712,10 @@ def loadfile_bf_rp(request): # ============================= sheet = 'Infolica' ws = wb[sheet] - + numero_id_agg = func.array_agg(Numero.id, type_=ARRAY(BigInteger)) numero_numero_agg = func.array_agg(aggregate_order_by(Numero.numero, Numero.numero.asc()), type_=ARRAY(BigInteger)) - + # prepare query to search Number data_query = request.dbsession.query( numero_id_agg, @@ -725,7 +735,7 @@ def loadfile_bf_rp(request): if numero_id is not None: data_id.append(numero_id) row_i += 1 - + else: results = data_query.filter( Numero.id.in_(data_id) @@ -759,14 +769,14 @@ def loadfile_bf_rp(request): 'cadastre_id': result[1], 'liste_numeros': liste_numeros }) - + data.append({ 'source': sheet, 'data': tmp }) - + break - + # =========================== # Let's focus on Terris sheet # =========================== @@ -777,7 +787,7 @@ def loadfile_bf_rp(request): row_i = 2 while row_i < 1000: cadastre_id = ws.cell(row=row_i, column=2).value - + if cadastre_id is not None: numero = re.split('\D', str(ws.cell(row=row_i, column=3).value))[0] @@ -812,7 +822,7 @@ def loadfile_bf_rp(request): 'cadastre': cadastre, 'sheet': sheet, 'font_color': font_color, - 'error': error + 'error': error } cadastre_id_already_exists = False @@ -828,9 +838,9 @@ def loadfile_bf_rp(request): 'cadastre_id': cadastre_id, 'liste_numeros': [numero_] }) - + row_i += 1 - + else: for tmp_ln in tmp: # parcourir les cadastres @@ -840,12 +850,12 @@ def loadfile_bf_rp(request): 'source': sheet, 'data': tmp }) - + break - + if os.path.exists(file_path): os.remove(file_path) - + return data @@ -858,7 +868,7 @@ def __save_bf_rp(request, affaire_id, data, numero_type_id, numero_etat_id, nume for num_cad in data: # on parcourt les cadastres for numero_obj in num_cad['liste_numeros']: - + numero = str(numero_obj['numero']).split(' ')[0] num = num_req.filter( @@ -898,7 +908,7 @@ def __save_bf_rp(request, affaire_id, data, numero_type_id, numero_etat_id, nume ) request.dbsession.add(neh) - + # log dans table affaire_numero if not already exists an = an_req.filter( AffaireNumero.affaire_id == affaire_id, @@ -930,14 +940,14 @@ def save_bf_rp(request): affaire_id = request.params["affaire_id"] if "affaire_id" in request.params else None num_projet = json.loads(request.params["num_projet"]) if "num_projet" in request.params else None num_vigueur = json.loads(request.params["num_vigueur"]) if "num_vigueur" in request.params else None - + affaire_numero_type_ancien_id = request.registry.settings['affaire_numero_type_ancien_id'] affaire_numero_type_nouveau_id = request.registry.settings['affaire_numero_type_nouveau_id'] numero_projet_id = request.registry.settings['numero_projet_id'] numero_vigueur_id = request.registry.settings['numero_vigueur_id'] numero_bf_id = request.registry.settings['numero_bf_id'] - + __save_bf_rp(request, affaire_id, num_projet, numero_bf_id, numero_projet_id, affaire_numero_type_nouveau_id) __save_bf_rp(request, affaire_id, num_vigueur, numero_bf_id, numero_vigueur_id, affaire_numero_type_ancien_id) - + return exc.HTTPOk() diff --git a/back/infolica/views/numero_relation.py b/back/infolica/views/numero_relation.py index 16e61902..44411dde 100644 --- a/back/infolica/views/numero_relation.py +++ b/back/infolica/views/numero_relation.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*-- -from pyramid.view import view_config import pyramid.httpexceptions as exc - from infolica.exceptions.custom_error import CustomError from infolica.models.constant import Constant -from infolica.models.models import NumeroRelation, VNumerosRelations -from infolica.scripts.utils import Utils +from infolica.models.models import (AffaireNumero, Numero, NumeroRelation, + VNumerosRelations) from infolica.scripts.authentication import check_connected +from infolica.scripts.utils import Utils +from pyramid.view import view_config from sqlalchemy import and_ @@ -116,7 +116,7 @@ def numeros_relations_update_view(request): # Check authorization if not Utils.has_permission(request, request.registry.settings['affaire_numero_edition']): raise exc.HTTPForbidden() - + model = request.dbsession.query(NumeroRelation) # get instance @@ -135,7 +135,7 @@ def numeros_relations_update_view(request): )) model = model.first() - + # update instance if model != None and "affaire_new_id" in request.params: model.affaire_id = request.params["affaire_new_id"] if "affaire_new_id" in request.params else None @@ -176,3 +176,82 @@ def numeros_relations_delete_view(request): request.dbsession.delete(model) return Utils.get_data_save_response(Constant.SUCCESS_SAVE.format(NumeroRelation.__tablename__)) + +########################################################### +# CONSTITUTION DDP +########################################################### + + +@view_config(route_name="new_ddp", request_method="POST", renderer="json") +def numero_differe_view(request): + """ + Post new ddp + """ + # Check authorization + if not Utils.has_permission( + request, request.registry.settings["affaire_numero_edition"] + ): + raise exc.HTTPForbidden() + + numero_type_ddp_id = request.registry.settings["numero_ddp_id"] + numero_relation_type_ddp_id = request.registry.settings["numero_relation_ddp_id"] + affaire_numero_type_ancien_id = request.registry.settings[ + "affaire_numero_type_ancien_id" + ] + + affaire_id = ( + request.params["affaire_id"] if "affaire_id" in request.params else None + ) + ddp_id = request.params["ddp"] if "ddp" in request.params else None + base_id = request.params["base"] if "base" in request.params else None + + if ddp_id is not None and base_id is not None: + # update type of ddp + ddp = request.dbsession.query(Numero).get(ddp_id) + ddp.type_id = numero_type_ddp_id + + # create / update numero_relation + num_rel = ( + request.dbsession.query(NumeroRelation) + .filter( + NumeroRelation.numero_id_base == base_id, + NumeroRelation.numero_id_associe == ddp_id, + NumeroRelation.affaire_id == affaire_id, + ) + .first() + ) + + if num_rel is not None: + num_rel.relation_type_id = numero_relation_type_ddp_id + else: + num_rel = NumeroRelation() + num_rel.affaire_id = affaire_id + num_rel.numero_id_base = base_id + num_rel.numero_id_associe = ddp_id + num_rel.relation_type_id = numero_relation_type_ddp_id + request.dbsession.add(num_rel) + + # create / update affaire_numero base + aff_num_base = ( + request.dbsession.query(AffaireNumero) + .filter( + AffaireNumero.affaire_id == affaire_id, + AffaireNumero.numero_id == base_id, + ) + .first() + ) + + if aff_num_base is not None: + aff_num_base.type_id = affaire_numero_type_ancien_id + aff_num_base.actif = True + else: + aff_num_base = AffaireNumero() + aff_num_base.affaire_id = affaire_id + aff_num_base.numero_id = base_id + aff_num_base.type_id = affaire_numero_type_ancien_id + aff_num_base.actif = True + request.dbsession.add(aff_num_base) + + return Utils.get_data_save_response( + Constant.SUCCESS_SAVE.format(NumeroRelation.__tablename__) + ) diff --git a/front/.env b/front/.env index 34cb4a91..980342c6 100644 --- a/front/.env +++ b/front/.env @@ -3,7 +3,7 @@ VUE_APP_API_URL="{API_URL}" PUBLIC_PATH = "{PUBLIC_PATH}" VUE_APP_STATUS = "development" -VUE_APP_VERSION = "1.11.5" +VUE_APP_VERSION = "1.11.6" #================================== @@ -62,6 +62,7 @@ VUE_APP_NUMEROS_ETAT_HISTO_ENDPOINT = "/numeros_etat_histo/" VUE_APP_NUMEROS_ENDPOINT = "/numeros/" VUE_APP_NUMEROS_RELATIONS_ENDPOINT = "/numeros_relations" VUE_APP_NUMEROS_RELATIONS_BY_AFFAIREID_ENDPOINT = "/affaire_numeros_relations/" +VUE_APP_NUMEROS_DDP_ENDPOINT = "/new_ddp" #VUE_APP_NUMEROS_RELATIONS_BY_NUMEROSBASEID_ENDPOINT = "/numeros_relations_by_numeroBase_id" VUE_APP_NUMEROS_DIFFERES_ENDPOINT = "/numeros_differes" @@ -239,7 +240,7 @@ VUE_APP_DATETIMEFORMAT_WS = "YYYY-MM-DD HH:mm:ss" #====================================== #======== VALEURS CONFIG ======== #====================================== -# role id +# role id VUE_APP_ADMIN_ROLE_ID = 1 VUE_APP_RESPONSABLE_ROLE_ID = 2 VUE_APP_SECRETAIRE_ROLE_ID = 3 diff --git a/front/src/components/Affaires/ControleGeometre/controleGeometre.html b/front/src/components/Affaires/ControleGeometre/controleGeometre.html index 3093c052..3f920d64 100644 --- a/front/src/components/Affaires/ControleGeometre/controleGeometre.html +++ b/front/src/components/Affaires/ControleGeometre/controleGeometre.html @@ -19,19 +19,19 @@

Dernier contrôle effectué le {{controleGeometre.date}} par {{controleGeometre.operateur_prenom_nom}}

- +
-
- +
Contrôle juridique
- + @@ -53,7 +53,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -172,13 +172,13 @@ - +
Signature
- +
Aspects juridiques
Factures
@@ -450,7 +450,7 @@
- +
@@ -560,7 +560,7 @@
- +
@@ -637,7 +637,7 @@
- +
@@ -670,7 +670,7 @@
- +
@@ -719,7 +719,7 @@ - + @@ -742,7 +742,7 @@
Prix total ~380.- par PFPPrix total ~460.- par PFP
- +
@@ -791,7 +791,7 @@ - + @@ -814,7 +814,7 @@
Prix total ~300.- par PLPrix total ~365- par PL
- +
@@ -980,7 +980,7 @@
- +
@@ -1090,10 +1090,10 @@ - +
- +
@@ -1106,14 +1106,14 @@ Annuler Enregistrer
-
+
Aucun contrôle
- + diff --git a/front/src/components/Affaires/Facturation/Emoluments/Emoluments.vue b/front/src/components/Affaires/Facturation/Emoluments/Emoluments.vue index dc6919c6..01f584d3 100644 --- a/front/src/components/Affaires/Facturation/Emoluments/Emoluments.vue +++ b/front/src/components/Affaires/Facturation/Emoluments/Emoluments.vue @@ -11,186 +11,73 @@ const moment = require('moment'); export default { name: 'Emoluments', props: { - affaire: {type: Object}, - affaire_factures: {type: Array}, - configFactureTypeID: {type: Object}, - factureTypes: {type: Array}, - numeros_references: {type: Array}, - permission: {type: Object}, - typesAffaires_conf: {type: Object}, + affaire: { type: Object }, + affaire_factures: { type: Array }, + configFactureTypeID: { type: Object }, + factureTypes: { type: Array }, + numeros_references: { type: Array }, + permission: { type: Object }, + typesAffaires_conf: { type: Object }, }, data: function () { - return { - cadastrationFactureNumerosId_old: [], - confirmationRemoveDialog: { - title: "Demande de confirmation", - msg: "Confirmez-vous la suppression de l'émolument?", - confirmBtn: "Confirmer", - cancelBtn: "Annuler", - show: false, - onConfirm: () => {}, - onCancel: () => {}, - }, - disabled: false, - emolument_facture_repartition_ctrl: false, - emolumentsGeneral_list: [], - facture_parametres : { - indice_application: null, - tva_pc: null, - }, - factures_repartition: [], - form_general: {}, //général - showEmolumentsDialog: false, - showProgressBar: false, - total: { - montant_recapitulatif_mandat: 0, - montant_recapitulatif_somme1: 0, - montant_recapitulatif_terrain_materialisation_deplacements: 0, - montant_recapitulatif_somme2: 0, - montant_recapitulatif_bureau: 0, - montant_recapitulatif_somme3: 0, - montant_recapitulatif_indice_application: 0, - montant_recapitulatif_somme4: 0, - montant_recapitulatif_materiel_divers: 0, - montant_recapitulatif_somme5: 0, - montant_recapitulatif_matdiff: 0, - montant_recapitulatif_somme6: 0, - montant_recapitulatif_tva: 0, - montant_recapitulatif_somme7: 0, - montant_recapitulatif_registre_foncier: 0, - montant_recapitulatif_total: 0, - }, - tableauEmolumentsNew: [], - isPageReady: false, - id_matdiff: process.env.VUE_APP_TABLEAUEMOLUMENTS_MATDIFF_ID.split(',').map(Number), - divers_tarif_horaire: [], - divers_tarif_horaire_unit: { - nom: null, - nombre: 1, - montant: null, - prix: 0, - }, - selectedHighlightRow: null, - } + return { + cadastrationFactureNumerosId_old: [], + confirmationRemoveDialog: { + title: "Demande de confirmation", + msg: "Confirmez-vous la suppression de l'émolument?", + confirmBtn: "Confirmer", + cancelBtn: "Annuler", + show: false, + onConfirm: () => { }, + onCancel: () => { }, + }, + disabled: false, + emolument_facture_repartition_ctrl: false, + emolumentsGeneral_list: [], + facture_parametres: { + indice_application: null, + tva_pc: null, + }, + factures_repartition: [], + form_general: {}, //général + showEmolumentsDialog: false, + showProgressBar: false, + total: { + montant_recapitulatif_mandat: 0, + montant_recapitulatif_somme1: 0, + montant_recapitulatif_terrain_materialisation_deplacements: 0, + montant_recapitulatif_somme2: 0, + montant_recapitulatif_bureau: 0, + montant_recapitulatif_somme3: 0, + montant_recapitulatif_indice_application: 0, + montant_recapitulatif_somme4: 0, + montant_recapitulatif_materiel_divers: 0, + montant_recapitulatif_somme5: 0, + montant_recapitulatif_matdiff: 0, + montant_recapitulatif_somme6: 0, + montant_recapitulatif_tva: 0, + montant_recapitulatif_somme7: 0, + montant_recapitulatif_registre_foncier: 0, + montant_recapitulatif_total: 0, + }, + tableauEmolumentsNew: [], + isPageReady: false, + id_matdiff: process.env.VUE_APP_TABLEAUEMOLUMENTS_MATDIFF_ID.split(',').map(Number), + divers_tarif_horaire: [], + divers_tarif_horaire_unit: { + nom: null, + nombre: 1, + montant: null, + prix: 0, + }, + selectedHighlightRow: null, + numeros: [], + numeros_selection: [], + } }, - methods:{ - - /** - * on select BF reference (cadastration) - */ - onSelectBFReferences(items) { - this.form_general.numeros = items; - this.form_general.numeros_id = []; - items.forEach(x => { - this.form_general.numeros_id.push(x.numero_id); - }); - - - // get facture id and check if there are other BF in facture - let factures = []; - let numeros_id = []; - let numeros_id_arr = []; - this.factures_repartition.filter(x => { - if (x.numeros_id.some(y => this.form_general.numeros_id.includes(y))) { - factures.push(x); - numeros_id_arr.push(x.numeros_id); - numeros_id.push(...x.numeros_id); - } - }); - - - // rajouter/retirer les numéros des biens-fonds - let disappear = this.cadastrationFactureNumerosId_old.filter(y => !this.form_general.numeros_id.includes(y)); // left comparison, shows what disappears - if (disappear.length > 0) { - let tmp = []; - numeros_id_arr.filter(y => { - if (!y.includes(disappear[0])) { - tmp.push(...y); - } - }); - - // update form_general.numeros and form_general.numeros_id - this.form_general.numeros = []; - tmp.forEach(y => { - if (this.numeros_references.length > 0) { - this.form_general.numeros.push(this.numeros_references.filter(z => z.numero_id === y)[0]); - } - }); - this.form_general.numeros_id = tmp; - numeros_id = tmp; - - // update factures - factures = factures.filter(y => !y.numeros_id.includes(disappear[0])); - } - - let appear = this.form_general.numeros_id.filter(y => !this.cadastrationFactureNumerosId_old.includes(y)); // left comparison, shows what appears - if (appear.length > 0) { - let tmp = []; - if (this.numeros_references.length > 0) { - numeros_id.forEach(x => tmp.push(this.numeros_references.filter(y => y.numero_id === x)[0])); - } - this.form_general.numeros = tmp; - } - - - // update numeros_id_old - this.cadastrationFactureNumerosId_old = numeros_id; - - - // if only one facture selected, set emolument_repartition 100% automatically - if (factures.length === 1) { - let facture = factures[0]; - - // set facture repartition to 100% - this.factures_repartition.forEach(x => { - if (x.numeros_id === facture.numeros_id) { - x.emolument_repartition = 100; - } else { - x.emolument_repartition = 0; - } - }); - - } else { - // get facture repartitions if existing - let sum_check = 0; - this.factures_repartition.forEach(x => sum_check += x.emolument_repartition); - if (sum_check <= 0){ - // set all facture repartitions to 0, it should be entered manually - this.factures_repartition.forEach(x => x.emolument_repartition = 0); - } - } - - }, - - - - - - - - - - // /** - // * Delete emolument_affaire_repartition - // */ - // async deleteEmolumentAffaireRepartition(emolument_affaire_id) { - // return new Promise ((resolve, reject) => { - // this.$http.delete( - // process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_AFFAIRE_REPARTITION_ENDPOINT + "?emolument_affaire_id=" + emolument_affaire_id, - // { - // withCredentials: true, - // headers: {Accept: "appication/json"} - // } - // ).then(response => resolve(response)) - // .catch(err => reject(err)); - // }); - // }, + methods: { - - - - /** * update emolument_affaire used */ @@ -205,33 +92,35 @@ export default { // NEW EMOLUMENTS // ================================================================================================================================================ // ================================================================================================================================================ - - + + // ================================================================================================================================================ // EMOLUMENT DIALOG // ================================================================================================================================================ async openEmolumentDialog(emolument_affaire_id) { await this.getEmolument(emolument_affaire_id); - this.getEmolumentAffaireRepartition(emolument_affaire_id).then(response => { + await this.getEmolumentAffaireRepartition(emolument_affaire_id).then(response => { if (response && response.data) { this.initFactureRepartition(response.data); this.updateFactureRepartition(); } }).catch(err => handleException(err, this)); - + + this.numeros.sort((a, b) => a.emolument_affaire_id === emolument_affaire_id? -1: b.emolument_affaire_id === emolument_affaire_id? 1: a.emolument_affaire_id - b.emolument_affaire_id); + this.showEmolumentsDialog = true; }, - + /** * Cancel formular edition */ - onCancel() { + async onCancel() { + await this.getEmolumentsGeneral(); this.showEmolumentsDialog = false; - this.getEmolumentsGeneral(); }, - - async initForm(form_general=true) { + + async initForm(form_general = true) { if (form_general) { this.form_general = { @@ -249,12 +138,14 @@ export default { numeros: [], numeros_id: [], utilise: false, - + // Bâtiments batiment_f: [], }; + this.numeros_selection = []; + this.divers_tarif_horaire = []; this.divers_tarif_horaire.push(JSON.parse(JSON.stringify(this.divers_tarif_horaire_unit))); @@ -287,20 +178,20 @@ export default { /** * Remove batiment */ - removeBatiment(batiment_i) { - let tmp = JSON.parse(JSON.stringify(this.tableauEmolumentsNew)); - tmp.forEach(cat => { - cat.forEach(scat => { - scat.forEach(pos => { - pos.nombre.splice(batiment_i, 1); - pos.prix.splice(batiment_i, 1); + removeBatiment(batiment_i) { + let tmp = JSON.parse(JSON.stringify(this.tableauEmolumentsNew)); + tmp.forEach(cat => { + cat.forEach(scat => { + scat.forEach(pos => { + pos.nombre.splice(batiment_i, 1); + pos.prix.splice(batiment_i, 1); }) }) }) - + this.tableauEmolumentsNew = tmp; - - this.form_general.batiment_f.splice(batiment_i-1,1); + + this.form_general.batiment_f.splice(batiment_i - 1, 1); this.form_general.nb_batiments -= 1; this.update_sommesPartielles(); @@ -310,9 +201,9 @@ export default { /** * Update batimentCorrectionFactor */ - updateBatimentCorrectionFactor(idx) { + updateBatimentCorrectionFactor(idx) { let tmp = JSON.parse(JSON.stringify(this.tableauEmolumentsNew)); - tmp.forEach(cat=> { + tmp.forEach(cat => { cat.forEach(scat => { scat.forEach(pos => { this.updateMontant(pos, idx); @@ -334,20 +225,20 @@ export default { process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_AFFAIRE_ENDPOINT + "?affaire_id=" + this.affaire.id, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } } ).then(response => { if (response && response.data) { this.initForm(); this.emolumentsGeneral_list = new Array(response.data.lenght); - for (let j=0; j { + return new Promise((resolve, reject) => { this.$http.post( process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_ENDPOINT, formData, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } } ).then((response) => { if (response && response.data) { @@ -389,18 +280,18 @@ export default { resolve(response); } }) - .catch(err => { - handleException(err, this); - reject(err); - }) - .finally(() => this.showProgressBar = false); + .catch(err => { + handleException(err, this); + reject(err); + }) + .finally(() => this.showProgressBar = false); }); }, /** * fix emolument definitively */ - async fixEmolumentDefinitively(emolument_affaire_id, status=true) { + async fixEmolumentDefinitively(emolument_affaire_id, status = true) { let formData = new FormData(); formData.append("emolument_affaire_id", emolument_affaire_id); formData.append("utilise", status); @@ -410,12 +301,12 @@ export default { formData, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } } - ).then(() => {}) - .catch(err => handleException(err, this)); + ).then(() => { }) + .catch(err => handleException(err, this)); }, - + /** * Get facture parametres @@ -425,15 +316,15 @@ export default { process.env.VUE_APP_API_URL + process.env.VUE_APP_FACTURE_PARAMETRES_ENDPOINT, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } } - ).then(response => { - if(response && response.data) { - this.facture_parametres = response.data.facture_parametres; - this.isPageReady = true; - } - }) - .catch(err => handleException(err, this)); + ).then(response => { + if (response && response.data) { + this.facture_parametres = response.data.facture_parametres; + this.isPageReady = true; + } + }) + .catch(err => handleException(err, this)); }, /** @@ -441,28 +332,29 @@ export default { */ async getTableauEmolumentsNew() { return this.$http.get( - process.env.VUE_APP_API_URL + "/tableau_emoluments_new", + process.env.VUE_APP_API_URL + "/tableau_emoluments_new?affaire_id=" + this.affaire.id, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } } - ).then(response => { - if(response && response.data) { - let tmp = response.data; - tmp.forEach(cat => { - cat.forEach(scat => { - scat.forEach(pos => { - pos.prix = [0]; - pos.nombre = [0]; - }) + ).then(response => { + if (response && response.data) { + this.numeros = response.data.numeros; + let tmp = response.data.emoluments; + tmp.forEach(cat => { + cat.forEach(scat => { + scat.forEach(pos => { + pos.prix = [0]; + pos.nombre = [0]; }) + }) }); this.tableauEmolumentsNew = tmp; } }) - .catch(err => handleException(err, this)); + .catch(err => handleException(err, this)); }, /** @@ -473,47 +365,58 @@ export default { process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_ENDPOINT + '?emolument_affaire_id=' + emolument_affaire_id, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } + } + ).then(response => { + if (response && response.data) { + + this.form_general = JSON.parse(response.data.form_general); + this.tableauEmolumentsNew = JSON.parse(response.data.emoluments); + this.divers_tarif_horaire = JSON.parse(response.data.divers_tarifhoraire); + this.numeros = JSON.parse(response.data.numeros); + + this.numeros_selection = this.numeros.filter(x => x.emolument_affaire_id === this.form_general.id); + + this.disabled = this.form_general.utilise; + + this.initFactureRepartition(response.data); + this.updateFactureRepartition(); + + this.update_sommesPartielles(); } - ).then(response => { - if (response && response.data) { - - this.form_general = JSON.parse(response.data.form_general); - this.tableauEmolumentsNew = JSON.parse(response.data.emoluments); - this.divers_tarif_horaire = JSON.parse(response.data.divers_tarifhoraire); - - this.disabled = this.form_general.utilise; - - this.initFactureRepartition(response.data); - this.updateFactureRepartition(); - - this.update_sommesPartielles(); - } }) - .catch(err => handleException(err, this)); + .catch(err => handleException(err, this)); }, confirmDelete(emolument_affaire_id) { - this.confirmationRemoveDialog.show = true; - this.confirmationRemoveDialog.onConfirm = () => this.deleteEmolument(emolument_affaire_id); + this.confirmationRemoveDialog = { + title: "Demande de confirmation", + msg: "Confirmez-vous la suppression de l'émolument?", + confirmBtn: "Confirmer", + cancelBtn: "Annuler", + show: true, + onConfirm: () => this.deleteEmolument(emolument_affaire_id), + onCancel: () => { }, + } }, async deleteEmolument(emolument_affaire_id) { return this.$http.delete( - process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_ENDPOINT + '?emolument_affaire_id=' + emolument_affaire_id, - { - withCredentials: true, - headers: {"Accept": "application/json"} - } - ).then(response => { - if (response && response.data) { - this.getEmolumentsGeneral(); - this.showEmolumentsDialog = false; - } - }) + process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_ENDPOINT + '?emolument_affaire_id=' + emolument_affaire_id, + { + withCredentials: true, + headers: { "Accept": "application/json" } + } + ).then(response => { + if (response && response.data) { + this.getEmolumentsGeneral(); + this.$root.$emit("searchAffaireFactures"); + this.showEmolumentsDialog = false; + } + }) .catch(err => handleException(err, this)); }, - + async handleUpdateEmolument(position, idx) { this.updateMontant(position, idx); await this.automaticUpdateNombres(position); @@ -529,7 +432,7 @@ export default { */ initFactureRepartition(emolument_facture_repartition) { this.factures_repartition = JSON.parse(JSON.stringify(this.affaire_factures)); - + if (emolument_facture_repartition.length > 0) { // Il existe une/des relations entre l'émolument et les factures this.factures_repartition.forEach(x => { @@ -564,7 +467,7 @@ export default { if (Math.abs(somme - 100) >= 0.011) { this.emolument_facture_repartition_ctrl = true; - } else { + } else { this.emolument_facture_repartition_ctrl = false; somme_ = somme } @@ -600,12 +503,12 @@ export default { promises.push(this.putFacture(x)); } }); - + let successMessage = "La facture a été mise à jour avec succès." if (promises.length > 1) { successMessage = "Les factures ont été mises à jour avec succès." } - + Promise.all(promises).then(() => { this.showEmolumentsDialog = false; this.fixEmolumentDefinitively(this.form_general.id, true); @@ -621,7 +524,7 @@ export default { * put facture */ async putFacture(facture_data) { - return new Promise ((resolve, reject) => { + return new Promise((resolve, reject) => { let montant_tva = this.round(Number(facture_data.montant_mo) * Number(this.form_general.tva_pc) / 100, 0.05) + this.round(Number(facture_data.montant_mat_diff) * Number(this.form_general.tva_pc) / 100, 0.05) let montant_total = this.round(Number(facture_data.montant_mo) + Number(facture_data.montant_mat_diff) + Number(facture_data.montant_rf) + Number(montant_tva), 0.05) @@ -640,10 +543,10 @@ export default { formData, { withCredentials: true, - headers: {"Accept": "application/json"} + headers: { "Accept": "application/json" } } ).then(response => resolve(response)) - .catch(err => reject(err)); + .catch(err => reject(err)); }); }, @@ -671,17 +574,17 @@ export default { * get emolument_affaire_repartition */ async getEmolumentAffaireRepartition(emolument_affaire_id) { - return new Promise ((resolve, reject) => { + return new Promise((resolve, reject) => { this.$http.get( process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_AFFAIRE_REPARTITION_ENDPOINT + "?emolument_affaire_id=" + emolument_affaire_id, { withCredentials: true, - headers: {Accept: "appication/json"} + headers: { Accept: "appication/json" } } - ).then(response => resolve(response)) + ).then(response => resolve(response)) .catch(err => reject(err)); - }); - }, + }); + }, /** * save emolument_affaire_repartition @@ -690,19 +593,19 @@ export default { let formData = new FormData(); formData.append("emolument_affaire_id", emolument_affaire_id); formData.append("emolument_facture_repartition", JSON.stringify(this.factures_repartition)); - + return new Promise((resolve, reject) => { this.$http.post( process.env.VUE_APP_API_URL + process.env.VUE_APP_EMOLUMENT_AFFAIRE_REPARTITION_ENDPOINT, formData, { withCredentials: true, - headers: {Accept: "appication/json"} + headers: { Accept: "appication/json" } } - ).then((response) => resolve(response)) + ).then((response) => resolve(response)) .catch(err => reject(err)); - }); - }, + }); + }, // ================================================================================================== // DOWNLOAD EMOLUMENT AS PDF @@ -727,8 +630,8 @@ export default { tableau_emoluments_html = tableau_emoluments_html.replaceAll(/<\/div>CHF/g, "CHF"); tableau_emoluments_html = tableau_emoluments_html.replaceAll('
CHF
', '
'); tableau_emoluments_html = tableau_emoluments_html.replaceAll('Nombre', 'Qté'); - - + + // tableau recapitulatif let tableau_recapitulatif_html = JSON.parse(JSON.stringify(document.getElementById("tableau_recapitulatif_form").outerHTML)); inputs = tableau_recapitulatif_html.matchAll(/(md-input-)\w+/g); @@ -736,30 +639,30 @@ export default { tableau_recapitulatif_html = tableau_recapitulatif_html.replaceAll(new RegExp(``, 'g'), '
' + document.getElementById(input[0]).value + '
'); } tableau_recapitulatif_html = tableau_recapitulatif_html.replaceAll(/<\/div>%/g, " %"); - + let formData = new FormData(); formData.append('tableau_emoluments_id', this.form_general.id); formData.append('affaire_id', this.affaire.id); formData.append('tableau_emoluments_html', tableau_emoluments_html); formData.append('tableau_recapitulatif_html', tableau_recapitulatif_html); - + this.$http.post( process.env.VUE_APP_API_URL + process.env.VUE_APP_EXPORT_EMOLUMENTS_PDF_ENDPOINT, formData, { withCredentials: true, - headers: {"Accept": "application/json"}, + headers: { "Accept": "application/json" }, responseType: "blob" } - ).then((response) => { + ).then((response) => { let fileURL = window.URL.createObjectURL(new Blob([response.data])); let fileLink = document.createElement('a'); fileLink.href = fileURL; let header_content_type = response.headers['content-type']; let filename = undefined; - for (let item of header_content_type.split(';')){ - item = item.trim(); + for (let item of header_content_type.split(';')) { + item = item.trim(); if (item.startsWith('filename=')) { filename = item.replace('filename=', '').replaceAll('"', ''); break @@ -772,15 +675,15 @@ export default { handleException(err, this); }); }, - - // ================================================================================================== - // UTILS - // ================================================================================================== - /** - * Round numbers - */ - round(num, multiple=0.1) { + + // ================================================================================================== + // UTILS + // ================================================================================================== + /** + * Round numbers + */ + round(num, multiple = 0.1) { num = Number(num); multiple = Number(multiple); return Math.round(num / multiple) * multiple; @@ -789,7 +692,7 @@ export default { updateMontant(position, idx) { let f = 1; if (idx > 0) { - f = Number(this.form_general.batiment_f[idx-1]); + f = Number(this.form_general.batiment_f[idx - 1]); } position.prix[idx] = this.round(f * Number(position.nombre[idx]) * Number(position.montant), 0.05); return; @@ -805,8 +708,8 @@ export default { base = pos.calcul_auto.split('+'); base_second.filter(x => x !== pos.id_html); if (base.includes(current_position.id_html) || base_second.some(x => base.includes(x))) { - for (let i=0; i partialSum + a.reduce((partialSum, a) => partialSum + a.reduce((partialSum, a) => partialSum + (base.includes(a.id_html)? Number(a.nombre[i]): 0), 0), 0), 0); + for (let i = 0; i < this.form_general.nb_batiments + 1; i++) { + pos.nombre[i] = this.tableauEmolumentsNew.reduce((partialSum, a) => partialSum + a.reduce((partialSum, a) => partialSum + a.reduce((partialSum, a) => partialSum + (base.includes(a.id_html) ? Number(a.nombre[i]) : 0), 0), 0), 0); base_second.push(pos.id_html); this.updateMontant(pos, i); } @@ -889,11 +792,11 @@ export default { this.total.montant_recapitulatif_somme1 = this.total.montant_recapitulatif_mandat; this.total.montant_recapitulatif_somme2 = this.total.montant_recapitulatif_somme1 + this.total.montant_recapitulatif_terrain_materialisation_deplacements; this.total.montant_recapitulatif_somme3 = this.total.montant_recapitulatif_somme2 + this.total.montant_recapitulatif_bureau; - this.total.montant_recapitulatif_indice_application = this.round(this.total.montant_recapitulatif_somme3 * (this.form_general.indice_application-1), 0.05); + this.total.montant_recapitulatif_indice_application = this.round(this.total.montant_recapitulatif_somme3 * (this.form_general.indice_application - 1), 0.05); this.total.montant_recapitulatif_somme4 = this.total.montant_recapitulatif_somme3 + this.total.montant_recapitulatif_indice_application; this.total.montant_recapitulatif_somme5 = this.total.montant_recapitulatif_somme4 + this.total.montant_recapitulatif_materiel_divers; this.total.montant_recapitulatif_somme6 = this.total.montant_recapitulatif_somme5 + this.total.montant_recapitulatif_matdiff; - this.total.montant_recapitulatif_tva = this.round(this.total.montant_recapitulatif_somme6 * this.form_general.tva_pc/100, 0.05); + this.total.montant_recapitulatif_tva = this.round(this.total.montant_recapitulatif_somme6 * this.form_general.tva_pc / 100, 0.05); this.total.montant_recapitulatif_somme7 = this.total.montant_recapitulatif_somme6 + this.total.montant_recapitulatif_tva; this.total.montant_recapitulatif_total = this.total.montant_recapitulatif_somme7 + this.total.montant_recapitulatif_registre_foncier; @@ -935,28 +838,37 @@ export default { this.tableauEmolumentsNew.forEach(cat => { cat.forEach(scat => { scat.forEach(pos => { - if (pos.id === this.id_matdiff[0]) {pos.nombre[0] = tmp_5; this.updateMontant(pos, 0)} - if (pos.id === this.id_matdiff[1]) {pos.nombre[0] = tmp_10; this.updateMontant(pos, 0)} - if (pos.id === this.id_matdiff[2]) {pos.nombre[0] = tmp_15; this.updateMontant(pos, 0)} - if (pos.id === this.id_matdiff[3]) {pos.nombre[0] = tmp_gt15; this.updateMontant(pos, 0)} + if (pos.id === this.id_matdiff[0]) { pos.nombre[0] = tmp_5; this.updateMontant(pos, 0) } + if (pos.id === this.id_matdiff[1]) { pos.nombre[0] = tmp_10; this.updateMontant(pos, 0) } + if (pos.id === this.id_matdiff[2]) { pos.nombre[0] = tmp_15; this.updateMontant(pos, 0) } + if (pos.id === this.id_matdiff[3]) { pos.nombre[0] = tmp_gt15; this.updateMontant(pos, 0) } }) }) }); } }, - highlithtSelectedRow(position_id) { this.selectedHighlightRow = position_id; - } + }, + + /** + * on select BF reference (cadastration) + */ + onSelectBFReferences(items) { + let numeros_id = []; + items.forEach(x => numeros_id.push(x.numero_id)); + + this.form_general.numeros_id = numeros_id; + }, }, - mounted: function(){ + mounted: function () { this.getEmolumentsGeneral(); this.getTableauEmolumentsNew(); this.getFactureParametres(); - this.addDivers(); + this.addDivers(); this.$root.$on("getEmolumentsGeneral", () => this.getEmolumentsGeneral()); } diff --git a/front/src/components/Affaires/Facturation/Emoluments/emoluments.css b/front/src/components/Affaires/Facturation/Emoluments/emoluments.css index 5d63f391..007ccce8 100644 --- a/front/src/components/Affaires/Facturation/Emoluments/emoluments.css +++ b/front/src/components/Affaires/Facturation/Emoluments/emoluments.css @@ -207,3 +207,8 @@ #tableau_emoluments tr:hover, .selected { background-color: #FFCF8B; } + +#emolumentsDialog .bfInOtherAffaire { + color: lightgrey; + font-style: italic; +} diff --git a/front/src/components/Affaires/Facturation/Emoluments/emoluments.html b/front/src/components/Affaires/Facturation/Emoluments/emoluments.html index 46e762ef..08e89b8b 100644 --- a/front/src/components/Affaires/Facturation/Emoluments/emoluments.html +++ b/front/src/components/Affaires/Facturation/Emoluments/emoluments.html @@ -1,393 +1,385 @@ -
- - - -
Émoluments (id: {{ form_general.id }})
-
- {{ form_general.utilise===true? 'lock': 'lock_open' }} - file_download Télécharger le PDF - delete Supprimer -
-
- - - - - -
-
- - - - {{ item.nom }} - - - -
- -

Bâtiments

-
- - - - - - - - - - - - - - - - - - - -
- warning - Indiquer les surfaces des bâtiments dans l'ordre du plus grand au plus petit. -
BâtimentFacteur correctif
{{ i }} - - - 1.5 (>1000m2) - 1.4 (751-1000m2) - 1.3 (501-750m2) - 1.2 (401-500m2) - 1.1 (301-400m2) - 1.0 (251-300m2) - 0.9 (201-250m2) - 0.8 (151-200m2) - 0.7 (101-150m2) - 0.6 (51-100m2) - 0.5 (1-50m2) - - - - delete -
Ajouter un bâtiment add
-
- -
-

Bien-fonds

- - - - {{ item.numero_cadastre }} - {{ item.numero }} - - -
+
+ + + +
Émoluments (id: {{ form_general.id }})
+
+ {{ form_general.utilise===true? 'lock': 'lock_open' }} + file_download Télécharger le PDF + delete Supprimer +
+
+ + + + + +
+
+ + + + {{ item.nom }} + + + +
+ +

Bâtiments

+ + + + + + + + + + + + + + + + + + + + +
+ warning + Indiquer les surfaces des bâtiments dans l'ordre du plus grand au plus petit. +
BâtimentFacteur correctif
{{ i }} + + + 1.5 (>1000m2) + 1.4 (751-1000m2) + 1.3 (501-750m2) + 1.2 (401-500m2) + 1.1 (301-400m2) + 1.0 (251-300m2) + 0.9 (201-250m2) + 0.8 (151-200m2) + 0.7 (101-150m2) + 0.6 (51-100m2) + 0.5 (1-50m2) + + + + delete +
Ajouter un bâtiment add
- - -
-

Répartition des émoluments dans les factures

-
- Vérifier la répartition dans les factures, dont le total ne vaut pas 100%.
- Si les parts impliquent des nombres à virgule, écrire une approximation à 2 chiffres après la virgule (33.33% et 66.66% par exemple). -
+
+

Bien-fonds

- - - - {{ item.adresse_facturation_ }} - {{ item.numeros.join(", ") }} - {{ item.montant_mo }} CHF - {{ item.montant_mat_diff }} CHF - {{ item.montant_rf }} CHF - {{ item.montant_tva }} CHF - {{ item.montant_total }} CHF - {{ item.remarque? item.remarque: "—" }} - - - - % - - + + + {{ item.cadastre }} + {{ item.numero }} + {{ item.emolument_affaire_id }} +
+
-
- Transférer les montants vers les factures (secrétariat) -
+ + +
+

Répartition des émoluments dans les factures

+
+ Vérifier la répartition dans les factures, dont le total ne vaut pas 100%.
+ Si les parts impliquent des nombres à virgule, écrire une approximation à 2 chiffres après la virgule (33.33% et 66.66% par exemple). +
+ + + + + {{ item.adresse_facturation_ }} + {{ item.numeros.join(", ") }} + {{ item.montant_mo }} CHF + {{ item.montant_mat_diff }} CHF + {{ item.montant_rf }} CHF + {{ item.montant_tva }} CHF + {{ item.montant_total }} CHF + {{ item.remarque? item.remarque: "—" }} + + + + % + + + + + +
+ Transférer les montants vers les factures (secrétariat)
- +
+ - - - - - + + +
+ +