Skip to content

Commit d379f6f

Browse files
committed
Add helper to create entreprise's revenu
1 parent 86188de commit d379f6f

1 file changed

Lines changed: 65 additions & 1 deletion

File tree

packages/modele/src/entreprise/helpers.ts

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { PartialDeep } from "type-fest";
22
import defaultsDeep from "lodash.defaultsdeep";
33

4-
import type { EI, MicroEntreprise, Sarl, SAS } from "./types";
4+
import type { AnyEntreprise, EI, MicroEntreprise, Sarl, SAS } from "./types";
5+
import type { Revenu } from "~/revenu/types";
6+
import { NATURE_REVENU } from "~/revenu/constants";
57
import { NATURE_ACTIVITE_ENTREPRISE, STATUT_ENTREPRISE } from "./constants";
68
import {
79
eiSchema,
@@ -56,3 +58,65 @@ export function creerSAS(sas: PartialDeep<SAS>): SAS {
5658
} satisfies SAS),
5759
);
5860
}
61+
62+
export function creerRevenuEntreprise(
63+
entreprise: AnyEntreprise,
64+
montantAnnuel: number,
65+
): Revenu {
66+
if (entreprise.statut === STATUT_ENTREPRISE.sas.value) {
67+
return {
68+
nature: NATURE_REVENU.salaire.value,
69+
montantAnnuel: montantAnnuel,
70+
};
71+
}
72+
73+
if (entreprise.statut === STATUT_ENTREPRISE.sarl.value) {
74+
return {
75+
nature: NATURE_REVENU.remuneration.value,
76+
montantAnnuel: montantAnnuel,
77+
};
78+
}
79+
80+
if (entreprise.statut === STATUT_ENTREPRISE.microEntreprise.value) {
81+
switch (entreprise.natureActivite) {
82+
case NATURE_ACTIVITE_ENTREPRISE.artisanale.value:
83+
return {
84+
nature: NATURE_REVENU.microBICServices.value,
85+
montantAnnuel: montantAnnuel,
86+
};
87+
case NATURE_ACTIVITE_ENTREPRISE.commercialeMarchandises.value:
88+
return {
89+
nature: NATURE_REVENU.microBICMarchandises.value,
90+
montantAnnuel: montantAnnuel,
91+
};
92+
case NATURE_ACTIVITE_ENTREPRISE.commercialeServices.value:
93+
return {
94+
nature: NATURE_REVENU.microBICServices.value,
95+
montantAnnuel: montantAnnuel,
96+
};
97+
case NATURE_ACTIVITE_ENTREPRISE.liberale.value:
98+
return {
99+
nature: NATURE_REVENU.microBNC.value,
100+
montantAnnuel: montantAnnuel,
101+
};
102+
}
103+
}
104+
105+
switch (entreprise.natureActivite) {
106+
case NATURE_ACTIVITE_ENTREPRISE.artisanale.value:
107+
return {
108+
nature: NATURE_REVENU.bic.value,
109+
montantAnnuel: montantAnnuel,
110+
};
111+
case NATURE_ACTIVITE_ENTREPRISE.commerciale.value:
112+
return {
113+
nature: NATURE_REVENU.bic.value,
114+
montantAnnuel: montantAnnuel,
115+
};
116+
case NATURE_ACTIVITE_ENTREPRISE.liberale.value:
117+
return {
118+
nature: NATURE_REVENU.bnc.value,
119+
montantAnnuel: montantAnnuel,
120+
};
121+
}
122+
}

0 commit comments

Comments
 (0)