示例#1
0
def test_extract_ft():
    data = {"entreprise": {"raison_sociale": "blablabar"}}
    assert helpers.extract_ft(models.Data(data)) == "blablabar"
    data = {
        "entreprise": {
            "raison_sociale": "blablabar",
            "ues": {
                "nom": "nom ues"
            }
        }
    }
    assert helpers.extract_ft(models.Data(data)) == "blablabar nom ues"
    data = {
        "entreprise": {
            "raison_sociale": "blablabar",
            "ues": {
                "nom":
                "nom ues",
                "entreprises": [
                    {
                        "siren": "123456789",
                        "raison_sociale": "entreprise une"
                    },
                    {
                        "siren": "123456780",
                        "raison_sociale": "entreprise deux"
                    },
                ],
            },
        }
    }
    assert (helpers.extract_ft(models.Data(data)) ==
            "blablabar nom ues entreprise une entreprise deux")
示例#2
0
async def search(q, verbose=False):
    rows = await db.declaration.search(q)
    for row in rows:
        data = models.Data(row)
        print(f"{data.siren} | {data.year} | {data.company}")
        if verbose:
            print(row)
示例#3
0
def test_compute_augmentations_note():
    data = models.Data({
        "déclaration": {},
        "indicateurs": {
            "augmentations_et_promotions": {
                "résultat": 5,
                "résultat_nombre_salariés": 6,
            }
        },
    })
    helpers.compute_notes(data)
    assert data["indicateurs"]["augmentations_et_promotions"]["note"] == 25
    assert (data["indicateurs"]["augmentations_et_promotions"]
            ["note_nombre_salariés"] == 15)
    assert (data["indicateurs"]["augmentations_et_promotions"]
            ["note_en_pourcentage"] == 25)

    data = models.Data({
        "déclaration": {},
        "indicateurs": {
            "augmentations_et_promotions": {
                "résultat": 5.05,
                "résultat_nombre_salariés": 2,
            }
        },
    })
    helpers.compute_notes(data)
    assert data["indicateurs"]["augmentations_et_promotions"]["note"] == 35
    assert (data["indicateurs"]["augmentations_et_promotions"]
            ["note_nombre_salariés"] == 35)
    assert (data["indicateurs"]["augmentations_et_promotions"]
            ["note_en_pourcentage"] == 15)
    data["indicateurs"]["augmentations_et_promotions"][
        "non_calculable"] = "egvi40pcet"
    helpers.compute_notes(data)
    assert not data["indicateurs"]["augmentations_et_promotions"].get("note")
    assert not data["indicateurs"]["augmentations_et_promotions"].get(
        "note_nombre_salariés")
    assert not data["indicateurs"]["augmentations_et_promotions"].get(
        "note_en_pourcentage")
示例#4
0
 async def factory(
     siren="123456782",
     year=2020,
     owner="*****@*****.**",
     company="Total Recall",
     departement="26",
     region="84",
     grade=26,
     uid=str(uuid.uuid1()),
     compute_notes=False,
     modified_at=None,
     **data,
 ):
     data.setdefault("entreprise", {})
     data.setdefault("déclaration", {})
     data.setdefault("déclarant", {})
     data.setdefault("indicateurs", {})
     data.setdefault("id", uid)
     data["entreprise"].setdefault("raison_sociale", company)
     data["entreprise"].setdefault("département", departement)
     data["entreprise"].setdefault("région", region)
     data["entreprise"].setdefault("siren", siren)
     data["entreprise"].setdefault("effectif", {
         "tranche": "50:250",
         "total": 149
     })
     data["déclaration"].setdefault("année_indicateurs", year)
     data["déclaration"].setdefault("index", grade)
     data["déclaration"].setdefault("fin_période_référence", "2019-12-31")
     data["déclarant"].setdefault("email", owner)
     data["déclarant"].setdefault("prénom", "Martin")
     data["déclarant"].setdefault("nom", "Martine")
     data["indicateurs"].setdefault("rémunérations", {"mode": "csp"})
     data["indicateurs"].setdefault("congés_maternité", {})
     if data["entreprise"]["effectif"]["tranche"] == "50:250":
         data["indicateurs"].setdefault("augmentations_et_promotions", {})
     else:
         data["indicateurs"].setdefault("augmentations", {})
         data["indicateurs"].setdefault("promotions", {})
     if compute_notes:
         helpers.compute_notes(models.Data(data))
     await db.declaration.put(siren,
                              year,
                              owner,
                              data,
                              modified_at=modified_at)
     await db.ownership.put(siren, owner)
     return data
示例#5
0
def test_compute_augmentations_hp_note_with_correction_measures_but_equality():
    data = models.Data({
        "déclaration": {},
        "indicateurs": {
            "rémunérations": {
                "note": 40,
                "résultat": 0.0,
                "population_favorable": "femmes",
            },
            "augmentations": {
                "résultat": 4.0,
                "population_favorable": "hommes",
            },
        },
    })
    helpers.compute_notes(data)
    assert data["indicateurs"]["augmentations"]["note"] == 10
