Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add ellisphere parser #179

Merged
merged 6 commits into from Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions dbmongo/handlers.go
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/base"
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/bdf"
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/diane"
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/ellisphere"
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/engine"
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/files"
"github.com/signaux-faibles/opensignauxfaibles/dbmongo/lib/marshal"
Expand Down Expand Up @@ -318,6 +319,7 @@ var registeredParsers = map[string]marshal.Parser{
"sirene": sirene.Parser,
"sirene_ul": sireneul.Parser,
"diane": diane.Parser,
"ellisphere": ellisphere.Parser,
}

// Vérifie et charge les parsers
Expand Down
16 changes: 16 additions & 0 deletions dbmongo/js/RawDataTypes.ts
Expand Up @@ -62,6 +62,7 @@ export type BatchValueProps = {
effectif_ent: ParHash<EntréeEffectif>
bdf: ParHash<EntréeBdf>
diane: ParHash<EntréeDiane>
ellisphere: ParHash<EntréeEllisphere>
}

// Détail des types de données
Expand Down Expand Up @@ -199,3 +200,18 @@ export type EntréeDiane = {
valeur_ajoutee?: number | null
dette_fiscale_et_sociale?: number | null
}

export type EntréeEllisphere = {
siren: string
code_groupe: string
siren_groupe: string
refid_groupe: string
raison_sociale_groupe: string
adresse_groupe: string
personne_pou_m_groupe: string
niveau_detention: number
part_financiere: number
code_filiere: string
refid_filiere: string
personne_pou_m_filiere: string
}
1 change: 0 additions & 1 deletion dbmongo/js/common/flatten.ts
Expand Up @@ -4,7 +4,6 @@ import { CompanyDataValuesWithCompact } from "../compact/applyPatchesToBatch"
export type FlattenedImportedData = {
key: SiretOrSiren
scope: Scope
crp?: unknown // exploité par le map-reduce "public" seulement
} & BatchValue

