示例#1
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
示例#2
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
示例#3
0
async def main(db, logger):

    SIREN = (
        "433108404",
        "820651610",
        "522305473",
        "403039977",
        "438027435",
        "308907971",
        "481301737",
        "314684960",
        "310497482",
        "387493513",
        "642040000",
        "310941125",
        "783883788",
        "334963105",
        "393579073",
        "808559546",
        "487884173",
        "425520376",
        "532504412",
        "327852596",
        "790696009",
        "395067184",
        "429853351",
        "314025701",
        "775720931",
    )
    records = await db.declaration.fetch(
        "SELECT data, owner, modified_at FROM declaration "
        "WHERE year=2020 "
        f"AND siren IN {SIREN}")
    bar = progressist.ProgressBar(prefix="Migrating…", total=len(records))
    for record in bar.iter(records):
        data = record.data
        helpers.compute_notes(data)
        siren = data.siren
        year = data.year
        await db.declaration.put(
            siren,
            year,
            owner=record["owner"],
            data=data.raw,
            modified_at=record["modified_at"],
        )
示例#4
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
示例#5
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
示例#6
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")
示例#7
0
async def main(db, logger):

    PAIRS = (
        (2020, "864801378"),
        (2020, "488181348"),
        (2020, "775576002"),
        (2019, "443094065"),
        (2018, "323592881"),
        (2018, "328695119"),
        (2018, "400131801"),
        (2019, "339733081"),
        (2019, "635780604"),
        (2019, "344319660"),
        (2019, "349821892"),
        (2019, "422386201"),
        (2019, "428724199"),
        (2019, "317031706"),
        (2019, "781562624"),
        (2019, "579803545"),
        (2019, "321761686"),
        (2019, "591820105"),
        (2019, "411010424"),
        (2019, "322084435"),
        (2019, "542110556"),
        (2019, "349173716"),
        (2019, "312610629"),
        (2019, "496950114"),
        (2019, "702010091"),
        (2019, "572183937"),
        (2019, "334537974"),
        (2019, "483698627"),
        (2019, "499434363"),
        (2019, "307350306"),
        (2019, "310004833"),
        (2019, "337783617"),
        (2019, "683650345"),
        (2019, "312381486"),
        (2019, "537908659"),
        (2019, "537915456"),
        (2019, "338297229"),
        (2019, "432678480"),
        (2019, "300701067"),
        (2019, "309730554"),
        (2019, "350324695"),
        (2019, "451886766"),
        (2019, "546750266"),
        (2019, "319665196"),
        (2019, "420075244"),
        (2019, "419911078"),
        (2019, "045750817"),
        (2019, "401247523"),
        (2019, "612011668"),
        (2019, "780060711"),
        (2019, "349540120"),
        (2019, "413446071"),
        (2019, "834179863"),
        (2019, "352411706"),
        (2019, "438992679"),
        (2019, "318334018"),
        (2019, "401698840"),
        (2019, "450745039"),
        (2019, "315948141"),
        (2019, "552106981"),
        (2019, "312456114"),
        (2019, "424081099"),
        (2019, "343006151"),
        (2019, "433977782"),
        (2019, "403526643"),
        (2019, "414831511"),
        (2019, "404490476"),
        (2019, "444829592"),
        (2019, "383764610"),
        (2019, "305934713"),
        (2019, "418214003"),
        (2019, "778859306"),
        (2019, "392808374"),
        (2019, "509225983"),
        (2019, "409059706"),
        (2019, "423683093"),
        (2019, "382495646"),
        (2019, "418767646"),
        (2019, "826250078"),
        (2019, "958803553"),
        (2019, "414730275"),
        (2019, "323944736"),
        (2019, "391764941"),
        (2019, "946150604"),
        (2019, "811986058"),
        (2019, "310146097"),
        (2019, "414733196"),
        (2019, "378807820"),
        (2019, "414837435"),
        (2019, "775725419"),
        (2019, "016950651"),
        (2019, "842191074"),
        (2019, "434314340"),
        (2019, "775612211"),
        (2019, "824597595"),
        (2019, "312680416"),
        (2019, "444542732"),
        (2018, "403839228"),
        (2019, "786069443"),
        (2019, "329285803"),
        (2019, "775932858"),
        (2019, "799178967"),
        (2019, "950010157"),
        (2019, "302717269"),
        (2019, "444518567"),
        (2019, "323276535"),
        (2019, "332538446"),
        (2019, "926450230"),
    )
    where = ",".join(str(p) for p in PAIRS)
    records = await db.declaration.fetch(
        "SELECT data, owner, modified_at FROM declaration "
        f"WHERE (year, siren) IN ({where})"
    )
    bar = progressist.ProgressBar(prefix="Migrating…", total=len(records))
    for record in bar.iter(records):
        data = record.data
        helpers.compute_notes(data)
        siren = data.siren
        year = data.year
        await db.declaration.put(
            siren,
            year,
            owner=record["owner"],
            data=data.raw,
            modified_at=record["modified_at"],
        )