# Version 4

##### Modification de F\_HISTOCLOT

Avant

```
si (CONSTANTE(GENERAL.BUDGET)=1)
alors (histocumuljoint(alias))
sinon (
        si ([PLAFONDSECU.NUMCAS]=1)
        alors (
               si ((moisdeb=0) ou (anneedeb=0))
               alors (histocumuljointbyanclot(alias))
               sinon (histocumuljointbyanclot(alias;moisdeb;anneedeb))
              )
        sinon (
              histocumuljointbyanclot(alias;1;CONSTANTE(CONTRAT.ANNEE_CLOTURE);12;CONSTANTE(GENERAL.ANNEE_PAYE))

              )
        )

```

Problème de calcul de csg pour un bulletin de régul portant sur un contrat alors qu'il y en a d'autres avant : Cas du mat 807  ADSEA15

Le problème est que dans le cas 2, le mot cle histocumuljointbyanclot va chercher le cumul de l'historique depuis l'année de clôture

donc si la clôture est en 2023, on aura 2023 et 2024 ce qui n'est pas correct

Mais si on ne laisse que 2023, on aura pas les régul de bulletin de 2024

Pour le moment on change comme cela :

Après

```
si (CONSTANTE(GENERAL.BUDGET)=1)
alors (histocumuljoint(alias))
sinon (
        si ([PLAFONDSECU.NUMCAS]=1)
        alors (
               si ((moisdeb=0) ou (anneedeb=0))
               alors (histocumuljointbyanclot(alias))
               sinon (histocumuljointbyanclot(alias;moisdeb;anneedeb))
              )
        sinon (
              histocumuljointbyanclot(alias;1;CONSTANTE(CONTRAT.ANNEE_CLOTURE);12;CONSTANTE(CONTRAT.ANNEE_CLOTURE))

              )
        )

```

Pour la CSG

Le pb est que les rubriques non abattue et tout ca n'existait pas en 2020

Du coup \[V\_CSG.CUM\_ABT\] + \[V\_CSG.CUM\_NABT\] = 0

Il faudrait faire un tes sur la date

```
si ((CONSTANTE(CONTRAT.PAS_RESIDENTETRANGER)=1) et (CONSTANTE(CONTRAT.PAS_ACTIF)=0))
alors (0)
sinon (
si ((CONSTANTE(GENERAL.NEWCSG)=1) ou (CONSTANTE(GENERAL.ANNEE_PAYE)>2024)
   ou ((CONSTANTE(GENERAL.ANNEE_PAYE)=2024) et ([PLAFONDSECU.NUMCAS]=1))
    )
alors (
      si ((CONSTANTE(CONTRAT.NATURECONTRAT)=0008) et ([FO.TOTAL]<>0))
      alors ([FO.TOTAL])
      sinon (
            si (([PLAFONDSECU.NUMCAS]=2) et (CONSTANTE(CONTRAT.ANNEE_CLOTURE)<=2023))
            alors (F_TESTCSG([B_COT_CSG.MONTANT];[BC_CSG.MONTANT]))
            sinon (
                  [V_CSG.CUM_ABT]
                  +[V_CSG.CUM_NABT]
                  -F_HISTOCLOT([BC_CSG.MONTANT])
                  )
            )
      )
sinon (
      si (CONSTANTE(CONTRAT.NATURECONTRAT)=0008)
      alors (
            si ([FO.TOTAL]<>0)
            alors ([FO.TOTAL])
            sinon (F_TESTCSG([B_COT_CSG.MONTANT];[BC_CSG.MONTANT]))
            )
      sinon (
            si (CONSTANTE(CONTRAT.DSNNATURE)=29)
            alors (F_TESTCSG([BC_BRUT_STA.MONTANT]*0.9825;[BC_CSG.MONTANT]))
            sinon (F_TESTCSG([B_COT_CSG.MONTANT];[BC_CSG.MONTANT]))
            )
      )
)
```

<span style="text-decoration: line-through;">V\_NEWAGCP.CUMREMUCOEF</span>

<span style="text-decoration: line-through;">Avant</span>

```
[V_NEWAGCP.REMUCOEF]
+
si (
   ([PLAFONDSECU.NUMCAS]=1)
   et ((CONSTANTE(GENERAL.ANNEE_PAYE)>=2024) ou (CONSTANTE(GENERAL.AGCP_AD)=1))
   )
alors (
      F_AGCP([V_NEWAGCP.REMUCOEF];[AGCPDEBUT.MONTANT])
      )
sinon (
      F_AGCP([V_AGCP.REMUCOEF];[AGCPDEBUT.MONTANT])
      )
```

<span style="text-decoration: line-through;">Après</span>

```
[V_NEWAGCP.REMUCOEF]
+
F_AGCP([V_NEWAGCP.REMUCOEF];[AGCPDEBUT.MONTANT])

```

<span style="text-decoration: line-through;">V\_NEWAGCP.CUMSMICPRO</span>

<span style="text-decoration: line-through;">Avant</span>

```
si (CONSTANTE(GENERAL.SMICAGCP)=0)
alors (
      [V_NEWAGCP.SMICPRO]+
      si (
         ([PLAFONDSECU.NUMCAS]=1)
         et ((CONSTANTE(GENERAL.ANNEE_PAYE)>=2024) ou (CONSTANTE(GENERAL.AGCP_AD)=1))
         )
      alors (
            F_AGCP([V_NEWAGCP.SMICPRO];[AGCPDEBUT.MONTANT])
            )
      sinon (
            F_AGCP([V_AGCP.SMICPRORATE];[AGCPDEBUT.MONTANT])
            )
      )
sinon ([V_NEWAGCP.TOTSMICPRO])
```

<span style="text-decoration: line-through;">Après</span>

```
F_AGCP([V_NEWAGCP.SMICPRO];[AGCPDEBUT.MONTANT])
```