示例#6
0
def ues_data(sheet, data):
    data = models.Data(data)
    entreprises = data.path("entreprise.ues.entreprises")
    if not entreprises:
        return
    region = constants.REGIONS.get(data.path("entreprise.région"))
    departement = constants.DEPARTEMENTS.get(
        data.path("entreprise.département"))
    adresse = data.path("entreprise.adresse")
    cp = data.path("entreprise.code_postal")
    commune = data.path("entreprise.commune")
    tranche = EFFECTIF.get(data.path("entreprise.effectif.tranche"))
    nom = data.path("entreprise.ues.nom")
    rows = [[
        data.year,
        region,
        departement,
        adresse,
        cp,
        commune,
        tranche,
        nom,
        data.siren,
        data.company,
        data.path("entreprise.raison_sociale"),
        data.siren,
    ]]
    for ues in entreprises or []:
        rows.append([
            data.year,
            region,
            departement,
            adresse,
            cp,
            commune,
            tranche,
            nom,
            data.siren,
            data.company,
            ues["raison_sociale"],
            ues["siren"],
        ])
    for row in rows:
        sheet.append(clean_cell(cell) for cell in row)
示例#7
0
def test_compute_augmentations_note_with_correction_measures_but_equality():
    data = models.Data({
        "déclaration": {},
        "indicateurs": {
            "rémunérations": {
                "résultat": 0,
                "population_favorable": "hommes"
            },
            "augmentations_et_promotions": {
                "résultat": 5,
                "résultat_nombre_salariés": 6,
                "population_favorable": "femmes",
            },
        },
    })
    helpers.compute_notes(data)
    # rémuénrations.résultat == 0, this means equality, so whatever the value of
    # population_favorable, we do not follow it
    assert data["indicateurs"]["augmentations_et_promotions"]["note"] == 25
示例#8
0
def test_compute_augmentations_note_with_correction_measures():
    data = models.Data({
        "déclaration": {},
        "indicateurs": {
            "rémunérations": {
                "résultat": 5,
                "population_favorable": "hommes"
            },
            "augmentations_et_promotions": {
                "résultat": 5,
                "résultat_nombre_salariés": 6,
                "population_favorable": "femmes",
            },
        },
    })
    helpers.compute_notes(data)
    # Maximal note because this indicateur is favourable for the opposition population
    # of rémunérations indicateur
    assert data["indicateurs"]["augmentations_et_promotions"]["note"] == 35
示例#9
0
async def resend_receipts(*sirens,
                          recipient=None,
                          year=constants.CURRENT_YEAR):
    """Resend receipt for a list of sirens in the current year"""
    for siren in sirens:
        record = await db.declaration.get(siren, year)
        data = models.Data(record.get("data"))
        url = config.DOMAIN + data.uri
        recipient_ = recipient or record["declarant"]
        try:
            emails.success.send(
                recipient_,
                url=url,
                modified_at=record["modified_at"],
                **data,
            )
        except Exception as ex:
            print(ex)
            print(data)
            continue
示例#10
0
SMALL_COMPANY = models.Data({
    "id": "1234",
    "source": "formulaire",
    "déclaration": {
        "date": "2020-11-04T10:37:06+00:00",
        "année_indicateurs": 2019,
        "fin_période_référence": "2019-12-31",
        "index": 65,
    },
    "déclarant": {
        "email": "*****@*****.**",
        "prénom": "Foo",
        "nom": "Bar",
        "téléphone": "+33123456789",
    },
    "entreprise": {
        "raison_sociale": "FooBar",
        "siren": "514027945",
        "code_naf": "47.25Z",
        "code_postal": "12345",
        "région": "76",
        "département": "12",
        "adresse": "12, rue des adresses",
        "commune": "Y",
        "effectif": {
            "total": 312,
            "tranche": "50:250"
        },
    },
    "indicateurs": {
        "promotions": {},
        "augmentations": {},
        "rémunérations": {
            "mode":
            "csp",
            "note":
            38,
            "résultat":
            1.95,
            "catégories": [
                {
                    "nom": "tranche 0",
                    "tranches": {}
                },
                {
                    "nom": "tranche 1",
                    "tranches": {
                        "50:": -8.6,
                        ":29": 4.6,
                        "30:39": -0.7,
                        "40:49": 5.2,
                    },
                },
                {
                    "nom": "tranche 2",
                    "tranches": {
                        "50:": 1.9,
                        ":29": 2.2,
                        "30:39": 1.1,
                        "40:49": 2.2,
                    },
                },
                {
                    "nom": "tranche 3",
                    "tranches": {
                        "50:": 22.5,
                        ":29": 7.6,
                        "30:39": 2.9,
                        "40:49": 6.4,
                    },
                },
            ],
            "population_favorable":
            "hommes",
        },
        "congés_maternité": {
            "non_calculable": "absrcm"
        },
        "hautes_rémunérations": {
            "note": 0,
            "résultat": 0,
            "population_favorable": "hommes",
        },
        "augmentations_et_promotions": {
            "note": 0,
            "résultat": 34.4888,
            "note_en_pourcentage": 0,
            "population_favorable": "hommes",
            "note_nombre_salariés": 0,
            "résultat_nombre_salariés": 11.4,
        },
    },
})