@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,164 @@
|
|
|
1
|
+
import { fromMinor, toMinor } from "../accounting/precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/management-accounting/decisions.ts
|
|
4
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
5
|
+
function optimizeLimitedFactor(products, resourceAvailable, policy = DEFAULT_POLICY) {
|
|
6
|
+
const diagnostics = [];
|
|
7
|
+
if (!Number.isFinite(resourceAvailable) || resourceAvailable < 0) diagnostics.push({
|
|
8
|
+
code: "invalid-input",
|
|
9
|
+
severity: "error",
|
|
10
|
+
message: "Available scarce resource must be finite and non-negative."
|
|
11
|
+
});
|
|
12
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13
|
+
for (const product of products) {
|
|
14
|
+
if (seen.has(product.id)) diagnostics.push({
|
|
15
|
+
code: "duplicate-product",
|
|
16
|
+
severity: "error",
|
|
17
|
+
productId: product.id,
|
|
18
|
+
message: `Product ${product.id} is duplicated.`
|
|
19
|
+
});
|
|
20
|
+
seen.add(product.id);
|
|
21
|
+
if (![
|
|
22
|
+
product.sellingPricePerUnit,
|
|
23
|
+
product.variableCostPerUnit,
|
|
24
|
+
product.scarceResourcePerUnit,
|
|
25
|
+
product.maximumDemandUnits
|
|
26
|
+
].every((value) => Number.isFinite(value) && value >= 0)) diagnostics.push({
|
|
27
|
+
code: "invalid-input",
|
|
28
|
+
severity: "error",
|
|
29
|
+
productId: product.id,
|
|
30
|
+
message: `${product.label} assumptions must be finite and non-negative.`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (diagnostics.length > 0) return {
|
|
34
|
+
completed: false,
|
|
35
|
+
resourceAvailable,
|
|
36
|
+
resourceUsed: 0,
|
|
37
|
+
unusedResource: 0,
|
|
38
|
+
totalContribution: 0,
|
|
39
|
+
allocations: [],
|
|
40
|
+
diagnostics,
|
|
41
|
+
trace: []
|
|
42
|
+
};
|
|
43
|
+
const ranked = products.map((product) => {
|
|
44
|
+
const contributionPerUnit = money(product.sellingPricePerUnit - product.variableCostPerUnit, policy);
|
|
45
|
+
return {
|
|
46
|
+
product,
|
|
47
|
+
contributionPerUnit,
|
|
48
|
+
contributionPerResourceUnit: product.scarceResourcePerUnit === 0 ? "unconstrained" : money(contributionPerUnit / product.scarceResourcePerUnit, policy)
|
|
49
|
+
};
|
|
50
|
+
}).sort((left, right) => score(right.contributionPerResourceUnit) - score(left.contributionPerResourceUnit) || left.product.id.localeCompare(right.product.id));
|
|
51
|
+
let remaining = resourceAvailable;
|
|
52
|
+
const allocations = ranked.map((item, index) => {
|
|
53
|
+
const allocatedUnits = !(item.contributionPerUnit > 0) ? 0 : item.product.scarceResourcePerUnit === 0 ? item.product.maximumDemandUnits : Math.min(item.product.maximumDemandUnits, remaining / item.product.scarceResourcePerUnit);
|
|
54
|
+
const resourceUsed = allocatedUnits * item.product.scarceResourcePerUnit;
|
|
55
|
+
remaining = Math.max(0, remaining - resourceUsed);
|
|
56
|
+
return {
|
|
57
|
+
productId: item.product.id,
|
|
58
|
+
label: item.product.label,
|
|
59
|
+
contributionPerUnit: item.contributionPerUnit,
|
|
60
|
+
contributionPerResourceUnit: item.contributionPerResourceUnit,
|
|
61
|
+
allocatedUnits,
|
|
62
|
+
resourceUsed,
|
|
63
|
+
contribution: money(allocatedUnits * item.contributionPerUnit, policy),
|
|
64
|
+
rank: index + 1
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
const resourceUsed = resourceAvailable - remaining;
|
|
68
|
+
const totalContribution = money(allocations.reduce((total, allocation) => total + allocation.contribution, 0), policy);
|
|
69
|
+
const trace = allocations.map((allocation) => ({
|
|
70
|
+
id: `limited:${allocation.productId}`,
|
|
71
|
+
kind: "derive",
|
|
72
|
+
rule: "Rank positive contribution by contribution per scarce-resource unit, then satisfy demand in rank order.",
|
|
73
|
+
working: `${allocation.allocatedUnits} units × ${allocation.contributionPerUnit} contribution`,
|
|
74
|
+
result: allocation.contribution
|
|
75
|
+
}));
|
|
76
|
+
return {
|
|
77
|
+
completed: true,
|
|
78
|
+
resourceAvailable,
|
|
79
|
+
resourceUsed,
|
|
80
|
+
unusedResource: remaining,
|
|
81
|
+
totalContribution,
|
|
82
|
+
allocations,
|
|
83
|
+
diagnostics,
|
|
84
|
+
trace
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function evaluateRelevantCostDecision(alternatives, policy = DEFAULT_POLICY) {
|
|
88
|
+
const diagnostics = [];
|
|
89
|
+
if (alternatives.length < 2) diagnostics.push({
|
|
90
|
+
code: "insufficient-alternatives",
|
|
91
|
+
severity: "error",
|
|
92
|
+
message: "A decision requires at least two alternatives."
|
|
93
|
+
});
|
|
94
|
+
const alternativeIds = /* @__PURE__ */ new Set();
|
|
95
|
+
for (const alternative of alternatives) {
|
|
96
|
+
if (alternativeIds.has(alternative.id)) diagnostics.push({
|
|
97
|
+
code: "duplicate-alternative",
|
|
98
|
+
severity: "error",
|
|
99
|
+
alternativeId: alternative.id,
|
|
100
|
+
message: `Alternative ${alternative.id} is duplicated.`
|
|
101
|
+
});
|
|
102
|
+
alternativeIds.add(alternative.id);
|
|
103
|
+
const flowIds = /* @__PURE__ */ new Set();
|
|
104
|
+
for (const flow of alternative.cashFlows) {
|
|
105
|
+
if (flowIds.has(flow.id)) diagnostics.push({
|
|
106
|
+
code: "duplicate-cash-flow",
|
|
107
|
+
severity: "error",
|
|
108
|
+
alternativeId: alternative.id,
|
|
109
|
+
message: `Cash flow ${flow.id} is duplicated within ${alternative.label}.`
|
|
110
|
+
});
|
|
111
|
+
flowIds.add(flow.id);
|
|
112
|
+
if (!Number.isFinite(flow.amount) || flow.amount < 0) diagnostics.push({
|
|
113
|
+
code: "invalid-input",
|
|
114
|
+
severity: "error",
|
|
115
|
+
alternativeId: alternative.id,
|
|
116
|
+
message: `${flow.label} must be finite and non-negative.`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (diagnostics.length > 0) return {
|
|
121
|
+
completed: false,
|
|
122
|
+
alternatives: [],
|
|
123
|
+
advantageOverNextBest: 0,
|
|
124
|
+
diagnostics,
|
|
125
|
+
trace: []
|
|
126
|
+
};
|
|
127
|
+
const results = alternatives.map((alternative) => {
|
|
128
|
+
const included = alternative.cashFlows.filter(isRelevant);
|
|
129
|
+
const excluded = alternative.cashFlows.filter((flow) => !isRelevant(flow));
|
|
130
|
+
const relevantBenefit = money(included.filter((flow) => flow.kind === "incremental-revenue" || flow.kind === "avoidable-cost").reduce((total, flow) => total + flow.amount, 0), policy);
|
|
131
|
+
const relevantCost = money(included.filter((flow) => flow.kind === "incremental-cost" || flow.kind === "opportunity-cost").reduce((total, flow) => total + flow.amount, 0), policy);
|
|
132
|
+
return {
|
|
133
|
+
id: alternative.id,
|
|
134
|
+
label: alternative.label,
|
|
135
|
+
relevantBenefit,
|
|
136
|
+
relevantCost,
|
|
137
|
+
netBenefit: money(relevantBenefit - relevantCost, policy),
|
|
138
|
+
included,
|
|
139
|
+
excluded
|
|
140
|
+
};
|
|
141
|
+
}).sort((left, right) => right.netBenefit - left.netBenefit || left.id.localeCompare(right.id));
|
|
142
|
+
const advantageOverNextBest = money(results[0].netBenefit - results[1].netBenefit, policy);
|
|
143
|
+
const trace = results.map((alternative) => ({
|
|
144
|
+
id: `relevant:${alternative.id}`,
|
|
145
|
+
kind: "derive",
|
|
146
|
+
rule: "Net relevant benefit includes future cash flows that differ between alternatives; sunk and unavoidable allocated costs are excluded.",
|
|
147
|
+
working: `${alternative.relevantBenefit} benefits − ${alternative.relevantCost} costs`,
|
|
148
|
+
result: alternative.netBenefit
|
|
149
|
+
}));
|
|
150
|
+
return {
|
|
151
|
+
completed: true,
|
|
152
|
+
alternatives: results,
|
|
153
|
+
recommendedAlternativeId: results[0].id,
|
|
154
|
+
advantageOverNextBest,
|
|
155
|
+
diagnostics,
|
|
156
|
+
trace
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const isRelevant = (flow) => flow.kind !== "sunk-cost" && flow.kind !== "unavoidable-allocated-cost";
|
|
160
|
+
const money = (value, policy) => fromMinor(toMinor(value, policy), policy);
|
|
161
|
+
const score = (value) => value === "unconstrained" ? Number.POSITIVE_INFINITY : value;
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
export { evaluateRelevantCostDecision, optimizeLimitedFactor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BudgetPeriodInput, CashBudgetFacts, CashBudgetPeriod, CashBudgetPeriodInput, CashBudgetResult, CashTimingAllocation, ClassifiedCost, CostBehavior, CostClassificationSummary, CostFunction, CostTraceability, CostVariance, CostVarianceFacts, CostVarianceResult, CostingStatement, IntegratedBudgetCashAdjustment, IntegratedMasterBudgetFacts, IntegratedMasterBudgetResult, InventoryCostLayer, InventoryCostingDiagnostic, InventoryCostingMethod, InventoryCostingMovement, InventoryCostingResult, InventoryLayerConsumption, InventoryTransaction, InvestmentAccountingProfit, InvestmentAppraisalFacts, InvestmentAppraisalPeriod, InvestmentAppraisalResult, InvestmentCashFlow, JobBatchCostFacts, JobBatchCostResult, LimitedFactorAllocation, LimitedFactorProduct, LimitedFactorResult, ManagementAccountingCase, ManagementAccountingCaseResult, ManagementCaseSolution, ManagementCaseTask, ManagementCaseTaskResult, MarginalAbsorptionFacts, MarginalAbsorptionResult, MasterBudgetFacts, MasterBudgetPeriod, MasterBudgetPeriodPolicy, MasterBudgetResult, OperatingBudgetFacts, OperatingBudgetPeriod, OperatingBudgetResult, ProcessCostFacts, ProcessCostResult, RelevantCashFlow, RelevantCashFlowKind, RelevantCostAlternative, RelevantCostAlternativeResult, RelevantCostDecisionResult } from "./types.mjs";
|
|
2
|
+
import { costInventory } from "./inventory-costing.mjs";
|
|
3
|
+
import { compareMarginalAndAbsorptionCosting, summarizeClassifiedCosts } from "./costing.mjs";
|
|
4
|
+
import { buildOperatingBudget } from "./budgeting.mjs";
|
|
5
|
+
import { buildCashBudget } from "./cash-budget.mjs";
|
|
6
|
+
import { composeMasterBudget } from "./master-budget.mjs";
|
|
7
|
+
import { buildIntegratedMasterBudget } from "./integrated-budget.mjs";
|
|
8
|
+
import { analyzeCostVariances } from "./variances.mjs";
|
|
9
|
+
import { evaluateRelevantCostDecision, optimizeLimitedFactor } from "./decisions.mjs";
|
|
10
|
+
import { appraiseInvestment } from "./investment-appraisal.mjs";
|
|
11
|
+
import { costJobOrBatch, costProcessWithLosses } from "./production-costing.mjs";
|
|
12
|
+
import { runManagementAccountingCase } from "./management-case.mjs";
|
|
13
|
+
export { BudgetPeriodInput, CashBudgetFacts, CashBudgetPeriod, CashBudgetPeriodInput, CashBudgetResult, CashTimingAllocation, ClassifiedCost, CostBehavior, CostClassificationSummary, CostFunction, CostTraceability, CostVariance, CostVarianceFacts, CostVarianceResult, CostingStatement, IntegratedBudgetCashAdjustment, IntegratedMasterBudgetFacts, IntegratedMasterBudgetResult, InventoryCostLayer, InventoryCostingDiagnostic, InventoryCostingMethod, InventoryCostingMovement, InventoryCostingResult, InventoryLayerConsumption, InventoryTransaction, InvestmentAccountingProfit, InvestmentAppraisalFacts, InvestmentAppraisalPeriod, InvestmentAppraisalResult, InvestmentCashFlow, JobBatchCostFacts, JobBatchCostResult, LimitedFactorAllocation, LimitedFactorProduct, LimitedFactorResult, ManagementAccountingCase, ManagementAccountingCaseResult, ManagementCaseSolution, ManagementCaseTask, ManagementCaseTaskResult, MarginalAbsorptionFacts, MarginalAbsorptionResult, MasterBudgetFacts, MasterBudgetPeriod, MasterBudgetPeriodPolicy, MasterBudgetResult, OperatingBudgetFacts, OperatingBudgetPeriod, OperatingBudgetResult, ProcessCostFacts, ProcessCostResult, RelevantCashFlow, RelevantCashFlowKind, RelevantCostAlternative, RelevantCostAlternativeResult, RelevantCostDecisionResult, analyzeCostVariances, appraiseInvestment, buildCashBudget, buildIntegratedMasterBudget, buildOperatingBudget, compareMarginalAndAbsorptionCosting, composeMasterBudget, costInventory, costJobOrBatch, costProcessWithLosses, evaluateRelevantCostDecision, optimizeLimitedFactor, runManagementAccountingCase, summarizeClassifiedCosts };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { costInventory } from "./inventory-costing.mjs";
|
|
2
|
+
import { compareMarginalAndAbsorptionCosting, summarizeClassifiedCosts } from "./costing.mjs";
|
|
3
|
+
import { buildOperatingBudget } from "./budgeting.mjs";
|
|
4
|
+
import { buildCashBudget } from "./cash-budget.mjs";
|
|
5
|
+
import { composeMasterBudget } from "./master-budget.mjs";
|
|
6
|
+
import { buildIntegratedMasterBudget } from "./integrated-budget.mjs";
|
|
7
|
+
import { analyzeCostVariances } from "./variances.mjs";
|
|
8
|
+
import { evaluateRelevantCostDecision, optimizeLimitedFactor } from "./decisions.mjs";
|
|
9
|
+
import { appraiseInvestment } from "./investment-appraisal.mjs";
|
|
10
|
+
import { costJobOrBatch, costProcessWithLosses } from "./production-costing.mjs";
|
|
11
|
+
import { runManagementAccountingCase } from "./management-case.mjs";
|
|
12
|
+
|
|
13
|
+
export { analyzeCostVariances, appraiseInvestment, buildCashBudget, buildIntegratedMasterBudget, buildOperatingBudget, compareMarginalAndAbsorptionCosting, composeMasterBudget, costInventory, costJobOrBatch, costProcessWithLosses, evaluateRelevantCostDecision, optimizeLimitedFactor, runManagementAccountingCase, summarizeClassifiedCosts };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { IntegratedMasterBudgetFacts, IntegratedMasterBudgetResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/integrated-budget.d.ts
|
|
5
|
+
/** Builds every linked schedule from one assumption set so consumers never hand-wire period results. */
|
|
6
|
+
declare function buildIntegratedMasterBudget(facts: IntegratedMasterBudgetFacts, policy?: AccountingPolicy): IntegratedMasterBudgetResult;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { buildIntegratedMasterBudget };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { buildOperatingBudget } from "./budgeting.mjs";
|
|
2
|
+
import { buildCashBudget } from "./cash-budget.mjs";
|
|
3
|
+
import { composeMasterBudget } from "./master-budget.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/finance/management-accounting/integrated-budget.ts
|
|
6
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
7
|
+
/** Builds every linked schedule from one assumption set so consumers never hand-wire period results. */
|
|
8
|
+
function buildIntegratedMasterBudget(facts, policy = DEFAULT_POLICY) {
|
|
9
|
+
const operating = buildOperatingBudget(facts.operating, policy);
|
|
10
|
+
const adjustments = new Map((facts.cashAdjustments ?? []).map((adjustment) => [adjustment.periodId, adjustment]));
|
|
11
|
+
const bridgeDiagnostics = [];
|
|
12
|
+
for (const adjustment of facts.cashAdjustments ?? []) if (!facts.operating.periods.some((period) => period.id === adjustment.periodId)) bridgeDiagnostics.push({
|
|
13
|
+
code: "period-mismatch",
|
|
14
|
+
severity: "error",
|
|
15
|
+
periodId: adjustment.periodId,
|
|
16
|
+
message: `Cash adjustment references unknown period ${adjustment.periodId}.`
|
|
17
|
+
});
|
|
18
|
+
const cash = buildCashBudget({
|
|
19
|
+
openingCashBalance: facts.openingCashBalance,
|
|
20
|
+
minimumCashBalance: facts.minimumCashBalance,
|
|
21
|
+
collectionProfile: facts.collectionProfile,
|
|
22
|
+
materialPaymentProfile: facts.materialPaymentProfile,
|
|
23
|
+
periods: operating.periods.map((period) => {
|
|
24
|
+
const adjustment = adjustments.get(period.id);
|
|
25
|
+
return {
|
|
26
|
+
id: period.id,
|
|
27
|
+
label: period.label,
|
|
28
|
+
salesRevenue: period.sales.revenue,
|
|
29
|
+
materialPurchases: period.materialsPurchases.purchaseCost,
|
|
30
|
+
labourCost: period.directLabour.labourCost,
|
|
31
|
+
productionOverhead: period.productionOverhead.totalOverhead,
|
|
32
|
+
...adjustment?.nonCashProductionOverhead == null ? {} : { nonCashProductionOverhead: adjustment.nonCashProductionOverhead },
|
|
33
|
+
...adjustment?.broughtForwardReceipts == null ? {} : { broughtForwardReceipts: adjustment.broughtForwardReceipts },
|
|
34
|
+
...adjustment?.broughtForwardPayments == null ? {} : { broughtForwardPayments: adjustment.broughtForwardPayments },
|
|
35
|
+
...adjustment?.otherReceipts == null ? {} : { otherReceipts: adjustment.otherReceipts },
|
|
36
|
+
...adjustment?.otherPayments == null ? {} : { otherPayments: adjustment.otherPayments }
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
}, policy);
|
|
40
|
+
const master = composeMasterBudget({
|
|
41
|
+
operating,
|
|
42
|
+
cash,
|
|
43
|
+
openingFinishedGoodsValue: facts.openingFinishedGoodsValue,
|
|
44
|
+
periodPolicies: facts.periodPolicies
|
|
45
|
+
}, policy);
|
|
46
|
+
const diagnostics = [
|
|
47
|
+
...operating.diagnostics,
|
|
48
|
+
...cash.diagnostics,
|
|
49
|
+
...master.diagnostics,
|
|
50
|
+
...bridgeDiagnostics
|
|
51
|
+
];
|
|
52
|
+
return {
|
|
53
|
+
completed: diagnostics.length === 0 && master.completed,
|
|
54
|
+
operating,
|
|
55
|
+
cash,
|
|
56
|
+
master,
|
|
57
|
+
diagnostics,
|
|
58
|
+
trace: [
|
|
59
|
+
...operating.trace,
|
|
60
|
+
...cash.trace,
|
|
61
|
+
...master.trace
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { buildIntegratedMasterBudget };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { InventoryCostingMethod, InventoryCostingResult, InventoryTransaction } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/inventory-costing.d.ts
|
|
5
|
+
declare function costInventory(method: InventoryCostingMethod, transactions: readonly InventoryTransaction[], policy?: AccountingPolicy): InventoryCostingResult;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { costInventory };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { fromMinor, toMinor } from "../accounting/precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/management-accounting/inventory-costing.ts
|
|
4
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
5
|
+
function publicLayer(layer, policy) {
|
|
6
|
+
const value = fromMinor(layer.valueMinor, policy);
|
|
7
|
+
return {
|
|
8
|
+
sourceId: layer.sourceId,
|
|
9
|
+
quantity: layer.quantity,
|
|
10
|
+
value,
|
|
11
|
+
unitCost: layer.quantity === 0 ? 0 : value / layer.quantity
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const totalValue = (layers) => layers.reduce((total, layer) => total + layer.valueMinor, 0);
|
|
15
|
+
function costInventory(method, transactions, policy = DEFAULT_POLICY) {
|
|
16
|
+
const diagnostics = [];
|
|
17
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18
|
+
for (const transaction of transactions) {
|
|
19
|
+
if (seen.has(transaction.id)) diagnostics.push({
|
|
20
|
+
code: "duplicate-transaction",
|
|
21
|
+
severity: "error",
|
|
22
|
+
transactionId: transaction.id,
|
|
23
|
+
message: `Transaction ${transaction.id} is duplicated.`
|
|
24
|
+
});
|
|
25
|
+
seen.add(transaction.id);
|
|
26
|
+
if (!Number.isFinite(transaction.quantity) || transaction.quantity <= 0) diagnostics.push({
|
|
27
|
+
code: "invalid-quantity",
|
|
28
|
+
severity: "error",
|
|
29
|
+
transactionId: transaction.id,
|
|
30
|
+
message: "Inventory quantity must be finite and positive."
|
|
31
|
+
});
|
|
32
|
+
if (transaction.type === "receipt" && (!Number.isFinite(transaction.unitCost) || transaction.unitCost < 0)) diagnostics.push({
|
|
33
|
+
code: "invalid-unit-cost",
|
|
34
|
+
severity: "error",
|
|
35
|
+
transactionId: transaction.id,
|
|
36
|
+
message: "Receipt unit cost must be finite and non-negative."
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (diagnostics.length > 0) return {
|
|
40
|
+
method,
|
|
41
|
+
completed: false,
|
|
42
|
+
movements: [],
|
|
43
|
+
costOfSales: 0,
|
|
44
|
+
closingQuantity: 0,
|
|
45
|
+
closingValue: 0,
|
|
46
|
+
closingLayers: [],
|
|
47
|
+
diagnostics,
|
|
48
|
+
trace: []
|
|
49
|
+
};
|
|
50
|
+
let layers = [];
|
|
51
|
+
let costOfSalesMinor = 0;
|
|
52
|
+
const movements = [];
|
|
53
|
+
const trace = [];
|
|
54
|
+
for (const transaction of transactions) {
|
|
55
|
+
const available = layers.reduce((total, layer) => total + layer.quantity, 0);
|
|
56
|
+
if (transaction.type === "issue" && transaction.quantity > available) {
|
|
57
|
+
diagnostics.push({
|
|
58
|
+
code: "insufficient-inventory",
|
|
59
|
+
severity: "error",
|
|
60
|
+
transactionId: transaction.id,
|
|
61
|
+
message: `Cannot issue ${transaction.quantity}; only ${available} unit(s) are available.`
|
|
62
|
+
});
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
let issueCostMinor = 0;
|
|
66
|
+
const consumedLayers = [];
|
|
67
|
+
if (transaction.type === "receipt") {
|
|
68
|
+
const receiptValueMinor = toMinor(transaction.quantity * transaction.unitCost, policy);
|
|
69
|
+
if (method === "fifo") layers.push({
|
|
70
|
+
sourceId: transaction.id,
|
|
71
|
+
quantity: transaction.quantity,
|
|
72
|
+
valueMinor: receiptValueMinor
|
|
73
|
+
});
|
|
74
|
+
else layers = [{
|
|
75
|
+
sourceId: "avco-pool",
|
|
76
|
+
quantity: available + transaction.quantity,
|
|
77
|
+
valueMinor: totalValue(layers) + receiptValueMinor
|
|
78
|
+
}];
|
|
79
|
+
trace.push({
|
|
80
|
+
id: `${transaction.id}:receipt`,
|
|
81
|
+
kind: "derive",
|
|
82
|
+
rule: method === "fifo" ? "A receipt creates a new chronological cost layer." : "A receipt joins the pool and changes the weighted-average cost.",
|
|
83
|
+
working: `${transaction.quantity} × ${transaction.unitCost}`,
|
|
84
|
+
result: fromMinor(receiptValueMinor, policy)
|
|
85
|
+
});
|
|
86
|
+
} else if (method === "fifo") {
|
|
87
|
+
let required = transaction.quantity;
|
|
88
|
+
while (required > 0) {
|
|
89
|
+
const layer = layers[0];
|
|
90
|
+
const taken = Math.min(required, layer.quantity);
|
|
91
|
+
const takenValue = taken === layer.quantity ? layer.valueMinor : Math.round(layer.valueMinor * taken / layer.quantity);
|
|
92
|
+
const value = fromMinor(takenValue, policy);
|
|
93
|
+
consumedLayers.push({
|
|
94
|
+
sourceId: layer.sourceId,
|
|
95
|
+
quantity: taken,
|
|
96
|
+
value,
|
|
97
|
+
unitCost: value / taken
|
|
98
|
+
});
|
|
99
|
+
issueCostMinor += takenValue;
|
|
100
|
+
layer.quantity -= taken;
|
|
101
|
+
layer.valueMinor -= takenValue;
|
|
102
|
+
required -= taken;
|
|
103
|
+
if (layer.quantity === 0) layers.shift();
|
|
104
|
+
}
|
|
105
|
+
trace.push({
|
|
106
|
+
id: `${transaction.id}:issue`,
|
|
107
|
+
kind: "derive",
|
|
108
|
+
rule: "FIFO issues the oldest available cost layer first.",
|
|
109
|
+
working: consumedLayers.map((layer) => `${layer.quantity} from ${layer.sourceId}`).join(" + "),
|
|
110
|
+
result: fromMinor(issueCostMinor, policy)
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
const pool = layers[0];
|
|
114
|
+
issueCostMinor = transaction.quantity === pool.quantity ? pool.valueMinor : Math.round(pool.valueMinor * transaction.quantity / pool.quantity);
|
|
115
|
+
const value = fromMinor(issueCostMinor, policy);
|
|
116
|
+
consumedLayers.push({
|
|
117
|
+
sourceId: pool.sourceId,
|
|
118
|
+
quantity: transaction.quantity,
|
|
119
|
+
value,
|
|
120
|
+
unitCost: value / transaction.quantity
|
|
121
|
+
});
|
|
122
|
+
pool.quantity -= transaction.quantity;
|
|
123
|
+
pool.valueMinor -= issueCostMinor;
|
|
124
|
+
if (pool.quantity === 0) layers = [];
|
|
125
|
+
trace.push({
|
|
126
|
+
id: `${transaction.id}:issue`,
|
|
127
|
+
kind: "derive",
|
|
128
|
+
rule: "AVCO issues inventory at the current weighted-average cost.",
|
|
129
|
+
working: `${transaction.quantity} × pooled average`,
|
|
130
|
+
result: value
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
costOfSalesMinor += issueCostMinor;
|
|
134
|
+
const quantity = layers.reduce((total, layer) => total + layer.quantity, 0);
|
|
135
|
+
const valueMinor = totalValue(layers);
|
|
136
|
+
movements.push({
|
|
137
|
+
transactionId: transaction.id,
|
|
138
|
+
type: transaction.type,
|
|
139
|
+
quantity: transaction.quantity,
|
|
140
|
+
...transaction.type === "receipt" ? { unitCost: transaction.unitCost } : {},
|
|
141
|
+
issueCost: fromMinor(issueCostMinor, policy),
|
|
142
|
+
runningCostOfSales: fromMinor(costOfSalesMinor, policy),
|
|
143
|
+
runningQuantity: quantity,
|
|
144
|
+
runningValue: fromMinor(valueMinor, policy),
|
|
145
|
+
averageUnitCost: quantity === 0 ? 0 : fromMinor(valueMinor, policy) / quantity,
|
|
146
|
+
consumedLayers,
|
|
147
|
+
remainingLayers: layers.map((layer) => publicLayer(layer, policy))
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const closingValueMinor = totalValue(layers);
|
|
151
|
+
const closingQuantity = layers.reduce((total, layer) => total + layer.quantity, 0);
|
|
152
|
+
trace.push({
|
|
153
|
+
id: "inventory:conservation",
|
|
154
|
+
kind: "check",
|
|
155
|
+
rule: "Goods available = cost of issues + closing inventory.",
|
|
156
|
+
working: `${fromMinor(costOfSalesMinor, policy)} issued; ${fromMinor(closingValueMinor, policy)} remains`,
|
|
157
|
+
result: diagnostics.length === 0
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
method,
|
|
161
|
+
completed: diagnostics.length === 0,
|
|
162
|
+
movements,
|
|
163
|
+
costOfSales: fromMinor(costOfSalesMinor, policy),
|
|
164
|
+
closingQuantity,
|
|
165
|
+
closingValue: fromMinor(closingValueMinor, policy),
|
|
166
|
+
closingLayers: layers.map((layer) => publicLayer(layer, policy)),
|
|
167
|
+
diagnostics,
|
|
168
|
+
trace
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { costInventory };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { InvestmentAppraisalFacts, InvestmentAppraisalResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/investment-appraisal.d.ts
|
|
5
|
+
declare function appraiseInvestment(facts: InvestmentAppraisalFacts, policy?: AccountingPolicy): InvestmentAppraisalResult;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { appraiseInvestment };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { fromMinor, toMinor } from "../accounting/precision.mjs";
|
|
2
|
+
import { npv, payback } from "../investment-math.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/investment-appraisal.ts
|
|
5
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
6
|
+
function appraiseInvestment(facts, policy = DEFAULT_POLICY) {
|
|
7
|
+
const diagnostics = [];
|
|
8
|
+
if (!Number.isFinite(facts.initialInvestment) || facts.initialInvestment <= 0) diagnostics.push({
|
|
9
|
+
code: "invalid-input",
|
|
10
|
+
severity: "error",
|
|
11
|
+
message: "Initial investment must be finite and positive."
|
|
12
|
+
});
|
|
13
|
+
if (!Number.isFinite(facts.discountRate) || facts.discountRate < 0) diagnostics.push({
|
|
14
|
+
code: "invalid-input",
|
|
15
|
+
severity: "error",
|
|
16
|
+
message: "Discount rate must be finite and non-negative."
|
|
17
|
+
});
|
|
18
|
+
if (!Number.isFinite(facts.residualValue.amount) || facts.residualValue.amount < 0) diagnostics.push({
|
|
19
|
+
code: "invalid-input",
|
|
20
|
+
severity: "error",
|
|
21
|
+
message: "Residual value must be finite and non-negative."
|
|
22
|
+
});
|
|
23
|
+
const cashByPeriod = validateSeries(facts.cashFlows, (item) => item.period, (item) => item.netCashFlow, "Cash flow", diagnostics);
|
|
24
|
+
const profitByPeriod = validateSeries(facts.accountingProfits, (item) => item.period, (item) => item.profit, "Accounting profit", diagnostics);
|
|
25
|
+
const finalPeriod = facts.cashFlows.length;
|
|
26
|
+
if (facts.residualValue.period !== finalPeriod) diagnostics.push({
|
|
27
|
+
code: "invalid-terminal-period",
|
|
28
|
+
severity: "error",
|
|
29
|
+
period: facts.residualValue.period,
|
|
30
|
+
message: "Residual value must occur in the final cash-flow period."
|
|
31
|
+
});
|
|
32
|
+
if (facts.accountingProfits.length !== facts.cashFlows.length || [...cashByPeriod.keys()].some((period) => !profitByPeriod.has(period))) diagnostics.push({
|
|
33
|
+
code: "incomplete-series",
|
|
34
|
+
severity: "error",
|
|
35
|
+
message: "Accounting profit must be supplied for every cash-flow period."
|
|
36
|
+
});
|
|
37
|
+
if (diagnostics.length > 0) return emptyResult(diagnostics);
|
|
38
|
+
const undiscounted = [-facts.initialInvestment];
|
|
39
|
+
const discounted = [-facts.initialInvestment];
|
|
40
|
+
const periods = [];
|
|
41
|
+
let cumulativeCashFlow = money(-facts.initialInvestment, policy);
|
|
42
|
+
let cumulativeDiscountedCashFlow = cumulativeCashFlow;
|
|
43
|
+
for (let period = 1; period <= finalPeriod; period += 1) {
|
|
44
|
+
const operatingCashFlow = cashByPeriod.get(period);
|
|
45
|
+
const residualValue = period === facts.residualValue.period ? facts.residualValue.amount : 0;
|
|
46
|
+
const totalCashFlow = money(operatingCashFlow + residualValue, policy);
|
|
47
|
+
const discountFactor = 1 / Math.pow(1 + facts.discountRate, period);
|
|
48
|
+
const presentValue = money(totalCashFlow * discountFactor, policy);
|
|
49
|
+
undiscounted.push(totalCashFlow);
|
|
50
|
+
discounted.push(presentValue);
|
|
51
|
+
cumulativeCashFlow = money(cumulativeCashFlow + totalCashFlow, policy);
|
|
52
|
+
cumulativeDiscountedCashFlow = money(cumulativeDiscountedCashFlow + presentValue, policy);
|
|
53
|
+
periods.push({
|
|
54
|
+
period,
|
|
55
|
+
operatingCashFlow,
|
|
56
|
+
residualValue,
|
|
57
|
+
totalCashFlow,
|
|
58
|
+
discountFactor,
|
|
59
|
+
presentValue,
|
|
60
|
+
cumulativeCashFlow,
|
|
61
|
+
cumulativeDiscountedCashFlow
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const netPresentValue = money(npv(facts.discountRate, undiscounted), policy);
|
|
65
|
+
const rawPayback = payback(undiscounted);
|
|
66
|
+
const rawDiscountedPayback = payback(discounted);
|
|
67
|
+
const averageAnnualAccountingProfit = money([...profitByPeriod.values()].reduce((total, profit) => total + profit, 0) / profitByPeriod.size, policy);
|
|
68
|
+
const arrInvestmentBase = money(facts.arrInvestmentBasis === "initial-investment" ? facts.initialInvestment : (facts.initialInvestment + facts.residualValue.amount) / 2, policy);
|
|
69
|
+
const accountingRateOfReturnPercent = money(averageAnnualAccountingProfit / arrInvestmentBase * 100, policy);
|
|
70
|
+
const trace = [
|
|
71
|
+
{
|
|
72
|
+
id: "appraisal:npv",
|
|
73
|
+
kind: "derive",
|
|
74
|
+
rule: "NPV = initial outlay + present value of future operating cash flows and residual value.",
|
|
75
|
+
working: discounted.join(" + "),
|
|
76
|
+
result: netPresentValue
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "appraisal:payback",
|
|
80
|
+
kind: "derive",
|
|
81
|
+
rule: "Payback interpolates within the period in which cumulative undiscounted cash flow becomes non-negative.",
|
|
82
|
+
working: undiscounted.join(" + "),
|
|
83
|
+
result: Number.isFinite(rawPayback) ? rawPayback : "not recovered"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "appraisal:arr",
|
|
87
|
+
kind: "derive",
|
|
88
|
+
rule: `ARR = average annual accounting profit ÷ ${facts.arrInvestmentBasis === "initial-investment" ? "initial investment" : "average investment"} × 100.`,
|
|
89
|
+
working: `${averageAnnualAccountingProfit} ÷ ${arrInvestmentBase} × 100`,
|
|
90
|
+
result: accountingRateOfReturnPercent
|
|
91
|
+
}
|
|
92
|
+
];
|
|
93
|
+
return {
|
|
94
|
+
completed: true,
|
|
95
|
+
periods,
|
|
96
|
+
netPresentValue,
|
|
97
|
+
paybackPeriod: Number.isFinite(rawPayback) ? rawPayback : null,
|
|
98
|
+
discountedPaybackPeriod: Number.isFinite(rawDiscountedPayback) ? rawDiscountedPayback : null,
|
|
99
|
+
averageAnnualAccountingProfit,
|
|
100
|
+
accountingRateOfReturnPercent,
|
|
101
|
+
arrInvestmentBase,
|
|
102
|
+
diagnostics,
|
|
103
|
+
trace
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function validateSeries(items, periodOf, valueOf, label, diagnostics) {
|
|
107
|
+
const values = /* @__PURE__ */ new Map();
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
const period = periodOf(item);
|
|
110
|
+
const value = valueOf(item);
|
|
111
|
+
if (!Number.isInteger(period) || period <= 0 || !Number.isFinite(value)) diagnostics.push({
|
|
112
|
+
code: "invalid-input",
|
|
113
|
+
severity: "error",
|
|
114
|
+
period,
|
|
115
|
+
message: `${label} periods must be positive integers and amounts must be finite.`
|
|
116
|
+
});
|
|
117
|
+
if (values.has(period)) diagnostics.push({
|
|
118
|
+
code: "duplicate-period",
|
|
119
|
+
severity: "error",
|
|
120
|
+
period,
|
|
121
|
+
message: `${label} period ${period} is duplicated.`
|
|
122
|
+
});
|
|
123
|
+
values.set(period, value);
|
|
124
|
+
}
|
|
125
|
+
for (let period = 1; period <= items.length; period += 1) if (!values.has(period)) diagnostics.push({
|
|
126
|
+
code: "incomplete-series",
|
|
127
|
+
severity: "error",
|
|
128
|
+
period,
|
|
129
|
+
message: `${label} period ${period} is missing.`
|
|
130
|
+
});
|
|
131
|
+
return values;
|
|
132
|
+
}
|
|
133
|
+
const money = (value, policy) => fromMinor(toMinor(value, policy), policy);
|
|
134
|
+
const emptyResult = (diagnostics) => ({
|
|
135
|
+
completed: false,
|
|
136
|
+
periods: [],
|
|
137
|
+
netPresentValue: 0,
|
|
138
|
+
paybackPeriod: null,
|
|
139
|
+
discountedPaybackPeriod: null,
|
|
140
|
+
averageAnnualAccountingProfit: 0,
|
|
141
|
+
accountingRateOfReturnPercent: 0,
|
|
142
|
+
arrInvestmentBase: 0,
|
|
143
|
+
diagnostics,
|
|
144
|
+
trace: []
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { appraiseInvestment };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { ManagementAccountingCase, ManagementAccountingCaseResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/management-case.d.ts
|
|
5
|
+
/** Runs independent authored tasks through their authoritative solvers; it contains no accounting formulas. */
|
|
6
|
+
declare function runManagementAccountingCase(caseDefinition: ManagementAccountingCase, policy?: AccountingPolicy): ManagementAccountingCaseResult;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { runManagementAccountingCase };
|