/**
Expand Down
9 changes: 5 additions & 4 deletions dbmongo/js/public/map.ts
Expand Up @@ -7,6 +7,7 @@ import {
EntréeDelai,
EntréeDefaillances,
EntréeDiane,
EntréeEllisphere,
} from "../RawDataTypes"
import { SortieDebit } from "./debits"
import { Bdf } from "./bdf"
Expand Down Expand Up @@ -37,7 +38,7 @@ type SortieMapEntreprise = SortieMapCommon & {
diane: EntréeDiane[]
bdf: Bdf[]
sirene_ul: unknown
crp: unknown
ellisphere: EntréeEllisphere
}

export type SortieMap = SortieMapEtablissement | SortieMapEntreprise
Expand Down Expand Up @@ -81,6 +82,7 @@ export function map(this: Input): void {
const diane = f.diane(value.diane)
const bdf = f.bdf(value.bdf)
const sirene_ul = f.iterable(value.sirene_ul)[0] || null
const ellisphere = f.iterable(value.ellisphere)[0] || null
if (sirene_ul) {
sirene_ul.raison_sociale = f.raison_sociale(
sirene_ul.raison_sociale,
Expand All @@ -92,7 +94,6 @@ export function map(this: Input): void {
sirene_ul.prenom4_unite_legale
)
}
const crp = value.crp
v.key = this.value.key
v.batch = actual_batch

Expand All @@ -105,8 +106,8 @@ export function map(this: Input): void {
if (sirene_ul) {
v.sirene_ul = sirene_ul
}
if (crp) {
v.crp = crp
if (ellisphere) {
v.ellisphere = ellisphere
}
if (Object.keys(v) !== []) {
emit("entreprise_" + this.value.key, v)
Expand Down
39 changes: 39 additions & 0 deletions dbmongo/js/public/public_tests.ts.md
Expand Up @@ -567,6 +567,19 @@ Generated by [AVA](https://avajs.dev).
valeur_ajoutee: 2587,
},
],
ellisphere: {
adresse_groupe: 'quelque part',
code_filiere: '1000000',
code_groupe: '1234567',
niveau_detention: 1,
part_financiere: 90.2,
personne_pou_m_filiere: 'M',
personne_pou_m_groupe: 'M',
raison_sociale_groupe: 'GROUPE A',
refid_filiere: 'AKES38748',
refid_groupe: '1234567',
siren_groupe: '525343432',
},
key: '123456789',
},
},
Expand Down Expand Up @@ -1579,6 +1592,19 @@ Generated by [AVA](https://avajs.dev).
valeur_ajoutee: 2587,
},
],
ellisphere: {
adresse_groupe: 'quelque part',
code_filiere: '1000000',
code_groupe: '1234567',
niveau_detention: 1,
part_financiere: 90.2,
personne_pou_m_filiere: 'M',
personne_pou_m_groupe: 'M',
raison_sociale_groupe: 'GROUPE A',
refid_filiere: 'AKES38748',
refid_groupe: '1234567',
siren_groupe: '525343432',
},
key: '123456789',
},
},
Expand Down Expand Up @@ -2589,6 +2615,19 @@ Generated by [AVA](https://avajs.dev).
valeur_ajoutee: 2587,
},
],
ellisphere: {
adresse_groupe: 'quelque part',
code_filiere: '1000000',
code_groupe: '1234567',
niveau_detention: 1,
part_financiere: 90.2,
personne_pou_m_filiere: 'M',
personne_pou_m_groupe: 'M',
raison_sociale_groupe: 'GROUPE A',
refid_filiere: 'AKES38748',
refid_groupe: '1234567',
siren_groupe: '525343432',
},
key: '123456789',
},
{
Expand Down
Binary file modified dbmongo/js/public/public_tests.ts.snap
Binary file not shown.
15 changes: 15 additions & 0 deletions dbmongo/js/test/data/objects.js
Expand Up @@ -548,6 +548,21 @@ const makeObjects = ISODate => ([
"financier_court_terme" : 0.00958588957055215,
"frais_financier" : 2.07039106145251
}
},
"ellisphere": {
"0bdfec56d76ba80d5f929dcb66196c28": {
"code_groupe": "1234567",
"siren_groupe": "525343432",
"refid_groupe": "1234567",
"raison_sociale_groupe": "GROUPE A",
"adresse_groupe": "quelque part",
"personne_pou_m_groupe": "M",
"niveau_detention": 1,
"part_financiere": 90.2,
"code_filiere": "1000000",
"refid_filiere": "AKES38748",
"personne_pou_m_filiere": "M"
}
}
},
"1810" : {
Expand Down
2 changes: 1 addition & 1 deletion dbmongo/lib/ellisphere/main.go
Expand Up @@ -13,7 +13,7 @@ import (

// Ellisphere informations groupe pour une entreprise
type Ellisphere struct {
Siren string `json:"siren" bson:"-" xlsx:"14"`
Siren string `json:"-" bson:"-" xlsx:"14"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qu'est-ce que veut dire ce - ?

CodeGroupe string `json:"code_groupe,omitempty" bson:"code_groupe,omitempty" xlsx:"0"`
SirenGroupe string `json:"siren_groupe,omitempty" bson:"siren_groupe,omitempty" xlsx:"2"`
RefIDGroupe string `json:"refid_groupe,omitempty" bson:"refid_groupe,omitempty" xlsx:"3"`
Expand Down
6 changes: 0 additions & 6 deletions dbmongo/lib/ellisphere/testData/expectedEllisphere.json
@@ -1,5 +1,4 @@
[{
"siren": "151515151",
"code_groupe": "1234567",
"siren_groupe": "525343432",
"refid_groupe": "1234567",
Expand All @@ -12,7 +11,6 @@
"refid_filiere": "AKES38748",
"personne_pou_m_filiere": "M"
},{
"siren": "151515152",
"code_groupe": "2345678",
"siren_groupe": "592839489",
"refid_groupe": "2345678",
Expand All @@ -25,7 +23,6 @@
"refid_filiere": "BKES38748",
"personne_pou_m_filiere": "M"
},{
"siren": "151515153",
"code_groupe": "3456789",
"siren_groupe": "235935959",
"refid_groupe": "3456789",
Expand All @@ -38,7 +35,6 @@
"refid_filiere": "CKES38748",
"personne_pou_m_filiere": "M"
},{
"siren": "151515154",
"code_groupe": "4567890",
"refid_groupe": "4567890",
"raison_sociale_groupe": "GROUPE A",
Expand All @@ -50,7 +46,6 @@
"refid_filiere": "DKES38748",
"personne_pou_m_filiere": "M"
},{
"siren": "151515155",
"code_groupe": "5678901",
"refid_groupe": "5678901",
"raison_sociale_groupe": "GROUPE B",
Expand All @@ -62,7 +57,6 @@
"refid_filiere": "EKES38748",
"personne_pou_m_filiere": "M"
},{
"siren": "151515156",
"code_groupe": "6789012",
"refid_groupe": "6789012",
"raison_sociale_groupe": "GROUPE C",
Expand Down
6 changes: 3 additions & 3 deletions dbmongo/lib/engine/jsFunctions.go
Expand Up @@ -989,10 +989,10 @@ db.getCollection("Features").createIndex({
const diane = f.diane(value.diane);
const bdf = f.bdf(value.bdf);
const sirene_ul = f.iterable(value.sirene_ul)[0] || null;
const ellisphere = f.iterable(value.ellisphere)[0] || null;
if (sirene_ul) {
sirene_ul.raison_sociale = f.raison_sociale(sirene_ul.raison_sociale, sirene_ul.nom_unite_legale, sirene_ul.nom_usage_unite_legale, sirene_ul.prenom1_unite_legale, sirene_ul.prenom2_unite_legale, sirene_ul.prenom3_unite_legale, sirene_ul.prenom4_unite_legale);
}
const crp = value.crp;
v.key = this.value.key;
v.batch = actual_batch;
if (diane.length > 0) {
Expand All @@ -1004,8 +1004,8 @@ db.getCollection("Features").createIndex({
if (sirene_ul) {
v.sirene_ul = sirene_ul;
}
if (crp) {
v.crp = crp;
if (ellisphere) {
v.ellisphere = ellisphere;
}
if (Object.keys(v) !== []) {
emit("entreprise_" + this.value.key, v);
Expand Down
Binary file modified tests/input-data/RawData.sample.json.secret
Binary file not shown.
Binary file modified tests/output-snapshots/test-api-compact.golden.json.secret
Binary file not shown.
15 changes: 14 additions & 1 deletion tests/output-snapshots/test-api-public.golden.json
Expand Up @@ -557,7 +557,20 @@
"financier_court_terme" : 0.216056402092336,
"frais_financier" : 7.54819277108434
}
]
],
"ellisphere" : {
"code_groupe" : "1234567",
"siren_groupe" : "525343432",
"refid_groupe" : "1234567",
"raison_sociale_groupe" : "GROUPE A",
"adresse_groupe" : "quelque part",
"personne_pou_m_groupe" : "M",
"niveau_detention" : 1,
"part_financiere" : 90.2,
"code_filiere" : "1000000",
"refid_filiere" : "AKES38748",
"personne_pou_m_filiere" : "M"
}
}
},
{
Expand Down