Skip to content

Commit

Permalink
feat(exports): ajout d'informations opérateur sur l'export Ocacia
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed Apr 17, 2024
1 parent 0881d12 commit fd2fb12
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/components/Features/ExportStrategies/BaseExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { utils } from 'xlsx'
import { cultureLabel, featureName, sortByAccessor } from "../index.js"
import { getAnnotationLabel } from '../../../referentiels/ab.js'

/**
* @typedef {import('@agencebio/cartobio-types').CartoBioFeatureCollection} FeatureCollection
* @typedef {import('@agencebio/cartobio-types').AgenceBioNormalizedOperator} AgenceBioNormalizedOperator
* @typedef {import('@agencebio/cartobio-types').NormalizedRecord} NormalizedRecord
*/

const { sheet_to_csv, sheet_to_json, json_to_sheet } = utils

export default class BaseExporter {
Expand All @@ -10,6 +16,9 @@ export default class BaseExporter {
mimetype = ''
range = null

/**
* @param {{ featureCollection: FeatureCollection, operator: AgenceBioNormalizedOperator, record: NormalizedRecord, permissions }} params
*/
constructor ({ featureCollection, operator, record, permissions }) {
this.featureCollection = featureCollection
this.operator = operator
Expand Down
13 changes: 9 additions & 4 deletions src/components/Features/ExportStrategies/OcaciaExporter.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { utils, write } from 'xlsx'
import { fromCodeCpf } from '@agencebio/rosetta-cultures'
import { GROUPE_NIVEAU_CONVERSION, featureName, getFeatureGroups, surface } from '@/components/Features/index.js'
import { certificationStates, yearLabel } from '@/referentiels/ab.js'

import BaseExporter, { generateAutresInfos } from "@/components/Features/ExportStrategies/BaseExporter.js";

const { aoa_to_sheet, sheet_add_aoa, book_append_sheet, book_new } = utils
const { decode_range: R } = utils

function getSheet () {
const { featureCollection, permissions } = this
const { featureCollection, operator, permissions, record } = this
const adresse = `${operator.codePostal} ${operator.commune}`.trim()
const annee = yearLabel(record)
const statut = certificationStates[record.certification_state].label

const sheet = aoa_to_sheet([
['' , '', '', '', '', 'Surfaces en ha', '', '', '', '', '', '', '', '', 'Dernier intrant non autorisé en AB', '', '', ''],
['' , '', '', '', '', '0', '0', '0', '0', '0', '', '', '', '', '', '', '', ''],
['Commune', 'Ilot', 'Culture', 'N° Cadastre', 'Variété / infos', 'C0', 'AB', 'C1', 'C2', 'C3', 'Date conv', 'Observation', 'Précédent', 'Anté précédent', 'Produit', 'Date', 'Code culture', 'Id. Parcelle'],
[operator.nom, adresse, statut, annee, '', 'Surfaces en ha', '', '', '', '', '', '', '', '', 'Dernier intrant non autorisé en AB', '', '', ''],
['' , '', '', '', '', '0', '0', '0', '0', '0', '', '', '', '', '', '', '', ''],
['Commune' , 'Ilot', 'Culture', 'N° Cadastre', 'Variété / infos', 'C0', 'AB', 'C1', 'C2', 'C3', 'Date conv', 'Observation', 'Précédent', 'Anté précédent', 'Produit', 'Date', 'Code culture', 'Id. Parcelle'],
])

sheet['!merges'] = [
Expand Down

0 comments on commit fd2fb12

Please sign in to comment.