-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REF] functions: create helper for AND and OR
This commit is a step to introduce the spreadsheet pivot. The functions AND and OR are used in the pivot to compute the values when the measure is a boolean. Task: 3748717 Part-of: #4025 Co-authored-by: rrahir <rar@odoo.com> Co-authored-by: Pierre Rousseau <pro@odoo.com>
- Loading branch information
Showing
2 changed files
with
35 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Arg } from "../types"; | ||
import { conditionalVisitBoolean } from "./helpers"; | ||
|
||
export function boolAnd(args: Arg[]) { | ||
let foundBoolean = false; | ||
let acc = true; | ||
conditionalVisitBoolean(args, (arg) => { | ||
foundBoolean = true; | ||
acc = acc && arg; | ||
return acc; | ||
}); | ||
return { | ||
foundBoolean, | ||
result: acc, | ||
}; | ||
} | ||
|
||
export function boolOr(args: Arg[]) { | ||
let foundBoolean = false; | ||
let acc = false; | ||
conditionalVisitBoolean(args, (arg) => { | ||
foundBoolean = true; | ||
acc = acc || arg; | ||
return !acc; | ||
}); | ||
return { | ||
foundBoolean, | ||
result: acc, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters