Skip to content

Commit

Permalink
Merge pull request #748 from rufener/facture
Browse files Browse the repository at this point in the history
Bugfix facture
  • Loading branch information
rufener authored Nov 27, 2023
2 parents e0dcbd1 + c99b7e2 commit e835407
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 9 deletions.
34 changes: 34 additions & 0 deletions back/infolica/alembic/versions/20231127_743ef3c2c7ff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""add facture_parametres
Revision ID: 743ef3c2c7ff
Revises: 3a451b565980
Create Date: 2023-11-27 11:17:20.125711
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '743ef3c2c7ff'
down_revision = '3a451b565980'
branch_labels = None
depends_on = None

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('facture_parametres',
sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column('nom', sa.Text(), nullable=False),
sa.Column('valeur', sa.Float(), nullable=False),
sa.Column('valable_de', sa.Date(), nullable=False),
sa.Column('valable_a', sa.Date(), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_facture_parametres')),
schema='infolica'
)
# ### end Alembic commands ###

def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('facture_parametres', schema='infolica')
# ### end Alembic commands ###
10 changes: 10 additions & 0 deletions back/infolica/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ class FactureType(Base):
nom = Column(Text, nullable=False)


class FactureParametres(Base):
__tablename__ = 'facture_parametres'
__table_args__ = {'schema': 'infolica'}
id = Column(BigInteger, primary_key=True, autoincrement=True)
nom = Column(Text, nullable=False)
valeur = Column(Float, nullable=False)
valable_de = Column(Date, nullable=False)
valable_a = Column(Date, nullable=True)


class Facture(Base):
__tablename__ = 'facture'
__table_args__ = {'schema': 'infolica'}
Expand Down
1 change: 1 addition & 0 deletions back/infolica/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def includeme(config):
config.add_route('emolument_affaire', '/infolica/api/emolument_affaire')
config.add_route('emolument', '/infolica/api/emolument')
config.add_route('emolument_affaire_repartiton', '/infolica/api/emolument_affaire_repartiton')
config.add_route('facture_parametres', '/infolica/api/facture_parametres')
#Login
config.add_route('login', '/infolica/api/login')
config.add_route('login_s', '/infolica/api/login/')
Expand Down
25 changes: 24 additions & 1 deletion back/infolica/views/facture_emolument.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from infolica.exceptions.custom_error import CustomError
from infolica.models.constant import Constant
from infolica.models.models import Facture, Numero, TableauEmoluments, VAffaire, VNumerosAffaires
from infolica.models.models import EmolumentAffaire, Emolument, EmolumentAffaireRepartition
from infolica.models.models import EmolumentAffaire, Emolument, EmolumentAffaireRepartition, FactureParametres
from infolica.scripts.utils import Utils
from infolica.scripts.authentication import check_connected
import json
Expand All @@ -20,6 +20,29 @@
###########################################################


@view_config(route_name='facture_parametres', request_method='GET', renderer='json')
def tableau_facture_parametres_view(request):
"""
Return actual parameters and values
"""
# Check connected
if not check_connected(request):
raise exc.HTTPForbidden()

today = datetime.date.today()
results = request.dbsession.query(FactureParametres).filter(
FactureParametres.valable_de <= today,
FactureParametres.valable_a >= today,
).all()

params = {}
for result in results:
if not result.nom in params.keys():
params[result.nom] = result.valeur

return { 'facture_parametres': params }


@view_config(route_name='tableau_emoluments', request_method='GET', renderer='json')
def tableau_emoluments_view(request):
"""
Expand Down
3 changes: 2 additions & 1 deletion front/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VUE_APP_API_URL="{API_URL}"

PUBLIC_PATH = "{PUBLIC_PATH}"
VUE_APP_STATUS = "development"
VUE_APP_VERSION = "1.10.6"
VUE_APP_VERSION = "1.10.7"


#==================================
Expand Down Expand Up @@ -141,6 +141,7 @@ VUE_APP_EMOLUMENT_ENDPOINT = "/emolument"
VUE_APP_EMOLUMENT_AFFAIRE_FREEZE_ENDPOINT = "/emolument_affaire_freeze"
VUE_APP_EMOLUMENT_AFFAIRE_REPARTITION_ENDPOINT = "/emolument_affaire_repartiton"
VUE_APP_EXPORT_EMOLUMENTS_PDF_ENDPOINT = "/export_emoluments_pdf"
VUE_APP_FACTURE_PARAMETRES_ENDPOINT = "/facture_parametres"

#Etapes de l'affaire
VUE_APP_ETAPES_INDEX_ENDPOINT = "/etapes_index/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default {
emolumentsGeneral_list: [],
emolument_priorite: true,
emolumentsUnits: [],
facture_parametres : {
indice_application: null,
tva_pc: null,
},
factures_repartition: [],
form_general: {}, //général
form_detail: {}, //emoluments sans bâtiment
Expand All @@ -59,6 +63,7 @@ export default {
relations_autres_services: 102,
forfait_rf: 103
},
isPageReady: false,
// ####################################################################################
// SI LE TABLEAU DES EMOLUMENTS EST MODIFIE, APPORTER LES MODIFICATIONS ICI ! STOP
// ####################################################################################
Expand Down Expand Up @@ -289,7 +294,7 @@ export default {
initForm(form_general=true) {
if (form_general) {
this.form_general = {
id: null,
Expand All @@ -299,8 +304,8 @@ export default {
trafic_pc: 0,
zi: 1,
nb_batiments: 0,
indice_application: 1.23,
tva_pc: 7.7, // %
indice_application: this.facture_parametres.indice_application,
tva_pc: this.facture_parametres.tva_pc, // %
remarque: "",
facture_type_id: 1,
numeros: [],
Expand Down Expand Up @@ -1357,8 +1362,13 @@ export default {
});
} else {
// set all facture repartitions to 0, it should be entered manually
this.factures_repartition.forEach(x => x.emolument_repartition = 0);
// 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);
}
}
},
Expand Down Expand Up @@ -1738,11 +1748,31 @@ export default {
});
}
}, 100);
}
},
/**
* Get facture parametres
*/
async getFactureParametres() {
this.$http.get(
process.env.VUE_APP_API_URL + process.env.VUE_APP_FACTURE_PARAMETRES_ENDPOINT,
{
withCredentials: true,
headers: {"Accept": "application/json"}
}
).then(response => {
if(response && response.data) {
this.facture_parametres = response.data.facture_parametres;
this.isPageReady = true;
}
})
.catch(err => handleException(this, err));
}
},
mounted: function(){
this.getFactureParametres();
this.getEmolumentsUnit().then(() => {
this.getEmolumentsGeneral();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="emoluments" v-if="emolumentsUnits.length > 0 && Object.keys(form_detail).length > 0">
<div class="emoluments" v-if="isPageReady && emolumentsUnits.length > 0 && Object.keys(form_detail).length > 0">

<md-dialog id="emolumentsDialog" :md-active.sync="showEmolumentsDialog" :md-click-outside-to-close="false" :md-close-on-esc="false">
<md-dialog-title class="justifyTitleBtn">
Expand Down

0 comments on commit e835407

Please sign in to comment.