Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

postprocess waterfall :: support no child on some parent #51

Open
WilliamGorge opened this issue Jan 27, 2020 · 0 comments
Open

postprocess waterfall :: support no child on some parent #51

WilliamGorge opened this issue Jan 27, 2020 · 0 comments

Comments

@WilliamGorge
Copy link
Member

In https://training-2019.toucantoco.com/diac-v2?view=FRANCE&report=FRANCE&slide=1004002&admin=true&stage=staging we need to have a parent (CAX) without a parent.

query is

query: [
  [
    {
      $match:
        domain: "Master"
        ANNEE_REF: "<%= appRequesters.date.ANNEE %>"
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA"
    }
    {
      $addFields:
        type: "Annee en cours"
        indicateur: "CA"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        ANNEE_REF:
          $lt: "<%= appRequesters.date.ANNEE %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA"
    }
    {
      $sort:
        _id: -1
    }
    {
      $limit: 1
    }
    {
      $addFields:
        type: "Annee precedente"
        indicateur: "CA"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        ANNEE_REF: "<%= appRequesters.date.ANNEE %>"
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA_REMUNERE_REG"
    }
    {
      $addFields:
        type: "Annee en cours"
        indicateur: "CA REM"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        ANNEE_REF:
          $lt: "<%= appRequesters.date.ANNEE %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA_REMUNERE_REG"
    }
    {
      $sort:
        _id: -1
    }
    {
      $limit: 1
    }
    {
      $addFields:
        type: "Annee precedente"
        indicateur: "CA REM"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        ANNEE_REF: "<%= appRequesters.date.ANNEE %>"
        QUAL_VEH:
          $ne: 0
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA_REMUNERE_REG"
    }
    {
      $addFields:
        type: "Annee en cours"
        indicateur: "CA REM VO"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        QUAL_VEH:
          $ne: 0
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        ANNEE_REF:
          $lt: "<%= appRequesters.date.ANNEE %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA_REMUNERE_REG"
    }
    {
      $sort:
        _id: -1
    }
    {
      $limit: 1
    }
    {
      $addFields:
        type: "Annee precedente"
        indicateur: "CA REM VO"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        ANNEE_REF: "<%= appRequesters.date.ANNEE %>"
        QUAL_VEH: 0
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA_REMUNERE_REG"
    }
    {
      $addFields:
        type: "Annee en cours"
        indicateur: "CA REM VN"
    }
  ]
  [
    {
      $match:
        domain: "Master"
        QUAL_VEH: 0
        MOIS_JOUR:
          $lte: "<%= appRequesters.date.MOIS_JOUR %>"
        ANNEE_REF:
          $lt: "<%= appRequesters.date.ANNEE %>"
        "<%= appRequesters.report.type %>": "<%= appRequesters.report.report == 'FRANCE' ? '__VOID__' : appRequesters.report.report %>"
    }
    {
      $group:
        _id: "$ANNEE_REF"
        value:
          $sum: "$MT_CA_REMUNERE_REG"
    }
    {
      $sort:
        _id: -1
    }
    {
      $limit: 1
    }
    {
      $addFields:
        type: "Annee precedente"
        indicateur: "CA REM VN"
    }
  ]
]
multiple_queries: true
postprocess: [
  {
    pivot:
      index: "type"
      column: "indicateur"
      value: "value"
  }
  {
    formula:
      new_column: "CAX"
      formula: "CA-CA REM"
  }
  {
    melt:
      id: [
        "type"
      ]
      value: [
        "CA"
        "CA REM"
        "CAX"
        "CA REM VO"
        "CA REM VN"
      ]
  }
  {
    sort:
      columns: "type"
      order: "desc"
  }
  {
    query: "indicateur != 'CA'"
  }
  {
    query: "indicateur != 'CA REM'"
  }
  {
    replace:
      column: "indicateur"
      new_column: "parent"
      to_replace:
        "CA REM VO": "CA REM"
        "CA REM VN": "CA REM"
  }
  {
    waterfall:
      date: "type"
      value: "value"
      start:
        label: "Année précédente"
        id: "Annee precedente"
      end:
        label: "Année en cours"
        id: "Annee en cours"
      upperGroup:
        id: "parent"
      insideGroup:
        id: "indicateur"
  }
  {
    query: "label != 'CAX' or type != 'child'"
  }
]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant