@classytic/stage 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/atomic/aufbau.d.mts +144 -0
- package/dist/atomic/aufbau.mjs +384 -0
- package/dist/atomic/elements.d.mts +67 -0
- package/dist/atomic/elements.mjs +785 -0
- package/dist/atomic/emission.d.mts +112 -0
- package/dist/atomic/emission.mjs +179 -0
- package/dist/atomic/index.d.mts +8 -0
- package/dist/atomic/index.mjs +9 -0
- package/dist/atomic/periodic.d.mts +82 -0
- package/dist/atomic/periodic.mjs +231 -0
- package/dist/atomic/properties.d.mts +100 -0
- package/dist/atomic/properties.mjs +574 -0
- package/dist/atomic/shells.d.mts +137 -0
- package/dist/atomic/shells.mjs +170 -0
- package/dist/atomic/trends.d.mts +148 -0
- package/dist/atomic/trends.mjs +225 -0
- package/dist/chem/chromatography.d.mts +66 -0
- package/dist/chem/chromatography.mjs +63 -0
- package/dist/chem/complex.d.mts +114 -0
- package/dist/chem/complex.mjs +234 -0
- package/dist/chem/cycle.d.mts +75 -0
- package/dist/chem/cycle.mjs +145 -0
- package/dist/chem/equation.d.mts +86 -0
- package/dist/chem/equation.mjs +168 -0
- package/dist/chem/formula.d.mts +90 -0
- package/dist/chem/formula.mjs +201 -0
- package/dist/chem/functional-groups.d.mts +31 -0
- package/dist/chem/functional-groups.mjs +187 -0
- package/dist/chem/hazard.d.mts +94 -0
- package/dist/chem/hazard.mjs +329 -0
- package/dist/chem/index.d.mts +34 -33
- package/dist/chem/index.mjs +34 -28
- package/dist/chem/ionic.d.mts +98 -0
- package/dist/chem/ionic.mjs +156 -0
- package/dist/chem/layout.d.mts +46 -0
- package/dist/chem/layout.mjs +342 -0
- package/dist/chem/lewis.d.mts +79 -0
- package/dist/chem/lewis.mjs +163 -0
- package/dist/chem/molecular-orbital.d.mts +114 -0
- package/dist/chem/molecular-orbital.mjs +201 -0
- package/dist/chem/molecule.d.mts +154 -0
- package/dist/chem/molecule.mjs +282 -0
- package/dist/chem/nmr.d.mts +153 -0
- package/dist/chem/nmr.mjs +165 -0
- package/dist/chem/polymer.d.mts +65 -0
- package/dist/chem/polymer.mjs +179 -0
- package/dist/chem/redox.d.mts +138 -0
- package/dist/chem/redox.mjs +328 -0
- package/dist/chem/relations.d.mts +183 -0
- package/dist/chem/relations.mjs +299 -0
- package/dist/chem/skeleton.d.mts +51 -0
- package/dist/chem/skeleton.mjs +186 -0
- package/dist/chem/solution.d.mts +116 -0
- package/dist/chem/solution.mjs +186 -0
- package/dist/chem/species.d.mts +47 -0
- package/dist/chem/species.mjs +128 -0
- package/dist/chem/stereo.d.mts +108 -0
- package/dist/chem/stereo.mjs +286 -0
- package/dist/chem/stoichiometry.d.mts +95 -0
- package/dist/chem/stoichiometry.mjs +145 -0
- package/dist/chem/synthesis.d.mts +113 -0
- package/dist/chem/synthesis.mjs +281 -0
- package/dist/chem/vsepr.d.mts +80 -0
- package/dist/chem/vsepr.mjs +247 -0
- package/dist/circuit/ac.d.mts +163 -0
- package/dist/circuit/ac.mjs +452 -0
- package/dist/circuit/dc.d.mts +92 -0
- package/dist/circuit/dc.mjs +333 -0
- package/dist/circuit/index.d.mts +5 -92
- package/dist/circuit/index.mjs +5 -332
- package/dist/circuit/network.d.mts +99 -0
- package/dist/circuit/network.mjs +440 -0
- package/dist/circuit/topology.d.mts +102 -0
- package/dist/circuit/topology.mjs +143 -0
- package/dist/colour/absorption.d.mts +79 -0
- package/dist/colour/absorption.mjs +137 -0
- package/dist/colour/index.d.mts +6 -0
- package/dist/colour/index.mjs +7 -0
- package/dist/colour/name.d.mts +14 -0
- package/dist/colour/name.mjs +76 -0
- package/dist/colour/observer.d.mts +31 -0
- package/dist/colour/observer.mjs +46 -0
- package/dist/colour/spectrum.d.mts +61 -0
- package/dist/colour/spectrum.mjs +108 -0
- package/dist/colour/srgb.d.mts +49 -0
- package/dist/colour/srgb.mjs +108 -0
- package/dist/core/constants.d.mts +138 -0
- package/dist/core/constants.mjs +139 -0
- package/dist/core/index.d.mts +3 -1
- package/dist/core/index.mjs +3 -1
- package/dist/core/vec3.d.mts +94 -0
- package/dist/core/vec3.mjs +123 -0
- package/dist/core/worked.d.mts +35 -0
- package/dist/core/worked.mjs +44 -0
- package/dist/electro/cell.d.mts +102 -0
- package/dist/electro/cell.mjs +170 -0
- package/dist/electro/conductivity.d.mts +157 -0
- package/dist/electro/conductivity.mjs +156 -0
- package/dist/electro/couples.d.mts +114 -0
- package/dist/electro/couples.mjs +334 -0
- package/dist/electro/electrolysis.d.mts +96 -0
- package/dist/electro/electrolysis.mjs +274 -0
- package/dist/electro/faraday.d.mts +150 -0
- package/dist/electro/faraday.mjs +118 -0
- package/dist/electro/index.d.mts +6 -0
- package/dist/electro/index.mjs +7 -0
- package/dist/finance/accounting/adjustments.d.mts +17 -0
- package/dist/finance/accounting/adjustments.mjs +202 -0
- package/dist/finance/accounting/analysis.d.mts +8 -0
- package/dist/finance/accounting/analysis.mjs +205 -0
- package/dist/finance/accounting/clubs.d.mts +21 -0
- package/dist/finance/accounting/clubs.mjs +217 -0
- package/dist/finance/accounting/company-statements.d.mts +7 -0
- package/dist/finance/accounting/company-statements.mjs +150 -0
- package/dist/finance/accounting/harness.d.mts +7 -0
- package/dist/finance/accounting/harness.mjs +45 -0
- package/dist/finance/accounting/index.d.mts +18 -0
- package/dist/finance/accounting/index.mjs +18 -0
- package/dist/finance/accounting/journalize.d.mts +16 -0
- package/dist/finance/accounting/journalize.mjs +128 -0
- package/dist/finance/accounting/manufacturing.d.mts +8 -0
- package/dist/finance/accounting/manufacturing.mjs +236 -0
- package/dist/finance/accounting/partnership.d.mts +7 -0
- package/dist/finance/accounting/partnership.mjs +152 -0
- package/dist/finance/accounting/period-case.d.mts +6 -0
- package/dist/finance/accounting/period-case.mjs +71 -0
- package/dist/finance/accounting/post.d.mts +9 -0
- package/dist/finance/accounting/post.mjs +84 -0
- package/dist/finance/accounting/precision.d.mts +9 -0
- package/dist/finance/accounting/precision.mjs +15 -0
- package/dist/finance/accounting/rules.d.mts +21 -0
- package/dist/finance/accounting/rules.mjs +37 -0
- package/dist/finance/accounting/solve.d.mts +28 -0
- package/dist/finance/accounting/solve.mjs +92 -0
- package/dist/finance/accounting/statements.d.mts +7 -0
- package/dist/finance/accounting/statements.mjs +142 -0
- package/dist/finance/accounting/types.d.mts +649 -0
- package/dist/finance/accounting/validate.d.mts +7 -0
- package/dist/finance/accounting/validate.mjs +67 -0
- package/dist/finance/accounting/verification.d.mts +24 -0
- package/dist/finance/accounting/verification.mjs +386 -0
- package/dist/finance/bizsim.d.mts +21 -39
- package/dist/finance/bizsim.mjs +276 -97
- package/dist/finance/index.d.mts +20 -43
- package/dist/finance/index.mjs +19 -77
- package/dist/finance/investment-math.d.mts +7 -0
- package/dist/finance/investment-math.mjs +18 -0
- package/dist/finance/management-accounting/budgeting.d.mts +7 -0
- package/dist/finance/management-accounting/budgeting.mjs +189 -0
- package/dist/finance/management-accounting/cash-budget.d.mts +7 -0
- package/dist/finance/management-accounting/cash-budget.mjs +154 -0
- package/dist/finance/management-accounting/costing.d.mts +8 -0
- package/dist/finance/management-accounting/costing.mjs +175 -0
- package/dist/finance/management-accounting/decisions.d.mts +8 -0
- package/dist/finance/management-accounting/decisions.mjs +164 -0
- package/dist/finance/management-accounting/index.d.mts +13 -0
- package/dist/finance/management-accounting/index.mjs +13 -0
- package/dist/finance/management-accounting/integrated-budget.d.mts +8 -0
- package/dist/finance/management-accounting/integrated-budget.mjs +67 -0
- package/dist/finance/management-accounting/inventory-costing.d.mts +7 -0
- package/dist/finance/management-accounting/inventory-costing.mjs +173 -0
- package/dist/finance/management-accounting/investment-appraisal.d.mts +7 -0
- package/dist/finance/management-accounting/investment-appraisal.mjs +148 -0
- package/dist/finance/management-accounting/management-case.d.mts +8 -0
- package/dist/finance/management-accounting/management-case.mjs +91 -0
- package/dist/finance/management-accounting/master-budget.d.mts +7 -0
- package/dist/finance/management-accounting/master-budget.mjs +137 -0
- package/dist/finance/management-accounting/production-costing.d.mts +8 -0
- package/dist/finance/management-accounting/production-costing.mjs +214 -0
- package/dist/finance/management-accounting/types.d.mts +644 -0
- package/dist/finance/management-accounting/variances.d.mts +7 -0
- package/dist/finance/management-accounting/variances.mjs +150 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +1 -1
- package/dist/math/analysis.d.mts +61 -0
- package/dist/math/analysis.mjs +187 -0
- package/dist/math/answer-check.d.mts +50 -0
- package/dist/math/answer-check.mjs +106 -0
- package/dist/math/calculus.d.mts +4 -9
- package/dist/math/calculus.mjs +216 -7
- package/dist/math/complex.d.mts +93 -0
- package/dist/math/complex.mjs +239 -0
- package/dist/math/expr.d.mts +23 -0
- package/dist/math/expr.mjs +36 -0
- package/dist/math/index.d.mts +8 -22
- package/dist/math/index.mjs +8 -37
- package/dist/math/latex.mjs +2 -1
- package/dist/math/parse.mjs +1 -1
- package/dist/math/poly.d.mts +55 -0
- package/dist/math/poly.mjs +273 -0
- package/dist/math/rearrange.d.mts +14 -0
- package/dist/math/rearrange.mjs +125 -0
- package/dist/math/solve.d.mts +21 -0
- package/dist/math/solve.mjs +75 -0
- package/dist/networking/addressing.d.mts +26 -0
- package/dist/networking/addressing.mjs +33 -0
- package/dist/networking/cloud/access.d.mts +36 -0
- package/dist/networking/cloud/access.mjs +95 -0
- package/dist/networking/cloud/containers.d.mts +43 -0
- package/dist/networking/cloud/containers.mjs +54 -0
- package/dist/networking/cloud/edge.d.mts +17 -0
- package/dist/networking/cloud/edge.mjs +31 -0
- package/dist/networking/cloud/failure-domains.d.mts +19 -0
- package/dist/networking/cloud/failure-domains.mjs +22 -0
- package/dist/networking/cloud/geo-routing.d.mts +22 -0
- package/dist/networking/cloud/geo-routing.mjs +64 -0
- package/dist/networking/cloud/index.d.mts +18 -0
- package/dist/networking/cloud/index.mjs +19 -0
- package/dist/networking/cloud/inference-reliability.d.mts +30 -0
- package/dist/networking/cloud/inference-reliability.mjs +76 -0
- package/dist/networking/cloud/inference.d.mts +118 -0
- package/dist/networking/cloud/inference.mjs +179 -0
- package/dist/networking/cloud/infrastructure.d.mts +45 -0
- package/dist/networking/cloud/infrastructure.mjs +96 -0
- package/dist/networking/cloud/observability.d.mts +24 -0
- package/dist/networking/cloud/observability.mjs +34 -0
- package/dist/networking/cloud/orchestration.d.mts +32 -0
- package/dist/networking/cloud/orchestration.mjs +38 -0
- package/dist/networking/cloud/recovery.d.mts +21 -0
- package/dist/networking/cloud/recovery.mjs +27 -0
- package/dist/networking/cloud/releases.d.mts +42 -0
- package/dist/networking/cloud/releases.mjs +135 -0
- package/dist/networking/cloud/scaling.d.mts +25 -0
- package/dist/networking/cloud/scaling.mjs +65 -0
- package/dist/networking/cloud/secrets.d.mts +39 -0
- package/dist/networking/cloud/secrets.mjs +68 -0
- package/dist/networking/cloud/server-deployment.d.mts +29 -0
- package/dist/networking/cloud/server-deployment.mjs +72 -0
- package/dist/networking/cloud/storage.d.mts +16 -0
- package/dist/networking/cloud/storage.mjs +58 -0
- package/dist/networking/cloud/vpc.d.mts +18 -0
- package/dist/networking/cloud/vpc.mjs +100 -0
- package/dist/networking/delivery.d.mts +34 -0
- package/dist/networking/delivery.mjs +52 -0
- package/dist/networking/index.d.mts +47 -0
- package/dist/networking/index.mjs +47 -0
- package/dist/networking/ipv6.d.mts +28 -0
- package/dist/networking/ipv6.mjs +17 -0
- package/dist/networking/journeys.d.mts +83 -0
- package/dist/networking/journeys.mjs +161 -0
- package/dist/networking/models/airtime.d.mts +87 -0
- package/dist/networking/models/airtime.mjs +130 -0
- package/dist/networking/models/cellular.d.mts +157 -0
- package/dist/networking/models/cellular.mjs +252 -0
- package/dist/networking/models/encapsulation.d.mts +98 -0
- package/dist/networking/models/encapsulation.mjs +132 -0
- package/dist/networking/models/handover.d.mts +116 -0
- package/dist/networking/models/handover.mjs +209 -0
- package/dist/networking/models/handshake.d.mts +90 -0
- package/dist/networking/models/handshake.mjs +122 -0
- package/dist/networking/models/index.d.mts +14 -0
- package/dist/networking/models/index.mjs +15 -0
- package/dist/networking/models/media.d.mts +82 -0
- package/dist/networking/models/media.mjs +188 -0
- package/dist/networking/models/satellite.d.mts +86 -0
- package/dist/networking/models/satellite.mjs +121 -0
- package/dist/networking/models/spectrum.d.mts +83 -0
- package/dist/networking/models/spectrum.mjs +235 -0
- package/dist/networking/models/switch.d.mts +80 -0
- package/dist/networking/models/switch.mjs +155 -0
- package/dist/networking/models/vlan.d.mts +62 -0
- package/dist/networking/models/vlan.mjs +100 -0
- package/dist/networking/models/vpn.d.mts +66 -0
- package/dist/networking/models/vpn.mjs +125 -0
- package/dist/networking/models/wifi-privacy.d.mts +82 -0
- package/dist/networking/models/wifi-privacy.mjs +130 -0
- package/dist/networking/models/wifi.d.mts +240 -0
- package/dist/networking/models/wifi.mjs +562 -0
- package/dist/networking/nat-traversal.d.mts +24 -0
- package/dist/networking/nat-traversal.mjs +38 -0
- package/dist/networking/protocols.d.mts +17 -0
- package/dist/networking/protocols.mjs +57 -0
- package/dist/networking/queue.d.mts +12 -0
- package/dist/networking/queue.mjs +18 -0
- package/dist/networking/route-learning.d.mts +23 -0
- package/dist/networking/route-learning.mjs +43 -0
- package/dist/networking/routing.d.mts +11 -0
- package/dist/networking/routing.mjs +25 -0
- package/dist/networking/signals.d.mts +26 -0
- package/dist/networking/signals.mjs +35 -0
- package/dist/networking/subnet.d.mts +49 -0
- package/dist/networking/subnet.mjs +89 -0
- package/dist/networking/tcp-reliability.d.mts +24 -0
- package/dist/networking/tcp-reliability.mjs +38 -0
- package/dist/networking/topology/contract.d.mts +123 -0
- package/dist/networking/topology/index.d.mts +4 -0
- package/dist/networking/topology/index.mjs +4 -0
- package/dist/networking/topology/presets.d.mts +7 -0
- package/dist/networking/topology/presets.mjs +302 -0
- package/dist/networking/topology/simulation.d.mts +8 -0
- package/dist/networking/topology/simulation.mjs +179 -0
- package/dist/networking/wireless.d.mts +11 -0
- package/dist/networking/wireless.mjs +17 -0
- package/dist/optics/imaging.d.mts +218 -0
- package/dist/optics/imaging.mjs +276 -0
- package/dist/optics/index.d.mts +7 -0
- package/dist/optics/index.mjs +8 -0
- package/dist/optics/laws.d.mts +70 -0
- package/dist/optics/laws.mjs +195 -0
- package/dist/optics/prism.d.mts +148 -0
- package/dist/optics/prism.mjs +197 -0
- package/dist/optics/refraction.d.mts +201 -0
- package/dist/optics/refraction.mjs +270 -0
- package/dist/optics/wave-optics.d.mts +171 -0
- package/dist/optics/wave-optics.mjs +259 -0
- package/dist/physics/ac/index.d.mts +183 -0
- package/dist/physics/ac/index.mjs +203 -0
- package/dist/physics/dynamics/forces.d.mts +98 -0
- package/dist/physics/dynamics/forces.mjs +153 -0
- package/dist/physics/dynamics/friction.d.mts +76 -0
- package/dist/physics/dynamics/friction.mjs +119 -0
- package/dist/physics/dynamics/system.d.mts +68 -0
- package/dist/physics/dynamics/system.mjs +125 -0
- package/dist/physics/electrostatics/index.d.mts +169 -0
- package/dist/physics/electrostatics/index.mjs +249 -0
- package/dist/physics/energy/centre-of-mass.d.mts +115 -0
- package/dist/physics/energy/centre-of-mass.mjs +180 -0
- package/dist/physics/energy/conservation.d.mts +81 -0
- package/dist/physics/energy/conservation.mjs +129 -0
- package/dist/physics/energy/power.d.mts +90 -0
- package/dist/physics/energy/power.mjs +167 -0
- package/dist/physics/energy/spring.d.mts +73 -0
- package/dist/physics/energy/spring.mjs +129 -0
- package/dist/physics/energy/store.d.mts +63 -0
- package/dist/physics/energy/store.mjs +108 -0
- package/dist/physics/energy/theorem.d.mts +65 -0
- package/dist/physics/energy/theorem.mjs +113 -0
- package/dist/physics/energy/work.d.mts +114 -0
- package/dist/physics/energy/work.mjs +219 -0
- package/dist/physics/gravitation/body.d.mts +85 -0
- package/dist/physics/gravitation/body.mjs +168 -0
- package/dist/physics/gravitation/kepler.d.mts +127 -0
- package/dist/physics/gravitation/kepler.mjs +216 -0
- package/dist/physics/gravitation/law.d.mts +117 -0
- package/dist/physics/gravitation/law.mjs +175 -0
- package/dist/physics/gravitation/orbit.d.mts +119 -0
- package/dist/physics/gravitation/orbit.mjs +202 -0
- package/dist/physics/gravitation/potential.d.mts +114 -0
- package/dist/physics/gravitation/potential.mjs +202 -0
- package/dist/physics/gravitation/variation.d.mts +97 -0
- package/dist/physics/gravitation/variation.mjs +175 -0
- package/dist/physics/index.d.mts +35 -0
- package/dist/physics/index.mjs +36 -0
- package/dist/physics/integral-sweep.d.mts +63 -0
- package/dist/physics/integral-sweep.mjs +126 -0
- package/dist/physics/kinematics/equations.d.mts +47 -0
- package/dist/physics/kinematics/equations.mjs +126 -0
- package/dist/physics/kinematics/free-fall.d.mts +53 -0
- package/dist/physics/kinematics/free-fall.mjs +71 -0
- package/dist/physics/kinematics/given.d.mts +16 -0
- package/dist/physics/kinematics/given.mjs +55 -0
- package/dist/physics/kinematics/roots.d.mts +41 -0
- package/dist/physics/kinematics/roots.mjs +72 -0
- package/dist/physics/kinematics/solve.d.mts +52 -0
- package/dist/physics/kinematics/solve.mjs +172 -0
- package/dist/physics/magnetism/biot-savart.d.mts +161 -0
- package/dist/physics/magnetism/biot-savart.mjs +353 -0
- package/dist/physics/magnetism/flux.d.mts +94 -0
- package/dist/physics/magnetism/flux.mjs +313 -0
- package/dist/physics/magnetism/geomagnetism.d.mts +151 -0
- package/dist/physics/magnetism/geomagnetism.mjs +184 -0
- package/dist/physics/magnetism/index.d.mts +12 -0
- package/dist/physics/magnetism/index.mjs +74 -0
- package/dist/physics/magnetism/lorentz.d.mts +28 -0
- package/dist/physics/magnetism/lorentz.mjs +88 -0
- package/dist/physics/magnetism/magnetic-force.d.mts +102 -0
- package/dist/physics/magnetism/magnetic-force.mjs +169 -0
- package/dist/physics/momentum/collide.d.mts +77 -0
- package/dist/physics/momentum/collide.mjs +115 -0
- package/dist/physics/momentum/impulse.d.mts +89 -0
- package/dist/physics/momentum/impulse.mjs +159 -0
- package/dist/physics/momentum/planar.d.mts +60 -0
- package/dist/physics/momentum/planar.mjs +110 -0
- package/dist/physics/projectile.d.mts +107 -0
- package/dist/physics/projectile.mjs +185 -0
- package/dist/physics/rotation/angular.d.mts +85 -0
- package/dist/physics/rotation/angular.mjs +130 -0
- package/dist/physics/rotation/circular.d.mts +79 -0
- package/dist/physics/rotation/circular.mjs +131 -0
- package/dist/physics/rotation/inertia.d.mts +164 -0
- package/dist/physics/rotation/inertia.mjs +332 -0
- package/dist/physics/rotation/torque.d.mts +65 -0
- package/dist/physics/rotation/torque.mjs +134 -0
- package/dist/physics/vectors.d.mts +64 -0
- package/dist/physics/vectors.mjs +114 -0
- package/dist/quantity/index.d.mts +119 -0
- package/dist/quantity/index.mjs +417 -0
- package/dist/relation/derive.d.mts +74 -0
- package/dist/relation/derive.mjs +73 -0
- package/dist/relation/index.d.mts +56 -0
- package/dist/relation/index.mjs +234 -0
- package/dist/scene/evaluators.mjs +1 -1
- package/dist/sim/thermal.mjs +45 -20
- package/dist/thermo/calorimetry.d.mts +207 -0
- package/dist/thermo/calorimetry.mjs +345 -0
- package/dist/thermo/cycles.d.mts +142 -0
- package/dist/thermo/cycles.mjs +256 -0
- package/dist/thermo/entropy.d.mts +87 -0
- package/dist/thermo/entropy.mjs +140 -0
- package/dist/thermo/expansion.d.mts +130 -0
- package/dist/thermo/expansion.mjs +178 -0
- package/dist/thermo/gas.d.mts +197 -0
- package/dist/thermo/gas.mjs +279 -0
- package/dist/thermo/heat-transfer.d.mts +164 -0
- package/dist/thermo/heat-transfer.mjs +217 -0
- package/dist/thermo/index.d.mts +9 -82
- package/dist/thermo/index.mjs +9 -132
- package/dist/thermo/processes.d.mts +95 -0
- package/dist/thermo/processes.mjs +154 -0
- package/dist/thermo/temperature.d.mts +174 -0
- package/dist/thermo/temperature.mjs +236 -0
- package/dist/waves/damping.d.mts +224 -0
- package/dist/waves/damping.mjs +317 -0
- package/dist/waves/doppler.d.mts +72 -0
- package/dist/waves/doppler.mjs +125 -0
- package/dist/waves/index.d.mts +10 -0
- package/dist/waves/index.mjs +10 -0
- package/dist/waves/pendulum.d.mts +130 -0
- package/dist/waves/pendulum.mjs +211 -0
- package/dist/waves/pitch.d.mts +125 -0
- package/dist/waves/pitch.mjs +158 -0
- package/dist/waves/shm.d.mts +170 -0
- package/dist/waves/shm.mjs +279 -0
- package/dist/waves/springs.d.mts +103 -0
- package/dist/waves/springs.mjs +176 -0
- package/dist/waves/superposition.d.mts +124 -0
- package/dist/waves/superposition.mjs +196 -0
- package/dist/waves/wave.d.mts +154 -0
- package/dist/waves/wave.mjs +178 -0
- package/package.json +74 -2
package/dist/finance/bizsim.mjs
CHANGED
|
@@ -1,117 +1,296 @@
|
|
|
1
|
+
import { solveJournal } from "./accounting/solve.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/finance/bizsim.ts
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
4
|
+
const BIZ_ACCOUNTS = [
|
|
5
|
+
{
|
|
6
|
+
id: "cash",
|
|
7
|
+
name: "Cash",
|
|
8
|
+
category: "Asset"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: "inventory",
|
|
12
|
+
name: "Inventory",
|
|
13
|
+
category: "Asset"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "equipment",
|
|
17
|
+
name: "Equipment",
|
|
18
|
+
category: "Asset"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "loan",
|
|
22
|
+
name: "Loan",
|
|
23
|
+
category: "Liability"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "capital",
|
|
27
|
+
name: "Capital",
|
|
28
|
+
category: "Equity"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "retained",
|
|
32
|
+
name: "Retained earnings",
|
|
33
|
+
category: "Equity"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "revenue",
|
|
37
|
+
name: "Revenue",
|
|
38
|
+
category: "Income"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "cogs",
|
|
42
|
+
name: "Cost of sales",
|
|
43
|
+
category: "Expense"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "expenses",
|
|
47
|
+
name: "Operating expenses",
|
|
48
|
+
category: "Expense"
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
function amount(value, label, allowZero = false) {
|
|
52
|
+
if (!Number.isFinite(value) || (allowZero ? value < 0 : value <= 0)) throw new RangeError(`${label} must be ${allowZero ? "non-negative" : "positive"} and finite.`);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
function journal(id, narration, debit, credit, value) {
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
narration,
|
|
59
|
+
lines: [{
|
|
60
|
+
accountId: debit,
|
|
61
|
+
side: "debit",
|
|
62
|
+
amount: value
|
|
63
|
+
}, {
|
|
64
|
+
accountId: credit,
|
|
65
|
+
side: "credit",
|
|
66
|
+
amount: value
|
|
67
|
+
}]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function books(state) {
|
|
71
|
+
const solution = solveJournal({
|
|
72
|
+
accounts: BIZ_ACCOUNTS,
|
|
73
|
+
entries: state.entries
|
|
74
|
+
});
|
|
75
|
+
if (solution.rejectedEntries.length > 0 || !solution.trialBalance.balances || !solution.equation.balances) throw new Error("Business simulation contains invalid journal data.");
|
|
76
|
+
return solution;
|
|
77
|
+
}
|
|
78
|
+
function natural(solution, accountId) {
|
|
79
|
+
return solution.ledger.find((account) => account.id === accountId)?.normalBalance ?? 0;
|
|
80
|
+
}
|
|
81
|
+
function append(state, entry, inventoryQty = state.inventoryQty) {
|
|
82
|
+
return {
|
|
83
|
+
entries: [...state.entries, entry],
|
|
84
|
+
inventoryQty,
|
|
85
|
+
nextEntryNumber: state.nextEntryNumber + 1
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function actionId(state, type) {
|
|
89
|
+
return `biz-${state.nextEntryNumber}-${type}`;
|
|
90
|
+
}
|
|
91
|
+
function initialBiz(opening = {}) {
|
|
92
|
+
const cash = amount(opening.cash ?? 0, "Opening cash", true);
|
|
93
|
+
const inventoryQty = amount(opening.inventoryQty ?? 0, "Opening inventory quantity", true);
|
|
94
|
+
const inventoryValue = amount(opening.inventoryValue ?? 0, "Opening inventory value", true);
|
|
95
|
+
const equipment = amount(opening.equipment ?? 0, "Opening equipment", true);
|
|
96
|
+
const loan = amount(opening.loan ?? 0, "Opening loan", true);
|
|
97
|
+
const retained = opening.retained ?? 0;
|
|
98
|
+
if (!Number.isFinite(retained)) throw new RangeError("Opening retained earnings must be finite.");
|
|
99
|
+
const inferredCapital = cash + inventoryValue + equipment - loan - retained;
|
|
100
|
+
const capital = opening.capital ?? inferredCapital;
|
|
101
|
+
if (!Number.isFinite(capital)) throw new RangeError("Opening capital must be finite.");
|
|
102
|
+
if (Math.abs(cash + inventoryValue + equipment - loan - capital - retained) >= .005) throw new Error("Opening balances do not satisfy Assets = Liabilities + Equity.");
|
|
103
|
+
if (inventoryQty === 0 && inventoryValue !== 0) throw new Error("Opening inventory value requires a positive inventory quantity.");
|
|
104
|
+
const lines = [];
|
|
105
|
+
for (const [accountId, value, side] of [
|
|
106
|
+
[
|
|
107
|
+
"cash",
|
|
108
|
+
cash,
|
|
109
|
+
"debit"
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"inventory",
|
|
113
|
+
inventoryValue,
|
|
114
|
+
"debit"
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
"equipment",
|
|
118
|
+
equipment,
|
|
119
|
+
"debit"
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"loan",
|
|
123
|
+
loan,
|
|
124
|
+
"credit"
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
"capital",
|
|
128
|
+
capital,
|
|
129
|
+
capital >= 0 ? "credit" : "debit"
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
"retained",
|
|
133
|
+
retained,
|
|
134
|
+
retained >= 0 ? "credit" : "debit"
|
|
135
|
+
]
|
|
136
|
+
]) if (value !== 0) lines.push({
|
|
137
|
+
accountId,
|
|
138
|
+
side,
|
|
139
|
+
amount: Math.abs(value)
|
|
140
|
+
});
|
|
141
|
+
const state = {
|
|
142
|
+
entries: lines.length === 0 ? [] : [{
|
|
143
|
+
id: "biz-opening",
|
|
144
|
+
narration: "Opening balances",
|
|
145
|
+
lines
|
|
146
|
+
}],
|
|
147
|
+
inventoryQty,
|
|
148
|
+
nextEntryNumber: 1
|
|
149
|
+
};
|
|
150
|
+
books(state);
|
|
151
|
+
return state;
|
|
152
|
+
}
|
|
153
|
+
function applyBiz(state, action) {
|
|
154
|
+
const solution = books(state);
|
|
155
|
+
const id = actionId(state, action.type);
|
|
156
|
+
switch (action.type) {
|
|
157
|
+
case "invest": return append(state, journal(id, "Owner investment", "cash", "capital", amount(action.amount, "Investment")));
|
|
158
|
+
case "loan": return append(state, journal(id, "Loan received", "cash", "loan", amount(action.amount, "Loan proceeds")));
|
|
159
|
+
case "repay": {
|
|
160
|
+
const value = amount(action.amount, "Loan repayment");
|
|
161
|
+
if (value > natural(solution, "loan")) throw new RangeError("Loan repayment exceeds the outstanding loan.");
|
|
162
|
+
return append(state, journal(id, "Loan principal repaid", "loan", "cash", value));
|
|
163
|
+
}
|
|
164
|
+
case "buyEquipment": return append(state, journal(id, "Equipment purchased for cash", "equipment", "cash", amount(action.amount, "Equipment purchase")));
|
|
165
|
+
case "depreciate": {
|
|
166
|
+
const value = amount(action.amount, "Depreciation");
|
|
167
|
+
if (value > natural(solution, "equipment")) throw new RangeError("Depreciation exceeds equipment book value.");
|
|
168
|
+
return append(state, journal(id, "Depreciation charged", "expenses", "equipment", value));
|
|
169
|
+
}
|
|
170
|
+
case "buyStock": {
|
|
171
|
+
const quantity = amount(action.qty, "Stock quantity");
|
|
172
|
+
const cost = quantity * amount(action.unitCost, "Stock unit cost", true);
|
|
173
|
+
if (cost === 0) throw new RangeError("A stock purchase must have a positive total cost.");
|
|
174
|
+
return append(state, journal(id, "Inventory purchased for cash", "inventory", "cash", cost), state.inventoryQty + quantity);
|
|
175
|
+
}
|
|
49
176
|
case "sell": {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
177
|
+
const quantity = amount(action.qty, "Sale quantity");
|
|
178
|
+
const price = amount(action.price, "Sale price", true);
|
|
179
|
+
if (quantity > state.inventoryQty) throw new RangeError("Sale quantity exceeds inventory on hand.");
|
|
180
|
+
const inventoryValue = natural(solution, "inventory");
|
|
181
|
+
const cost = quantity * (state.inventoryQty === 0 ? 0 : inventoryValue / state.inventoryQty);
|
|
182
|
+
const sales = quantity * price;
|
|
183
|
+
if (sales <= 0) throw new RangeError("A sale must have positive revenue.");
|
|
184
|
+
const lines = [{
|
|
185
|
+
accountId: "cash",
|
|
186
|
+
side: "debit",
|
|
187
|
+
amount: sales
|
|
188
|
+
}, {
|
|
189
|
+
accountId: "revenue",
|
|
190
|
+
side: "credit",
|
|
191
|
+
amount: sales
|
|
192
|
+
}];
|
|
193
|
+
if (cost > 0) lines.push({
|
|
194
|
+
accountId: "cogs",
|
|
195
|
+
side: "debit",
|
|
196
|
+
amount: cost
|
|
197
|
+
}, {
|
|
198
|
+
accountId: "inventory",
|
|
199
|
+
side: "credit",
|
|
200
|
+
amount: cost
|
|
201
|
+
});
|
|
202
|
+
return append(state, {
|
|
203
|
+
id,
|
|
204
|
+
narration: "Inventory sold for cash",
|
|
205
|
+
lines
|
|
206
|
+
}, state.inventoryQty - quantity);
|
|
61
207
|
}
|
|
62
|
-
case "expense": return
|
|
63
|
-
...s,
|
|
64
|
-
cash: s.cash - a.amount,
|
|
65
|
-
expenses: s.expenses + a.amount
|
|
66
|
-
};
|
|
208
|
+
case "expense": return append(state, journal(id, "Operating expense paid", "expenses", "cash", amount(action.amount, "Expense")));
|
|
67
209
|
case "closePeriod": {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
210
|
+
const revenue = natural(solution, "revenue");
|
|
211
|
+
const cogs = natural(solution, "cogs");
|
|
212
|
+
const expenses = natural(solution, "expenses");
|
|
213
|
+
if (revenue === 0 && cogs === 0 && expenses === 0) return state;
|
|
214
|
+
const netProfit = revenue - cogs - expenses;
|
|
215
|
+
const lines = [];
|
|
216
|
+
if (revenue > 0) lines.push({
|
|
217
|
+
accountId: "revenue",
|
|
218
|
+
side: "debit",
|
|
219
|
+
amount: revenue
|
|
220
|
+
});
|
|
221
|
+
if (cogs > 0) lines.push({
|
|
222
|
+
accountId: "cogs",
|
|
223
|
+
side: "credit",
|
|
224
|
+
amount: cogs
|
|
225
|
+
});
|
|
226
|
+
if (expenses > 0) lines.push({
|
|
227
|
+
accountId: "expenses",
|
|
228
|
+
side: "credit",
|
|
229
|
+
amount: expenses
|
|
230
|
+
});
|
|
231
|
+
if (netProfit > 0) lines.push({
|
|
232
|
+
accountId: "retained",
|
|
233
|
+
side: "credit",
|
|
234
|
+
amount: netProfit
|
|
235
|
+
});
|
|
236
|
+
else if (netProfit < 0) lines.push({
|
|
237
|
+
accountId: "retained",
|
|
238
|
+
side: "debit",
|
|
239
|
+
amount: Math.abs(netProfit)
|
|
240
|
+
});
|
|
241
|
+
return append(state, {
|
|
242
|
+
id,
|
|
243
|
+
narration: "Close income and expenses to retained earnings",
|
|
244
|
+
lines
|
|
245
|
+
});
|
|
76
246
|
}
|
|
77
|
-
default: return s;
|
|
78
247
|
}
|
|
79
248
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return actions.reduce(applyBiz, initialBiz(init));
|
|
249
|
+
function runBiz(actions, opening = {}) {
|
|
250
|
+
return actions.reduce(applyBiz, initialBiz(opening));
|
|
83
251
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
252
|
+
function incomeStatement(state) {
|
|
253
|
+
const solution = books(state);
|
|
254
|
+
const revenue = natural(solution, "revenue");
|
|
255
|
+
const cogs = natural(solution, "cogs");
|
|
256
|
+
const expenses = natural(solution, "expenses");
|
|
257
|
+
const grossProfit = revenue - cogs;
|
|
87
258
|
return {
|
|
88
|
-
revenue
|
|
89
|
-
cogs
|
|
259
|
+
revenue,
|
|
260
|
+
cogs,
|
|
90
261
|
grossProfit,
|
|
91
|
-
expenses
|
|
92
|
-
netProfit: grossProfit -
|
|
262
|
+
expenses,
|
|
263
|
+
netProfit: grossProfit - expenses
|
|
93
264
|
};
|
|
94
265
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
266
|
+
function balanceSheet(state) {
|
|
267
|
+
const solution = books(state);
|
|
268
|
+
const cash = natural(solution, "cash");
|
|
269
|
+
const inventory = natural(solution, "inventory");
|
|
270
|
+
const equipment = natural(solution, "equipment");
|
|
271
|
+
const loan = natural(solution, "loan");
|
|
272
|
+
const capital = natural(solution, "capital");
|
|
273
|
+
const retained = natural(solution, "retained");
|
|
274
|
+
const openProfit = solution.equation.profit;
|
|
275
|
+
const totalAssets = cash + inventory + equipment;
|
|
276
|
+
const totalEquity = capital + retained + openProfit;
|
|
101
277
|
return {
|
|
102
|
-
cash
|
|
103
|
-
inventory
|
|
104
|
-
equipment
|
|
278
|
+
cash,
|
|
279
|
+
inventory,
|
|
280
|
+
equipment,
|
|
105
281
|
totalAssets,
|
|
106
|
-
loan
|
|
107
|
-
capital
|
|
108
|
-
retained
|
|
282
|
+
loan,
|
|
283
|
+
capital,
|
|
284
|
+
retained,
|
|
109
285
|
openProfit,
|
|
110
286
|
totalEquity,
|
|
111
|
-
totalLiabilitiesEquity,
|
|
112
|
-
balances:
|
|
287
|
+
totalLiabilitiesEquity: loan + totalEquity,
|
|
288
|
+
balances: solution.trialBalance.balances && solution.equation.balances
|
|
113
289
|
};
|
|
114
290
|
}
|
|
291
|
+
function businessBooks(state) {
|
|
292
|
+
return books(state);
|
|
293
|
+
}
|
|
115
294
|
|
|
116
295
|
//#endregion
|
|
117
|
-
export { applyBiz, balanceSheet, incomeStatement, initialBiz, runBiz };
|
|
296
|
+
export { applyBiz, balanceSheet, businessBooks, incomeStatement, initialBiz, runBiz };
|
package/dist/finance/index.d.mts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountCategory, AccountDefinition, AccountRole, AccountingCase, AccountingCaseResult, AccountingCheck, AccountingDiagnostic, AccountingEquation, AccountingExpectation, AccountingPolicy, AccountingSolution, AdjustmentFact, AdjustmentResult, BankReconciliationItem, BankReconciliationResult, BusinessEvent, ClubMember, ClubMemberState, ClubMemberTiming, ClubStatementFacts, ClubStatementResult, ClubSubscriptionResult, ControlAccountFacts, ControlAccountResult, ExplanationStep, FinancialAnalysisComparison, FinancialAnalysisFacts, FinancialAnalysisResult, FinancialRatioAssessment, FinancialRatioBenchmark, FinancialRatioFamily, FinancialRatioKey, FinancialRatioMetric, FinancialStatements, JournalEntry, JournalLine, LedgerAccount, LedgerPosting, LimitedCompanyStatementFacts, LimitedCompanyStatementResult, ManufacturingAccountFacts, ManufacturingAccountResult, ManufacturingFlowStage, ManufacturingTradingFacts, ManufacturingTradingResult, PartnerAppropriation, PartnerFacts, PartnershipAgreement, PartnershipResult, PostingSide, SoleTraderPeriodCase, SoleTraderPeriodResult, SoleTraderStatementFacts, SoleTraderStatementResult, StatementLine, StatementSection, SuspenseCorrectionFact, SuspenseDiscoveredError, SuspenseMovement, SuspenseReconstructionFacts, SuspenseReconstructionResult, TrialBalance, TrialBalanceErrorDiagnosis, TrialBalanceErrorType, TrialBalanceLine } from "./accounting/types.mjs";
|
|
2
|
+
import { DEFAULT_ACCOUNTING_POLICY, amountScale, fromMinor, toMinor } from "./accounting/precision.mjs";
|
|
3
|
+
import { changeSide, deriveNaturalEquation, normalBalance, statementOf, totalsBalance } from "./accounting/rules.mjs";
|
|
4
|
+
import { validateChart, validateJournalEntry } from "./accounting/validate.mjs";
|
|
5
|
+
import { journalizeBusinessEvent, journalizeBusinessEvents } from "./accounting/journalize.mjs";
|
|
6
|
+
import { applyAdjustments, produceAdjustment } from "./accounting/adjustments.mjs";
|
|
7
|
+
import { createSuspenseCorrection, diagnoseTrialBalanceError, reconcileBank, reconstructSuspenseAccount, solveControlAccount } from "./accounting/verification.mjs";
|
|
8
|
+
import { solveCashSettledSoleTraderScenario, solveSoleTraderStatements } from "./accounting/statements.mjs";
|
|
9
|
+
import { salaryForEqualPartnershipShares, solvePartnershipAppropriation } from "./accounting/partnership.mjs";
|
|
10
|
+
import { solveDividendSettledCompanyScenario, solveLimitedCompanyStatements } from "./accounting/company-statements.mjs";
|
|
11
|
+
import { CLUB_MEMBER_STATES, clubMemberCrossesYear, clubMemberTiming, solveClubStatements, solveClubSubscriptions } from "./accounting/clubs.mjs";
|
|
12
|
+
import { solveManufacturingAccount, solveManufacturingTradingFlow } from "./accounting/manufacturing.mjs";
|
|
13
|
+
import { solveSoleTraderPeriod } from "./accounting/period-case.mjs";
|
|
14
|
+
import { analyzeFinancialPerformance, assessFinancialPerformance, compareFinancialPerformance } from "./accounting/analysis.mjs";
|
|
15
|
+
import { runAccountingCase } from "./accounting/harness.mjs";
|
|
16
|
+
import { deriveEquation, deriveStatements, deriveTrialBalance, postLedger } from "./accounting/post.mjs";
|
|
17
|
+
import { SolveJournalOptions, solveBusinessProblem, solveJournal } from "./accounting/solve.mjs";
|
|
18
|
+
import { BalanceSheet, BizAction, BizOpeningBalances, BizState, IncomeStatement, applyBiz, balanceSheet, businessBooks, incomeStatement, initialBiz, runBiz } from "./bizsim.mjs";
|
|
19
|
+
import { npv, payback } from "./investment-math.mjs";
|
|
2
20
|
|
|
3
21
|
//#region src/finance/index.d.ts
|
|
4
22
|
/** Simple interest I = P·r·t (interest only, not the total). */
|
|
@@ -67,52 +85,11 @@ declare function breakEven({
|
|
|
67
85
|
declare function profitAt(units: number, m: CostModel): number;
|
|
68
86
|
/** Margin of safety = actual output − break-even output (units). */
|
|
69
87
|
declare function marginOfSafety(currentUnits: number, breakEvenUnits: number): number;
|
|
70
|
-
type InvMethod = 'fifo' | 'lifo' | 'avco';
|
|
71
|
-
interface InvMove {
|
|
72
|
-
type: 'buy' | 'sell';
|
|
73
|
-
qty: number;
|
|
74
|
-
unitCost?: number;
|
|
75
|
-
}
|
|
76
|
-
interface InvResult {
|
|
77
|
-
cogs: number;
|
|
78
|
-
closingValue: number;
|
|
79
|
-
closingQty: number;
|
|
80
|
-
}
|
|
81
|
-
/** Value stock and cost of goods sold under FIFO, LIFO or weighted-average (AVCO). */
|
|
82
|
-
declare function inventoryValue(method: InvMethod, moves: InvMove[]): InvResult;
|
|
83
88
|
/** Economic order quantity: √(2·D·S / H) — demand D, order cost S, holding cost/unit H. */
|
|
84
89
|
declare function eoq(annualDemand: number, orderCost: number, holdingCostPerUnit: number): number;
|
|
85
90
|
/** Reorder level = usage during the lead time, plus any buffer (safety) stock. */
|
|
86
91
|
declare function reorderLevel(usagePerDay: number, leadTimeDays: number, bufferStock?: number): number;
|
|
87
92
|
/** Split a total cost across cost-centres in proportion to a basis (floor area sq ft, headcount, machine hours…). */
|
|
88
93
|
declare function apportion(total: number, weights: number[]): number[];
|
|
89
|
-
interface FinInputs {
|
|
90
|
-
currentAssets: number;
|
|
91
|
-
inventory: number;
|
|
92
|
-
currentLiabilities: number;
|
|
93
|
-
nonCurrentLiabilities: number;
|
|
94
|
-
equity: number;
|
|
95
|
-
revenue: number;
|
|
96
|
-
costOfSales: number;
|
|
97
|
-
expenses?: number;
|
|
98
|
-
grossProfit?: number;
|
|
99
|
-
netProfit?: number;
|
|
100
|
-
capitalEmployed?: number;
|
|
101
|
-
}
|
|
102
|
-
interface Ratios {
|
|
103
|
-
current: number;
|
|
104
|
-
quick: number;
|
|
105
|
-
gearing: number;
|
|
106
|
-
grossMargin: number;
|
|
107
|
-
netMargin: number;
|
|
108
|
-
roce: number;
|
|
109
|
-
inventoryTurnover: number;
|
|
110
|
-
}
|
|
111
|
-
/** Standard analysis ratios from summary figures (liquidity, gearing, profitability, efficiency). */
|
|
112
|
-
declare function ratios(f: FinInputs): Ratios;
|
|
113
|
-
/** Net present value; `cashflows[0]` is the initial outlay (usually negative). */
|
|
114
|
-
declare function npv(rate: number, cashflows: number[]): number;
|
|
115
|
-
/** Payback period in years (fractional), from year-0 outlay + yearly inflows. */
|
|
116
|
-
declare function payback(cashflows: number[]): number;
|
|
117
94
|
//#endregion
|
|
118
|
-
export { AmortResult, AmortRow, BalanceSheet, BizAction, BizState, BreakEven, CostModel, DepRow,
|
|
95
|
+
export { AccountCategory, AccountDefinition, AccountRole, AccountingCase, AccountingCaseResult, AccountingCheck, AccountingDiagnostic, AccountingEquation, AccountingExpectation, AccountingPolicy, AccountingSolution, AdjustmentFact, AdjustmentResult, AmortResult, AmortRow, BalanceSheet, BankReconciliationItem, BankReconciliationResult, BizAction, BizOpeningBalances, BizState, BreakEven, BusinessEvent, CLUB_MEMBER_STATES, ClubMember, ClubMemberState, ClubMemberTiming, ClubStatementFacts, ClubStatementResult, ClubSubscriptionResult, ControlAccountFacts, ControlAccountResult, CostModel, DEFAULT_ACCOUNTING_POLICY, DepRow, ExplanationStep, FinancialAnalysisComparison, FinancialAnalysisFacts, FinancialAnalysisResult, FinancialRatioAssessment, FinancialRatioBenchmark, FinancialRatioFamily, FinancialRatioKey, FinancialRatioMetric, FinancialStatements, IncomeStatement, JournalEntry, JournalLine, LedgerAccount, LedgerPosting, LimitedCompanyStatementFacts, LimitedCompanyStatementResult, ManufacturingAccountFacts, ManufacturingAccountResult, ManufacturingFlowStage, ManufacturingTradingFacts, ManufacturingTradingResult, PartnerAppropriation, PartnerFacts, PartnershipAgreement, PartnershipResult, PostingSide, SoleTraderPeriodCase, SoleTraderPeriodResult, SoleTraderStatementFacts, SoleTraderStatementResult, SolveJournalOptions, StatementLine, StatementSection, SuspenseCorrectionFact, SuspenseDiscoveredError, SuspenseMovement, SuspenseReconstructionFacts, SuspenseReconstructionResult, TrialBalance, TrialBalanceErrorDiagnosis, TrialBalanceErrorType, TrialBalanceLine, amortize, amountScale, analyzeFinancialPerformance, applyAdjustments, applyBiz, apportion, assessFinancialPerformance, balanceSheet, breakEven, businessBooks, changeSide, clubMemberCrossesYear, clubMemberTiming, compareFinancialPerformance, compoundAmount, compoundInterest, createSuspenseCorrection, deriveEquation, deriveNaturalEquation, deriveStatements, deriveTrialBalance, diagnoseTrialBalanceError, effectiveRate, eoq, fromMinor, futureValue, growthSeries, incomeStatement, initialBiz, journalizeBusinessEvent, journalizeBusinessEvents, marginOfSafety, normalBalance, npv, payback, postLedger, presentValue, produceAdjustment, profitAt, reconcileBank, reconstructSuspenseAccount, reducingBalance, reorderLevel, rule72, runAccountingCase, runBiz, salaryForEqualPartnershipShares, simpleInterest, solveBusinessProblem, solveCashSettledSoleTraderScenario, solveClubStatements, solveClubSubscriptions, solveControlAccount, solveDividendSettledCompanyScenario, solveJournal, solveLimitedCompanyStatements, solveManufacturingAccount, solveManufacturingTradingFlow, solvePartnershipAppropriation, solveSoleTraderPeriod, solveSoleTraderStatements, statementOf, straightLine, toMinor, totalsBalance, validateChart, validateJournalEntry };
|
package/dist/finance/index.mjs
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { journalizeBusinessEvent, journalizeBusinessEvents } from "./accounting/journalize.mjs";
|
|
2
|
+
import { DEFAULT_ACCOUNTING_POLICY, amountScale, fromMinor, toMinor } from "./accounting/precision.mjs";
|
|
3
|
+
import { changeSide, deriveNaturalEquation, normalBalance, statementOf, totalsBalance } from "./accounting/rules.mjs";
|
|
4
|
+
import { deriveEquation, deriveStatements, deriveTrialBalance, postLedger } from "./accounting/post.mjs";
|
|
5
|
+
import { validateChart, validateJournalEntry } from "./accounting/validate.mjs";
|
|
6
|
+
import { solveBusinessProblem, solveJournal } from "./accounting/solve.mjs";
|
|
7
|
+
import { applyBiz, balanceSheet, businessBooks, incomeStatement, initialBiz, runBiz } from "./bizsim.mjs";
|
|
8
|
+
import { applyAdjustments, produceAdjustment } from "./accounting/adjustments.mjs";
|
|
9
|
+
import { createSuspenseCorrection, diagnoseTrialBalanceError, reconcileBank, reconstructSuspenseAccount, solveControlAccount } from "./accounting/verification.mjs";
|
|
10
|
+
import { solveCashSettledSoleTraderScenario, solveSoleTraderStatements } from "./accounting/statements.mjs";
|
|
11
|
+
import { salaryForEqualPartnershipShares, solvePartnershipAppropriation } from "./accounting/partnership.mjs";
|
|
12
|
+
import { solveDividendSettledCompanyScenario, solveLimitedCompanyStatements } from "./accounting/company-statements.mjs";
|
|
13
|
+
import { CLUB_MEMBER_STATES, clubMemberCrossesYear, clubMemberTiming, solveClubStatements, solveClubSubscriptions } from "./accounting/clubs.mjs";
|
|
14
|
+
import { solveManufacturingAccount, solveManufacturingTradingFlow } from "./accounting/manufacturing.mjs";
|
|
15
|
+
import { solveSoleTraderPeriod } from "./accounting/period-case.mjs";
|
|
16
|
+
import { analyzeFinancialPerformance, assessFinancialPerformance, compareFinancialPerformance } from "./accounting/analysis.mjs";
|
|
17
|
+
import { runAccountingCase } from "./accounting/harness.mjs";
|
|
18
|
+
import { npv, payback } from "./investment-math.mjs";
|
|
2
19
|
|
|
3
20
|
//#region src/finance/index.ts
|
|
4
21
|
/** Simple interest I = P·r·t (interest only, not the total). */
|
|
@@ -110,52 +127,6 @@ function profitAt(units, m) {
|
|
|
110
127
|
function marginOfSafety(currentUnits, breakEvenUnits) {
|
|
111
128
|
return currentUnits - breakEvenUnits;
|
|
112
129
|
}
|
|
113
|
-
/** Value stock and cost of goods sold under FIFO, LIFO or weighted-average (AVCO). */
|
|
114
|
-
function inventoryValue(method, moves) {
|
|
115
|
-
let cogs = 0;
|
|
116
|
-
if (method === "avco") {
|
|
117
|
-
let qty = 0, val = 0;
|
|
118
|
-
for (const m of moves) if (m.type === "buy") {
|
|
119
|
-
qty += m.qty;
|
|
120
|
-
val += m.qty * (m.unitCost ?? 0);
|
|
121
|
-
} else {
|
|
122
|
-
const avg = qty > 0 ? val / qty : 0;
|
|
123
|
-
cogs += m.qty * avg;
|
|
124
|
-
val -= m.qty * avg;
|
|
125
|
-
qty -= m.qty;
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
cogs,
|
|
129
|
-
closingValue: val,
|
|
130
|
-
closingQty: qty
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
const lots = [];
|
|
134
|
-
for (const m of moves) {
|
|
135
|
-
if (m.type === "buy") {
|
|
136
|
-
lots.push({
|
|
137
|
-
qty: m.qty,
|
|
138
|
-
cost: m.unitCost ?? 0
|
|
139
|
-
});
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
let need = m.qty;
|
|
143
|
-
while (need > 0 && lots.length) {
|
|
144
|
-
const idx = method === "fifo" ? 0 : lots.length - 1;
|
|
145
|
-
const lot = lots[idx];
|
|
146
|
-
const take = Math.min(need, lot.qty);
|
|
147
|
-
cogs += take * lot.cost;
|
|
148
|
-
lot.qty -= take;
|
|
149
|
-
need -= take;
|
|
150
|
-
if (lot.qty === 0) lots.splice(idx, 1);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
cogs,
|
|
155
|
-
closingValue: lots.reduce((a, l) => a + l.qty * l.cost, 0),
|
|
156
|
-
closingQty: lots.reduce((a, l) => a + l.qty, 0)
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
130
|
/** Economic order quantity: √(2·D·S / H) — demand D, order cost S, holding cost/unit H. */
|
|
160
131
|
function eoq(annualDemand, orderCost, holdingCostPerUnit) {
|
|
161
132
|
return holdingCostPerUnit > 0 ? Math.sqrt(2 * annualDemand * orderCost / holdingCostPerUnit) : Infinity;
|
|
@@ -169,35 +140,6 @@ function apportion(total, weights) {
|
|
|
169
140
|
const sum = weights.reduce((a, b) => a + b, 0) || 1;
|
|
170
141
|
return weights.map((w) => total * w / sum);
|
|
171
142
|
}
|
|
172
|
-
/** Standard analysis ratios from summary figures (liquidity, gearing, profitability, efficiency). */
|
|
173
|
-
function ratios(f) {
|
|
174
|
-
const grossProfit = f.grossProfit ?? f.revenue - f.costOfSales;
|
|
175
|
-
const netProfit = f.netProfit ?? grossProfit - (f.expenses ?? 0);
|
|
176
|
-
const capEmp = f.capitalEmployed ?? f.equity + f.nonCurrentLiabilities;
|
|
177
|
-
return {
|
|
178
|
-
current: f.currentAssets / f.currentLiabilities,
|
|
179
|
-
quick: (f.currentAssets - f.inventory) / f.currentLiabilities,
|
|
180
|
-
gearing: f.nonCurrentLiabilities / (f.equity + f.nonCurrentLiabilities),
|
|
181
|
-
grossMargin: grossProfit / f.revenue,
|
|
182
|
-
netMargin: netProfit / f.revenue,
|
|
183
|
-
roce: netProfit / capEmp,
|
|
184
|
-
inventoryTurnover: f.costOfSales / f.inventory
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/** Net present value; `cashflows[0]` is the initial outlay (usually negative). */
|
|
188
|
-
function npv(rate, cashflows) {
|
|
189
|
-
return cashflows.reduce((a, cf, t) => a + cf / Math.pow(1 + rate, t), 0);
|
|
190
|
-
}
|
|
191
|
-
/** Payback period in years (fractional), from year-0 outlay + yearly inflows. */
|
|
192
|
-
function payback(cashflows) {
|
|
193
|
-
let cum = 0;
|
|
194
|
-
for (let t = 0; t < cashflows.length; t++) {
|
|
195
|
-
const prev = cum;
|
|
196
|
-
cum += cashflows[t];
|
|
197
|
-
if (cum >= 0 && t > 0) return t - 1 + -prev / cashflows[t];
|
|
198
|
-
}
|
|
199
|
-
return Infinity;
|
|
200
|
-
}
|
|
201
143
|
|
|
202
144
|
//#endregion
|
|
203
|
-
export { amortize, applyBiz, apportion, balanceSheet, breakEven, compoundAmount, compoundInterest, effectiveRate, eoq, futureValue, growthSeries, incomeStatement, initialBiz,
|
|
145
|
+
export { CLUB_MEMBER_STATES, DEFAULT_ACCOUNTING_POLICY, amortize, amountScale, analyzeFinancialPerformance, applyAdjustments, applyBiz, apportion, assessFinancialPerformance, balanceSheet, breakEven, businessBooks, changeSide, clubMemberCrossesYear, clubMemberTiming, compareFinancialPerformance, compoundAmount, compoundInterest, createSuspenseCorrection, deriveEquation, deriveNaturalEquation, deriveStatements, deriveTrialBalance, diagnoseTrialBalanceError, effectiveRate, eoq, fromMinor, futureValue, growthSeries, incomeStatement, initialBiz, journalizeBusinessEvent, journalizeBusinessEvents, marginOfSafety, normalBalance, npv, payback, postLedger, presentValue, produceAdjustment, profitAt, reconcileBank, reconstructSuspenseAccount, reducingBalance, reorderLevel, rule72, runAccountingCase, runBiz, salaryForEqualPartnershipShares, simpleInterest, solveBusinessProblem, solveCashSettledSoleTraderScenario, solveClubStatements, solveClubSubscriptions, solveControlAccount, solveDividendSettledCompanyScenario, solveJournal, solveLimitedCompanyStatements, solveManufacturingAccount, solveManufacturingTradingFlow, solvePartnershipAppropriation, solveSoleTraderPeriod, solveSoleTraderStatements, statementOf, straightLine, toMinor, totalsBalance, validateChart, validateJournalEntry };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/finance/investment-math.d.ts
|
|
2
|
+
/** Net present value; `cashflows[0]` is the initial outlay, normally negative. */
|
|
3
|
+
declare function npv(rate: number, cashflows: readonly number[]): number;
|
|
4
|
+
/** Payback period with within-period interpolation; returns Infinity when unrecovered. */
|
|
5
|
+
declare function payback(cashflows: readonly number[]): number;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { npv, payback };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/finance/investment-math.ts
|
|
2
|
+
/** Net present value; `cashflows[0]` is the initial outlay, normally negative. */
|
|
3
|
+
function npv(rate, cashflows) {
|
|
4
|
+
return cashflows.reduce((total, cashflow, period) => total + cashflow / Math.pow(1 + rate, period), 0);
|
|
5
|
+
}
|
|
6
|
+
/** Payback period with within-period interpolation; returns Infinity when unrecovered. */
|
|
7
|
+
function payback(cashflows) {
|
|
8
|
+
let cumulative = 0;
|
|
9
|
+
for (let period = 0; period < cashflows.length; period += 1) {
|
|
10
|
+
const previous = cumulative;
|
|
11
|
+
cumulative += cashflows[period];
|
|
12
|
+
if (cumulative >= 0 && period > 0) return period - 1 + -previous / cashflows[period];
|
|
13
|
+
}
|
|
14
|
+
return Number.POSITIVE_INFINITY;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { npv, payback };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { OperatingBudgetFacts, OperatingBudgetResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/budgeting.d.ts
|
|
5
|
+
declare function buildOperatingBudget(facts: OperatingBudgetFacts, policy?: AccountingPolicy): OperatingBudgetResult;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { buildOperatingBudget };
|