Skip to content

Commit

Permalink
Merge pull request #719 from rufener/rp
Browse files Browse the repository at this point in the history
Rp
  • Loading branch information
rufener authored Mar 2, 2023
2 parents 309eb5e + e3a64b6 commit 4393a9e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 31 deletions.
72 changes: 45 additions & 27 deletions back/infolica/views/numero.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,17 +633,18 @@ def numero_differe_delete_view(request):
#####################################


def __getNumberId(request, numero, cadastre_id):
numero_id = request.dbsession.query(
Numero.id
def _getNumberId(request, numero, cadastre_id):
numero = request.dbsession.query(
Numero.id,
Numero.type_id
).filter(
Numero.cadastre_id == cadastre_id,
Numero.numero == numero
).first()
return numero_id[0] if numero_id is not None else None
return (numero.id, numero.type_id) if numero is not None else (None, None)


def __getCadastre(request, cadastre_id):
def _getCadastre(request, cadastre_id):
cadastre = request.dbsession.query(
Cadastre.nom
).filter(
Expand All @@ -652,7 +653,7 @@ def __getCadastre(request, cadastre_id):
return cadastre[0] if cadastre is not None else None


def __getAffairesIdFromNumeroId(request, numero_id, numero_type_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(
Expand Down Expand Up @@ -682,6 +683,7 @@ def loadfile_bf_rp(request):

temporary_directory = request.registry.settings['temporary_directory']
affaire_numero_type_nouveau_id = request.registry.settings['affaire_numero_type_nouveau_id']
numero_ddp_id = int(request.registry.settings['numero_ddp_id'])
file_path = os.path.join(temporary_directory, file.filename)

if os.path.exists(file_path):
Expand All @@ -691,15 +693,16 @@ def loadfile_bf_rp(request):
shutil.copyfileobj(file.file, output_file)

wb = openpyxl.load_workbook(file_path)
data = []

numero_query = request.dbsession.query(Numero)

# =============================
# Let's focus on Infolica sheet
# =============================
sheet = 'Infolica'
ws = wb[sheet]

data = []

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))

Expand All @@ -720,10 +723,7 @@ def loadfile_bf_rp(request):
numero_id = ws.cell(row=row_i, column=1).value

if numero_id is not None:

if sheet == 'Infolica':
data_id.append(numero_id)

data_id.append(numero_id)
row_i += 1

else:
Expand All @@ -733,18 +733,31 @@ def loadfile_bf_rp(request):

tmp = []
for result in results: # parcourir les cadastres
tmp.append({
'cadastre': result[3],
'cadastre_id': result[1],
'liste_numeros': [{

liste_numeros = []
for i, numero_ in enumerate(result[2]):
num = numero_query.filter(Numero.id == result[0][i]).first()

error = False
font_color = 'black'
if num is not None and num.type_id == numero_ddp_id:
error = True
font_color = 'blue'

liste_numeros.append({
'numero_id': result[0][i],
'cadastre_id': result[1],
'numero': numero_,
'numero': str(numero_) if error is False else 'DDP ' + str(numero_),
'cadastre': result[3],
'sheet': sheet,
'font-color': 'black',
'reservation_autre_affaire': False,
} for i, numero_ in enumerate(result[2])]
'font_color': font_color,
'error': error,
})

tmp.append({
'cadastre': result[3],
'cadastre_id': result[1],
'liste_numeros': liste_numeros
})

data.append({
Expand All @@ -759,7 +772,6 @@ def loadfile_bf_rp(request):
# ===========================
sheet = 'Terris'
ws = wb[sheet]

tmp = []

row_i = 2
Expand All @@ -770,21 +782,27 @@ def loadfile_bf_rp(request):
if cadastre_id is not None:
numero = re.split('\D', str(ws.cell(row=row_i, column=3).value))[0]

numero_id = __getNumberId(request, numero, cadastre_id)
numero_id, numero_type_id = _getNumberId(request, numero, cadastre_id)
affaires_id = []
if numero_id is not None:
affaires_id = __getAffairesIdFromNumeroId(request, numero_id, numero_type_id=affaire_numero_type_nouveau_id)
affaires_id = _getAffairesIdFromNumeroId(request, numero_id, numero_type_id=affaire_numero_type_nouveau_id)

cadastre = __getCadastre(request, cadastre_id)
cadastre = _getCadastre(request, cadastre_id)

reservation_autre_affaire = False
# errors
error = False
font_color = 'red'
if affaire_id in (affaires_id):
font_color = 'green'
elif len(affaires_id) > 0:
numero = numero + (" [affaire(s): " + ', '.join(affaires_id) + "]" if len(affaires_id) > 0 else "")
font_color = 'blue'
reservation_autre_affaire = True
error = True

if numero_type_id == numero_ddp_id:
numero = 'DDP ' + numero
font_color = 'blue'
error = True


numero_ = {
Expand All @@ -794,7 +812,7 @@ def loadfile_bf_rp(request):
'cadastre': cadastre,
'sheet': sheet,
'font_color': font_color,
'reservation_autre_affaire': reservation_autre_affaire
'error': error
}

cadastre_id_already_exists = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
clientTypes_conf: {type: Object},
permission: {type: Object},
etapes_affaire_conf: {type: Object},
affaireDashboardLayout: {type: Object},
},
components: {},
data() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</div>
</div>

<div id="clients" v-if="affaire.type_id !== typesAffaires_conf.cadastration">
<div id="clients" v-if="affaireDashboardLayout.section_facture && affaire.type_id !== typesAffaires_conf.cadastration">
<div v-if="infoGenReadonly">
<!-- Clients (read-only) -->
<div class="md-layout md-gutter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ export default {
// parcourir liste_numeros
content += sep + "<span style='color: " + z.font_color + ";'>" + z.numero + "</span>";
sep = ', ';
if (allowConfirm && z.reservation_autre_affaire) {
if (allowConfirm && z.error) {
allowConfirm = false;
}
});
Expand All @@ -821,7 +821,7 @@ export default {
onConfirm: () => { this.saveNumerosFromExcel_remaniementParcellaire(response.data) }
};
} else {
content += "<p style='font-weight: bold; color: blue;'>Les numéros réservés dans une autre affaire doivent être manuellement supprimés dans le fichier Excel afin de valider le processus.</p>";
content += "<p style='font-weight: bold; color: blue;'>Les numéros réservés dans une autre affaire ou les DDP doivent être manuellement supprimés dans le fichier Excel afin de valider le processus.</p>";
this.alertDialog= {
show: true,
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/Affaires/affairesDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1 style="margin-bottom: 0px;">
<div class="affaireDashboardContent">
<!-- INFORMATIONS GENERALES -->
<div class="leftColumn">
<InfosGenerales @modify-off="modifyOff" :affaire="affaire" :typesAffaires_conf="typesAffaires_conf" :clientTypes_conf="clientTypes_conf" :permission="permission" :etapes_affaire_conf="etapes_affaire_conf" />
<InfosGenerales @modify-off="modifyOff" :affaire="affaire" :typesAffaires_conf="typesAffaires_conf" :clientTypes_conf="clientTypes_conf" :permission="permission" :etapes_affaire_conf="etapes_affaire_conf" :affaireDashboardLayout="affaireDashboardLayout" />
</div>

<!-- MAP -->
Expand Down

0 comments on commit 4393a9e

Please sign in to comment.