Compare commits
No commits in common. "7e50ef1bf89058bc94efb573db78184ed21f6484" and "677732d511447965cd4e48a868199fc7079693be" have entirely different histories.
7e50ef1bf8
...
677732d511
|
@ -1,42 +0,0 @@
|
||||||
## Formula Calculation
|
|
||||||
|
|
||||||
### Instalation
|
|
||||||
```
|
|
||||||
yarn add mathjs algebra.js
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Example
|
|
||||||
```ts
|
|
||||||
import * as math from 'mathjs'
|
|
||||||
import { Equation, parse } from 'algebra.js'
|
|
||||||
|
|
||||||
const formula = 'dpp - (dpp*ppn) - (dpp*retribusi) - (dpp*service) - (dpp*ppn3)'
|
|
||||||
const total = '300000'
|
|
||||||
|
|
||||||
const variable = {
|
|
||||||
ppn: 11,
|
|
||||||
retribusi: 5000,
|
|
||||||
service: 5,
|
|
||||||
ppn3: 5000
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
const x1 = math.simplify(formula, variable).toString()
|
|
||||||
console.log('Formula ', x1)
|
|
||||||
const dppFormula = parse(x1)
|
|
||||||
const totalFormula = parse(total)
|
|
||||||
const equation = new Equation(totalFormula, dppFormula)
|
|
||||||
|
|
||||||
console.log(equation.toString())
|
|
||||||
const result = equation.solveFor('dpp').toString()
|
|
||||||
console.log(result)
|
|
||||||
|
|
||||||
const value = math.evaluate(result)
|
|
||||||
console.log(value)
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
```
|
|
Loading…
Reference in New Issue