1.0.0 • Published 2 years ago

@synqueit/directus-extension-hook-formula v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Introduction

When new record is inserted into system_projection collection. It will trigger this hook to compute values based on custom formula and insert record into benchmark_manhour and manhour_distribution collections.

Procedure

Input (Trigger)

  1. collection => system_projection AND field => revenue

Variables

  1. (FOR benchmark_manhour) collection => formulas AND field => formula_expression, type = 'benchmark-manhour'
  2. (FOR manhour_distribution) collection => benchmark_ratio AND field => kitchen_ratio, bar_ratio, foh_ratio, cleaning_ratio

Result

  1. collection => benchmark_manhour AND fields => shop_cd,date,manhours

    e.g. manhours = 0.0006Math.pow(\<revenue>,2)+266.79\<revenue>-20323

  2. collection => manhour_distribution AND fields => shop_cd, date, kitchen_manhours, bar_manhours,cleaning_manhours,foh_manhours

    e.g. kitchen_manhours = kitchen_ratio * \<revenue>

Formula Format

0.0006Math.pow(\<revenue>,2)+266.79\<revenue>-20323 where \<revenue> field in system_projection collection

Requirement for manhour_distribution computation

collection benchmark_ratio must have ratios for shop_cd