Skip to content
Snippets Groups Projects
Commit fa059da1 authored by Loïc Poullain's avatar Loïc Poullain
Browse files

[DF] Mention ecretement

parent 64212440
No related branches found
No related tags found
1 merge request!101Corriger bug variations montants DSR/DSU et ajouter mention écrêtement
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
} }
}, },
"rules": { "rules": {
"class-methods-use-this": "off",
"import/extensions": [ "import/extensions": [
"error", "error",
"ignorePackages", "ignorePackages",
......
...@@ -35,15 +35,7 @@ type PropsFromRedux = ConnectedProps<typeof connector>; ...@@ -35,15 +35,7 @@ type PropsFromRedux = ConnectedProps<typeof connector>;
class MajorationMinorationText extends PureComponent<PropsFromRedux> { class MajorationMinorationText extends PureComponent<PropsFromRedux> {
static isMajoration(dsr: number, dsu: number): boolean { getMontantsText(dsr: number, dsu: number): string {
return dsr > 0 || dsu > 0;
}
static inMillions(n: number): string {
return `${formatNumber(Math.sign(n) * n)} million${Math.abs(n) > 1 ? "s" : ""}`;
}
static getMontantsText(dsr: number, dsu: number): string {
// eslint-disable-next-line prefer-template // eslint-disable-next-line prefer-template
return (this.isMajoration(dsr, dsu) ? "augmentent au moins" : "baissent") return (this.isMajoration(dsr, dsu) ? "augmentent au moins" : "baissent")
+ (dsr !== dsu ? ", respectivement, de " : " de ") + (dsr !== dsu ? ", respectivement, de " : " de ")
...@@ -53,12 +45,19 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> { ...@@ -53,12 +45,19 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> {
+ (dsr === dsu ? " chacun" : ""); + (dsr === dsu ? " chacun" : "");
} }
// eslint-disable-next-line class-methods-use-this isMajoration(dsr: number, dsu: number): boolean {
return dsr > 0 || dsu > 0;
}
inMillions(n: number): string {
return `${formatNumber(Math.sign(n) * n)} million${Math.abs(n) > 1 ? "s" : ""}`;
}
variationsHaveNotTheSameSign({ dsr, dsu }: { dsr: number, dsu: number }): boolean { variationsHaveNotTheSameSign({ dsr, dsu }: { dsr: number, dsu: number }): boolean {
return (dsr > 0 && dsu < 0) || (dsu > 0 && dsr < 0); return (dsr > 0 && dsu < 0) || (dsu > 0 && dsr < 0);
} }
render() { render() {
const { amendement, plf, removeVariation } = this.props; const { amendement, plf, removeVariation } = this.props;
const plfHasVariations = plf.dsr !== 0 || plf.dsu !== 0; const plfHasVariations = plf.dsr !== 0 || plf.dsu !== 0;
...@@ -103,7 +102,7 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> { ...@@ -103,7 +102,7 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> {
[styles.replacedWithAmendement]: plfAndAmendementAreDifferent, [styles.replacedWithAmendement]: plfAndAmendementAreDifferent,
[styles.bold]: true, [styles.bold]: true,
})}> })}>
{MajorationMinorationText.getMontantsText(plf.dsr, plf.dsu)} {this.getMontantsText(plf.dsr, plf.dsu)}
</span> </span>
) )
} }
...@@ -114,7 +113,7 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> { ...@@ -114,7 +113,7 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> {
[styles.bold]: true, [styles.bold]: true,
})}> })}>
{" "} {" "}
{MajorationMinorationText.getMontantsText(amendement.dsr, amendement.dsu)} {this.getMontantsText(amendement.dsr, amendement.dsu)}
</span> </span>
) )
} }
...@@ -130,6 +129,32 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> { ...@@ -130,6 +129,32 @@ class MajorationMinorationText extends PureComponent<PropsFromRedux> {
</span> </span>
) )
} }
{
plfHasVariations && this.isMajoration(plf.dsr, plf.dsu) && (
<span className={classNames({
[styles.plfValue]: true,
[styles.replacedWithAmendement]: !this.isMajoration(amendement.dsr, amendement.dsu),
})}>
{" "}
Cette augmentation est financée par les minorations prévues
à l&apos;article L. 2334-7-1.
</span>
)
}
{
amendementHasVariations
&& !this.isMajoration(plf.dsr, plf.dsu)
&& this.isMajoration(amendement.dsr, amendement.dsu)
&& (
<span className={classNames({
[styles.amendementValue]: true,
})}>
{" "}
Cette augmentation est financée par les minorations prévues
à l&apos;article L. 2334-7-1.
</span>
)
}
{ {
amendementHasVariations && ( amendementHasVariations && (
<Fragment> <Fragment>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment