When a SectionTa has no modifying text use one at the same date if it exists
This commit is contained in:
parent
0a23b4594c
commit
2c1bffcaa4
1 changed files with 87 additions and 1 deletions
|
@ -1563,7 +1563,7 @@ async function registerLegiArticleModifiers(
|
|||
} else {
|
||||
// If article belongs directly to a text published in JORF but at a later date than the JORF text,
|
||||
// then if article has no creating text, consider that it has been created by a modifying text having the same start
|
||||
// date as the article.
|
||||
// date as the article when such a text exists.
|
||||
const modifyingTextIdByAction = (context.modifyingTextIdByActionById[
|
||||
articleId
|
||||
] ??= {})
|
||||
|
@ -1839,6 +1839,92 @@ async function registerLegiSectionTaModifiers(
|
|||
}
|
||||
}
|
||||
|
||||
if (sectionTa.CONTEXTE.TEXTE["@cid"].startsWith("JORFTEXT")) {
|
||||
if (sectionTaDateDebut === sectionTa.CONTEXTE.TEXTE["@date_publi"]) {
|
||||
// If Section Texte Article belongs directly to a text published in JORF at the same date, then this JORF text is its creating text.
|
||||
await addModifyingTextId(
|
||||
context,
|
||||
sectionTa.CONTEXTE.TEXTE["@cid"],
|
||||
"CREATE",
|
||||
sectionTaId,
|
||||
sectionTaDateDebut,
|
||||
sectionTaDateFin,
|
||||
)
|
||||
// Delete another version of the same sectionTa that existed before the newly created one.
|
||||
for (const otherLienSectionTa of liensSectionTa) {
|
||||
if (otherLienSectionTa["@id"] === sectionTaId) {
|
||||
continue
|
||||
}
|
||||
if (
|
||||
otherLienSectionTa["@cid"] === lienSectionTa["@cid"] &&
|
||||
otherLienSectionTa["@fin"] === sectionTaDateDebut
|
||||
) {
|
||||
// The other sectionTa is the old version of the sectionTa.
|
||||
await addModifyingTextId(
|
||||
context,
|
||||
sectionTa.CONTEXTE.TEXTE["@cid"],
|
||||
"DELETE",
|
||||
otherLienSectionTa["@id"],
|
||||
otherLienSectionTa["@debut"],
|
||||
otherLienSectionTa["@fin"],
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If Section Texte Article belongs directly to a text published in JORF but at a later date than the JORF text,
|
||||
// then if it has no creating text, consider that it has been created by a modifying text having the same start
|
||||
// date as the Section Texte Article when such a text exists.
|
||||
const modifyingTextIdByAction = (context.modifyingTextIdByActionById[
|
||||
sectionTaId
|
||||
] ??= {})
|
||||
if (modifyingTextIdByAction.CREATE === undefined) {
|
||||
const consolidatedTextModifyingTextsIds =
|
||||
context.consolidatedTextModifyingTextsIdsByActionByDate[
|
||||
sectionTaDateDebut
|
||||
]?.CREATE
|
||||
if (consolidatedTextModifyingTextsIds !== undefined) {
|
||||
if (consolidatedTextModifyingTextsIds.size === 1) {
|
||||
const modifyingTextId = [...consolidatedTextModifyingTextsIds][0]
|
||||
await addModifyingTextId(
|
||||
context,
|
||||
modifyingTextId,
|
||||
"CREATE",
|
||||
sectionTaId,
|
||||
sectionTaDateDebut,
|
||||
sectionTaDateFin,
|
||||
)
|
||||
// Delete another version of the same sectionTa that existed before the newly created one.
|
||||
for (const otherLienSectionTa of liensSectionTa) {
|
||||
if (otherLienSectionTa["@id"] === sectionTaId) {
|
||||
continue
|
||||
}
|
||||
if (
|
||||
otherLienSectionTa["@cid"] === lienSectionTa["@cid"] &&
|
||||
otherLienSectionTa["@fin"] === sectionTaDateDebut
|
||||
) {
|
||||
// The other sectionTa is the old version of the sectionTa.
|
||||
await addModifyingTextId(
|
||||
context,
|
||||
sectionTa.CONTEXTE.TEXTE["@cid"],
|
||||
"DELETE",
|
||||
otherLienSectionTa["@id"],
|
||||
otherLienSectionTa["@debut"],
|
||||
otherLienSectionTa["@fin"],
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
`Can't attach modifying article ${sectionTaId} to a modifying text`,
|
||||
`because there are several possibilities at the date ${sectionTaDateDebut}:`,
|
||||
`${[...consolidatedTextModifyingTextsIds].join(", ")}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If Section Texte Article has no creating text at all, then use a fake one.
|
||||
const modifyingTextIdByAction = (context.modifyingTextIdByActionById[
|
||||
sectionTaId
|
||||
|
|
Loading…
Reference in a new issue