@classytic/stage 0.2.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/LICENSE +1 -1
- package/README.md +5 -1
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/assets/index.mjs +0 -1
- 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/builder/Palette.mjs +50 -89
- package/dist/builder/SceneBuilder.mjs +15 -73
- 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 +4 -1
- package/dist/core/index.mjs +4 -1
- package/dist/core/math.d.mts +26 -0
- package/dist/core/math.mjs +37 -0
- 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 +75 -0
- package/dist/finance/bizsim.mjs +296 -0
- package/dist/finance/index.d.mts +95 -0
- package/dist/finance/index.mjs +145 -0
- 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 +9 -8
- package/dist/index.mjs +5 -5
- package/dist/interaction/MovableDot.mjs +19 -0
- package/dist/interaction/useDraggable.mjs +24 -4
- 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 +17 -1
- package/dist/math/calculus.mjs +365 -2
- 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 +9 -23
- package/dist/math/index.mjs +9 -38
- package/dist/math/latex.mjs +10 -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/primitives/Dot.d.mts +2 -15
- package/dist/primitives/Dot.mjs +6 -4
- package/dist/primitives/Grid.d.mts +33 -17
- package/dist/primitives/Grid.mjs +89 -17
- package/dist/primitives/Label.d.mts +1 -14
- package/dist/primitives/Label.mjs +3 -2
- package/dist/primitives/Lines.d.mts +4 -32
- package/dist/primitives/Lines.mjs +10 -8
- package/dist/primitives/Shapes.d.mts +5 -43
- package/dist/primitives/Shapes.mjs +12 -10
- package/dist/primitives/index.d.mts +2 -2
- package/dist/primitives/index.mjs +2 -2
- package/dist/primitives/props.mjs +31 -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/Scene.d.mts +6 -1
- package/dist/scene/Scene.mjs +15 -40
- 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/view/Stage.mjs +4 -11
- 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 +103 -23
- package/styles.css +125 -8
- package/dist/assets/kit/index.mjs +0 -4
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { solveJournal } from "./accounting/solve.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/bizsim.ts
|
|
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
|
+
}
|
|
176
|
+
case "sell": {
|
|
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);
|
|
207
|
+
}
|
|
208
|
+
case "expense": return append(state, journal(id, "Operating expense paid", "expenses", "cash", amount(action.amount, "Expense")));
|
|
209
|
+
case "closePeriod": {
|
|
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
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function runBiz(actions, opening = {}) {
|
|
250
|
+
return actions.reduce(applyBiz, initialBiz(opening));
|
|
251
|
+
}
|
|
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;
|
|
258
|
+
return {
|
|
259
|
+
revenue,
|
|
260
|
+
cogs,
|
|
261
|
+
grossProfit,
|
|
262
|
+
expenses,
|
|
263
|
+
netProfit: grossProfit - expenses
|
|
264
|
+
};
|
|
265
|
+
}
|
|
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;
|
|
277
|
+
return {
|
|
278
|
+
cash,
|
|
279
|
+
inventory,
|
|
280
|
+
equipment,
|
|
281
|
+
totalAssets,
|
|
282
|
+
loan,
|
|
283
|
+
capital,
|
|
284
|
+
retained,
|
|
285
|
+
openProfit,
|
|
286
|
+
totalEquity,
|
|
287
|
+
totalLiabilitiesEquity: loan + totalEquity,
|
|
288
|
+
balances: solution.trialBalance.balances && solution.equation.balances
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function businessBooks(state) {
|
|
292
|
+
return books(state);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//#endregion
|
|
296
|
+
export { applyBiz, balanceSheet, businessBooks, incomeStatement, initialBiz, runBiz };
|
|
@@ -0,0 +1,95 @@
|
|
|
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";
|
|
20
|
+
|
|
21
|
+
//#region src/finance/index.d.ts
|
|
22
|
+
/** Simple interest I = P·r·t (interest only, not the total). */
|
|
23
|
+
declare function simpleInterest(principal: number, rate: number, years: number): number;
|
|
24
|
+
/** Amount after compound interest, A = P(1 + r/m)^(m·t). */
|
|
25
|
+
declare function compoundAmount(principal: number, rate: number, years: number, m?: number): number;
|
|
26
|
+
/** Compound interest earned (total − principal). */
|
|
27
|
+
declare function compoundInterest(principal: number, rate: number, years: number, m?: number): number;
|
|
28
|
+
/** Future value of a lump sum, FV = P(1+r)^n. */
|
|
29
|
+
declare function futureValue(principal: number, rate: number, n: number): number;
|
|
30
|
+
/** Present value of a future lump sum, PV = FV/(1+r)^n. */
|
|
31
|
+
declare function presentValue(fv: number, rate: number, n: number): number;
|
|
32
|
+
/** Effective annual rate from a nominal rate compounded m times/year. */
|
|
33
|
+
declare function effectiveRate(nominal: number, m: number): number;
|
|
34
|
+
/** Rule of 72: approximate years for money to double at a given annual rate. */
|
|
35
|
+
declare function rule72(rate: number): number;
|
|
36
|
+
/** Yearly simple-vs-compound growth series, for the "money snowball" curve. */
|
|
37
|
+
declare function growthSeries(principal: number, rate: number, years: number): {
|
|
38
|
+
year: number;
|
|
39
|
+
simple: number;
|
|
40
|
+
compound: number;
|
|
41
|
+
}[];
|
|
42
|
+
interface AmortRow {
|
|
43
|
+
period: number;
|
|
44
|
+
interest: number;
|
|
45
|
+
principal: number;
|
|
46
|
+
balance: number;
|
|
47
|
+
}
|
|
48
|
+
interface AmortResult {
|
|
49
|
+
payment: number;
|
|
50
|
+
totalInterest: number;
|
|
51
|
+
schedule: AmortRow[];
|
|
52
|
+
}
|
|
53
|
+
/** Amortize a loan into equal payments; returns the payment, total interest, and per-period schedule. */
|
|
54
|
+
declare function amortize(principal: number, annualRate: number, years: number, m?: number): AmortResult;
|
|
55
|
+
interface DepRow {
|
|
56
|
+
year: number;
|
|
57
|
+
depreciation: number;
|
|
58
|
+
bookValue: number;
|
|
59
|
+
}
|
|
60
|
+
/** Straight-line depreciation: equal charge (cost − residual)/life each year. */
|
|
61
|
+
declare function straightLine(cost: number, residual: number, life: number): {
|
|
62
|
+
perYear: number;
|
|
63
|
+
schedule: DepRow[];
|
|
64
|
+
};
|
|
65
|
+
/** Reducing-balance depreciation: a fixed % of the falling book value each year. */
|
|
66
|
+
declare function reducingBalance(cost: number, rate: number, life: number): DepRow[];
|
|
67
|
+
interface CostModel {
|
|
68
|
+
fixedCost: number;
|
|
69
|
+
price: number;
|
|
70
|
+
variableCost: number;
|
|
71
|
+
}
|
|
72
|
+
interface BreakEven {
|
|
73
|
+
contributionPerUnit: number;
|
|
74
|
+
units: number;
|
|
75
|
+
revenue: number;
|
|
76
|
+
contributionMargin: number;
|
|
77
|
+
}
|
|
78
|
+
/** Break-even: units where contribution covers fixed cost; plus revenue and margin. */
|
|
79
|
+
declare function breakEven({
|
|
80
|
+
fixedCost,
|
|
81
|
+
price,
|
|
82
|
+
variableCost
|
|
83
|
+
}: CostModel): BreakEven;
|
|
84
|
+
/** Profit at a given output: units·(price − variable) − fixed. */
|
|
85
|
+
declare function profitAt(units: number, m: CostModel): number;
|
|
86
|
+
/** Margin of safety = actual output − break-even output (units). */
|
|
87
|
+
declare function marginOfSafety(currentUnits: number, breakEvenUnits: number): number;
|
|
88
|
+
/** Economic order quantity: √(2·D·S / H) — demand D, order cost S, holding cost/unit H. */
|
|
89
|
+
declare function eoq(annualDemand: number, orderCost: number, holdingCostPerUnit: number): number;
|
|
90
|
+
/** Reorder level = usage during the lead time, plus any buffer (safety) stock. */
|
|
91
|
+
declare function reorderLevel(usagePerDay: number, leadTimeDays: number, bufferStock?: number): number;
|
|
92
|
+
/** Split a total cost across cost-centres in proportion to a basis (floor area sq ft, headcount, machine hours…). */
|
|
93
|
+
declare function apportion(total: number, weights: number[]): number[];
|
|
94
|
+
//#endregion
|
|
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 };
|
|
@@ -0,0 +1,145 @@
|
|
|
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";
|
|
19
|
+
|
|
20
|
+
//#region src/finance/index.ts
|
|
21
|
+
/** Simple interest I = P·r·t (interest only, not the total). */
|
|
22
|
+
function simpleInterest(principal, rate, years) {
|
|
23
|
+
return principal * rate * years;
|
|
24
|
+
}
|
|
25
|
+
/** Amount after compound interest, A = P(1 + r/m)^(m·t). */
|
|
26
|
+
function compoundAmount(principal, rate, years, m = 1) {
|
|
27
|
+
return principal * Math.pow(1 + rate / m, m * years);
|
|
28
|
+
}
|
|
29
|
+
/** Compound interest earned (total − principal). */
|
|
30
|
+
function compoundInterest(principal, rate, years, m = 1) {
|
|
31
|
+
return compoundAmount(principal, rate, years, m) - principal;
|
|
32
|
+
}
|
|
33
|
+
/** Future value of a lump sum, FV = P(1+r)^n. */
|
|
34
|
+
function futureValue(principal, rate, n) {
|
|
35
|
+
return principal * Math.pow(1 + rate, n);
|
|
36
|
+
}
|
|
37
|
+
/** Present value of a future lump sum, PV = FV/(1+r)^n. */
|
|
38
|
+
function presentValue(fv, rate, n) {
|
|
39
|
+
return fv / Math.pow(1 + rate, n);
|
|
40
|
+
}
|
|
41
|
+
/** Effective annual rate from a nominal rate compounded m times/year. */
|
|
42
|
+
function effectiveRate(nominal, m) {
|
|
43
|
+
return Math.pow(1 + nominal / m, m) - 1;
|
|
44
|
+
}
|
|
45
|
+
/** Rule of 72: approximate years for money to double at a given annual rate. */
|
|
46
|
+
function rule72(rate) {
|
|
47
|
+
return 72 / (rate * 100);
|
|
48
|
+
}
|
|
49
|
+
/** Yearly simple-vs-compound growth series, for the "money snowball" curve. */
|
|
50
|
+
function growthSeries(principal, rate, years) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (let y = 0; y <= years; y++) out.push({
|
|
53
|
+
year: y,
|
|
54
|
+
simple: principal * (1 + rate * y),
|
|
55
|
+
compound: principal * Math.pow(1 + rate, y)
|
|
56
|
+
});
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/** Amortize a loan into equal payments; returns the payment, total interest, and per-period schedule. */
|
|
60
|
+
function amortize(principal, annualRate, years, m = 12) {
|
|
61
|
+
const n = Math.round(years * m), i = annualRate / m;
|
|
62
|
+
const payment = i === 0 ? principal / n : principal * i / (1 - Math.pow(1 + i, -n));
|
|
63
|
+
const schedule = [];
|
|
64
|
+
let bal = principal;
|
|
65
|
+
for (let k = 1; k <= n; k++) {
|
|
66
|
+
const interest = bal * i;
|
|
67
|
+
const princ = payment - interest;
|
|
68
|
+
bal = Math.max(0, bal - princ);
|
|
69
|
+
schedule.push({
|
|
70
|
+
period: k,
|
|
71
|
+
interest,
|
|
72
|
+
principal: princ,
|
|
73
|
+
balance: bal
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
payment,
|
|
78
|
+
totalInterest: payment * n - principal,
|
|
79
|
+
schedule
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Straight-line depreciation: equal charge (cost − residual)/life each year. */
|
|
83
|
+
function straightLine(cost, residual, life) {
|
|
84
|
+
const perYear = (cost - residual) / life;
|
|
85
|
+
const schedule = [];
|
|
86
|
+
for (let y = 1; y <= life; y++) schedule.push({
|
|
87
|
+
year: y,
|
|
88
|
+
depreciation: perYear,
|
|
89
|
+
bookValue: cost - perYear * y
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
perYear,
|
|
93
|
+
schedule
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Reducing-balance depreciation: a fixed % of the falling book value each year. */
|
|
97
|
+
function reducingBalance(cost, rate, life) {
|
|
98
|
+
const schedule = [];
|
|
99
|
+
let bv = cost;
|
|
100
|
+
for (let y = 1; y <= life; y++) {
|
|
101
|
+
const dep = bv * rate;
|
|
102
|
+
bv -= dep;
|
|
103
|
+
schedule.push({
|
|
104
|
+
year: y,
|
|
105
|
+
depreciation: dep,
|
|
106
|
+
bookValue: bv
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return schedule;
|
|
110
|
+
}
|
|
111
|
+
/** Break-even: units where contribution covers fixed cost; plus revenue and margin. */
|
|
112
|
+
function breakEven({ fixedCost, price, variableCost }) {
|
|
113
|
+
const contributionPerUnit = price - variableCost;
|
|
114
|
+
const units = contributionPerUnit > 0 ? fixedCost / contributionPerUnit : Infinity;
|
|
115
|
+
return {
|
|
116
|
+
contributionPerUnit,
|
|
117
|
+
units,
|
|
118
|
+
revenue: units * price,
|
|
119
|
+
contributionMargin: price > 0 ? contributionPerUnit / price : 0
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Profit at a given output: units·(price − variable) − fixed. */
|
|
123
|
+
function profitAt(units, m) {
|
|
124
|
+
return units * (m.price - m.variableCost) - m.fixedCost;
|
|
125
|
+
}
|
|
126
|
+
/** Margin of safety = actual output − break-even output (units). */
|
|
127
|
+
function marginOfSafety(currentUnits, breakEvenUnits) {
|
|
128
|
+
return currentUnits - breakEvenUnits;
|
|
129
|
+
}
|
|
130
|
+
/** Economic order quantity: √(2·D·S / H) — demand D, order cost S, holding cost/unit H. */
|
|
131
|
+
function eoq(annualDemand, orderCost, holdingCostPerUnit) {
|
|
132
|
+
return holdingCostPerUnit > 0 ? Math.sqrt(2 * annualDemand * orderCost / holdingCostPerUnit) : Infinity;
|
|
133
|
+
}
|
|
134
|
+
/** Reorder level = usage during the lead time, plus any buffer (safety) stock. */
|
|
135
|
+
function reorderLevel(usagePerDay, leadTimeDays, bufferStock = 0) {
|
|
136
|
+
return usagePerDay * leadTimeDays + bufferStock;
|
|
137
|
+
}
|
|
138
|
+
/** Split a total cost across cost-centres in proportion to a basis (floor area sq ft, headcount, machine hours…). */
|
|
139
|
+
function apportion(total, weights) {
|
|
140
|
+
const sum = weights.reduce((a, b) => a + b, 0) || 1;
|
|
141
|
+
return weights.map((w) => total * w / sum);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
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 };
|