Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
.git
nginx
.nuxt
.nuxt
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
"plugin:prettier/recommended",
"plugin:nuxt/recommended",
],
plugins: ["prettier"],
// add your custom rules here
rules: {
// force semicolon at the end
semi: [2, "always"],
// use double quote
quotes: ["error", "double"],
},
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ sw.*
_site
.sass-cache
.jekyll-metadata
Gemfile.lock
Gemfile.lock
101 changes: 101 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
exclude: ^(.*\/node_modules|.*package.json|.*package-lock.json|.*\/fixtures\/.*.json)
repos:
- hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: forbid-new-submodules
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- hooks:
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-symlinks
- id: check-vcs-permalinks
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- hooks:
- id: forbid-crlf
- id: remove-crlf
- id: forbid-tabs
- id: remove-tabs
repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.9
- hooks:
- id: check-json
- args:
- --autofix
id: pretty-format-json
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- hooks:
- id: beautysh
repo: https://github.com/bemeurer/beautysh.git
rev: 6.0.1
- hooks:
- id: script-must-have-extension
repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
- hooks:
- args:
- "-d {rules: {line-length: {max: 999}}}"
id: yamllint
repo: https://github.com/adrienverge/yamllint.git
rev: v1.24.2
- hooks:
- id: check-yaml
- id: sort-simple-yaml
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- hooks:
- id: gitlab-ci-linter
repo: https://gitlab.com/devopshq/gitlab-ci-linter
rev: v1.0.1
- hooks:
- additional_dependencies:
- eslint@latest
- vue-eslint-parser@latest
- eslint-plugin-vue@latest
- eslint-plugin-jquery@latest
- eslint-plugin-eslint-plugin@latest
- prettier@latest
- eslint-config-prettier@latest
- eslint-plugin-prettier@latest
- babel-eslint
args:
- -c=.eslintrc.js
- --fix
id: eslint
name: vue-eslint
types:
- vue
repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.8.1
- hooks:
- additional_dependencies:
- eslint@latest
- vue-eslint-parser@latest
- eslint-plugin-vue@latest
- eslint-plugin-jquery@latest
- eslint-plugin-eslint-plugin@latest
- prettier@latest
- eslint-config-prettier@latest
- eslint-plugin-prettier@latest
- babel-eslint
args:
- -c=.eslintrc.js
- --fix
files: ^
id: eslint
name: js-eslint
repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.8.1
- hooks:
- id: commitizen
stages:
- manual
repo: https://github.com/commitizen-tools/commitizen
rev: v2.3.1
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": true,
"printWidth": 120
}
203 changes: 100 additions & 103 deletions CheckAndCompleteCompteDeResultat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,148 +8,145 @@ data = {
status : "official"
}
*/
export function checkTreeData( item ) {
if (!item.data)
{
console.log(" from item :", item)
export function checkTreeData(item) {
if (!item.data) {
console.log(" from item :", item);
item.data = {
code : item.codeLiasses.toString(),
description : "non fourni",
value : undefined,
status : "missing" }
code: item.codeLiasses.toString(),
description: "non fourni",
value: undefined,
status: "missing",
};
}
if (item.children)
{
for (var childName in item.children)
{
checkTreeData(item.children[childName])
if (item.children) {
for (var childName in item.children) {
checkTreeData(item.children[childName]);
}

// Accepted amount of difference when checking parent value against it's children
const relativeError = 0.005
const absoluteError = 10
const relativeError = 0.005;
const absoluteError = 10;

// Compute ourself item's value from its children
var computedSum = 0 // Result from official children's value
var computedSumFromComputed = 0 // Result from computed children's value
var computedSumWithoutSign = 0 // Result by adding all children (even if somme children should be substracted)
var childMissingCount = 0 // Count of child without value officially given
for (var childName in item.children)
{
var child = item.children[childName]
if (child.data.value)
{
computedSum += child.data.value * (child.sign ? -1 : 1)
computedSumFromComputed += child.data.value * (child.sign ? -1 : 1)
computedSumWithoutSign += child.data.value
}
else
{
childMissingCount += 1
if (child.data.computedValue)
{
computedSumFromComputed += child.data.computedValue * (child.sign ? -1 : 1)
var computedSum = 0; // Result from official children's value
var computedSumFromComputed = 0; // Result from computed children's value
var computedSumWithoutSign = 0; // Result by adding all children (even if somme children should be substracted)
var childMissingCount = 0; // Count of child without value officially given
for (var childName in item.children) {
var child = item.children[childName];
if (child.data.value) {
computedSum += child.data.value * (child.sign ? -1 : 1);
computedSumFromComputed += child.data.value * (child.sign ? -1 : 1);
computedSumWithoutSign += child.data.value;
} else {
childMissingCount += 1;
if (child.data.computedValue) {
computedSumFromComputed += child.data.computedValue * (child.sign ? -1 : 1);
}
}
}

if (item.data.value) {
// If official value match computed value from official children's value with less than 0.5% error
if (Math.abs((computedSum - item.data.value) / item.data.value) < relativeError
|| Math.abs(computedSum - item.data.value) < absoluteError)
{
item.data.status = "checked"
if (
Math.abs((computedSum - item.data.value) / item.data.value) < relativeError ||
Math.abs(computedSum - item.data.value) < absoluteError
) {
item.data.status = "checked";
// Fix children values if needed
if (childMissingCount > 0)
{
for (var childName in item.children)
{
setToZeroComputed(item.children[childName])
if (childMissingCount > 0) {
for (var childName in item.children) {
setToZeroComputed(item.children[childName]);
}
}
}
// If official value match computed value from computed children's value with less than 0.5% error
else if (Math.abs((computedSumFromComputed - item.data.value) / item.data.value) < relativeError
|| Math.abs(computedSumFromComputed - item.data.value) < absoluteError)
{
item.data.status = "checked"
else if (
Math.abs((computedSumFromComputed - item.data.value) / item.data.value) < relativeError ||
Math.abs(computedSumFromComputed - item.data.value) < absoluteError
) {
item.data.status = "checked";
// Fix children values if needed
for (var childName in item.children)
{
if (item.children[childName].data.value == undefined )
{
item.children[childName].data.value = item.children[childName].data.computedValue
item.children[childName].data.status = "computed"
for (var childName in item.children) {
if (item.children[childName].data.value == undefined) {
item.children[childName].data.value = item.children[childName].data.computedValue;
item.children[childName].data.status = "computed";
}
}
computedSum = computedSumFromComputed
computedSum = computedSumFromComputed;
}
// If there is only on value missing from children, set this child's value equal to the computed difference
else if (childMissingCount == 1)
{
for (var childName in item.children)
{
var child = item.children[childName]
if (!child.data.value)
{
item.children[childName].data.computedValue = (item.data.value - computedSum) / (child.sign ? -1 : 1)
item.children[childName].data.value = item.children[childName].data.computedValue
item.children[childName].data.status = "computed"
item.data.status = "checked"
else if (childMissingCount == 1) {
for (var childName in item.children) {
var child = item.children[childName];
if (!child.data.value) {
item.children[childName].data.computedValue = (item.data.value - computedSum) / (child.sign ? -1 : 1);
item.children[childName].data.value = item.children[childName].data.computedValue;
item.children[childName].data.status = "computed";
item.data.status = "checked";
break;
}
}
}
// If official value match computed value by adding all children's value (no substraction) with less than 0.5% error
else if (Math.abs((computedSumWithoutSign - item.data.value) / item.data.value) < relativeError
|| Math.abs(computedSumWithoutSign - item.data.value) < absoluteError)
{
item.data.status = "checked"
else if (
Math.abs((computedSumWithoutSign - item.data.value) / item.data.value) < relativeError ||
Math.abs(computedSumWithoutSign - item.data.value) < absoluteError
) {
item.data.status = "checked";
// Fix children sign and/or set to zero missing values if any
for (var childName in item.children)
{
flipSign(item.children[childName])
setToZeroComputed(item.children[childName])
for (var childName in item.children) {
flipSign(item.children[childName]);
setToZeroComputed(item.children[childName]);
}
}
else if (Math.abs((computedSum - item.data.value) / item.data.value) > 100)
{
item.data.status = "error"
console.log("checkTreeData detected very big error for ", item.name, " value doesn't match by several order of magnitude. Maybe units problem ?")
}
else {
item.data.status = "error"
console.log("checkTreeData detected error for ", item.name, " value doesn't match with ", computedSumWithoutSign)
} else if (Math.abs((computedSum - item.data.value) / item.data.value) > 100) {
item.data.status = "error";
console.log(
"checkTreeData detected very big error for ",
item.name,
" value doesn't match by several order of magnitude. Maybe units problem ?"
);
} else {
item.data.status = "error";
console.log(
"checkTreeData detected error for ",
item.name,
" value doesn't match with ",
computedSumWithoutSign
);
}
}
if (computedSum != item.data.value)
{
console.log("computed sum : ", computedSum, "computed sum from computed : ", computedSumFromComputed, " and given sum : ", item.data.value, " diff en pour 100 : ", ((computedSum - item.data.value)*100 / item.data.value))
item.data.computedValue = computedSumFromComputed
if (computedSum != item.data.value) {
console.log(
"computed sum : ",
computedSum,
"computed sum from computed : ",
computedSumFromComputed,
" and given sum : ",
item.data.value,
" diff en pour 100 : ",
((computedSum - item.data.value) * 100) / item.data.value
);
item.data.computedValue = computedSumFromComputed;
}
}
}

function setToZeroComputed ( item )
{
console.log("setToZeroComputed called for : ", item.name, item.data)
if (item.data.value == undefined && (item.data.computedValue == undefined || item.data.computedValue == 0))
{
item.data.value = 0
item.data.status = "computed"
for (var childName in item.children)
{
setToZeroComputed(item.children[childName])
function setToZeroComputed(item) {
console.log("setToZeroComputed called for : ", item.name, item.data);
if (item.data.value == undefined && (item.data.computedValue == undefined || item.data.computedValue == 0)) {
item.data.value = 0;
item.data.status = "computed";
for (var childName in item.children) {
setToZeroComputed(item.children[childName]);
}
}
}

function flipSign ( item )
{
console.log("flipSign called for : ", item.name, item.data)
if (item.sign && item.sign == -1)
{
item.data.value = -item.data.value
item.data.status = "signFlipped"
function flipSign(item) {
console.log("flipSign called for : ", item.name, item.data);
if (item.sign && item.sign == -1) {
item.data.value = -item.data.value;
item.data.status = "signFlipped";
}
}
Loading