@classytic/stage 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/atomic/aufbau.d.mts +144 -0
- package/dist/atomic/aufbau.mjs +384 -0
- package/dist/atomic/elements.d.mts +67 -0
- package/dist/atomic/elements.mjs +785 -0
- package/dist/atomic/emission.d.mts +112 -0
- package/dist/atomic/emission.mjs +179 -0
- package/dist/atomic/index.d.mts +8 -0
- package/dist/atomic/index.mjs +9 -0
- package/dist/atomic/periodic.d.mts +82 -0
- package/dist/atomic/periodic.mjs +231 -0
- package/dist/atomic/properties.d.mts +100 -0
- package/dist/atomic/properties.mjs +574 -0
- package/dist/atomic/shells.d.mts +137 -0
- package/dist/atomic/shells.mjs +170 -0
- package/dist/atomic/trends.d.mts +148 -0
- package/dist/atomic/trends.mjs +225 -0
- package/dist/chem/chromatography.d.mts +66 -0
- package/dist/chem/chromatography.mjs +63 -0
- package/dist/chem/complex.d.mts +114 -0
- package/dist/chem/complex.mjs +234 -0
- package/dist/chem/cycle.d.mts +75 -0
- package/dist/chem/cycle.mjs +145 -0
- package/dist/chem/equation.d.mts +86 -0
- package/dist/chem/equation.mjs +168 -0
- package/dist/chem/formula.d.mts +90 -0
- package/dist/chem/formula.mjs +201 -0
- package/dist/chem/functional-groups.d.mts +31 -0
- package/dist/chem/functional-groups.mjs +187 -0
- package/dist/chem/hazard.d.mts +94 -0
- package/dist/chem/hazard.mjs +329 -0
- package/dist/chem/index.d.mts +34 -33
- package/dist/chem/index.mjs +34 -28
- package/dist/chem/ionic.d.mts +98 -0
- package/dist/chem/ionic.mjs +156 -0
- package/dist/chem/layout.d.mts +46 -0
- package/dist/chem/layout.mjs +342 -0
- package/dist/chem/lewis.d.mts +79 -0
- package/dist/chem/lewis.mjs +163 -0
- package/dist/chem/molecular-orbital.d.mts +114 -0
- package/dist/chem/molecular-orbital.mjs +201 -0
- package/dist/chem/molecule.d.mts +154 -0
- package/dist/chem/molecule.mjs +282 -0
- package/dist/chem/nmr.d.mts +153 -0
- package/dist/chem/nmr.mjs +165 -0
- package/dist/chem/polymer.d.mts +65 -0
- package/dist/chem/polymer.mjs +179 -0
- package/dist/chem/redox.d.mts +138 -0
- package/dist/chem/redox.mjs +328 -0
- package/dist/chem/relations.d.mts +183 -0
- package/dist/chem/relations.mjs +299 -0
- package/dist/chem/skeleton.d.mts +51 -0
- package/dist/chem/skeleton.mjs +186 -0
- package/dist/chem/solution.d.mts +116 -0
- package/dist/chem/solution.mjs +186 -0
- package/dist/chem/species.d.mts +47 -0
- package/dist/chem/species.mjs +128 -0
- package/dist/chem/stereo.d.mts +108 -0
- package/dist/chem/stereo.mjs +286 -0
- package/dist/chem/stoichiometry.d.mts +95 -0
- package/dist/chem/stoichiometry.mjs +145 -0
- package/dist/chem/synthesis.d.mts +113 -0
- package/dist/chem/synthesis.mjs +281 -0
- package/dist/chem/vsepr.d.mts +80 -0
- package/dist/chem/vsepr.mjs +247 -0
- package/dist/circuit/ac.d.mts +163 -0
- package/dist/circuit/ac.mjs +452 -0
- package/dist/circuit/dc.d.mts +92 -0
- package/dist/circuit/dc.mjs +333 -0
- package/dist/circuit/index.d.mts +5 -92
- package/dist/circuit/index.mjs +5 -332
- package/dist/circuit/network.d.mts +99 -0
- package/dist/circuit/network.mjs +440 -0
- package/dist/circuit/topology.d.mts +102 -0
- package/dist/circuit/topology.mjs +143 -0
- package/dist/colour/absorption.d.mts +79 -0
- package/dist/colour/absorption.mjs +137 -0
- package/dist/colour/index.d.mts +6 -0
- package/dist/colour/index.mjs +7 -0
- package/dist/colour/name.d.mts +14 -0
- package/dist/colour/name.mjs +76 -0
- package/dist/colour/observer.d.mts +31 -0
- package/dist/colour/observer.mjs +46 -0
- package/dist/colour/spectrum.d.mts +61 -0
- package/dist/colour/spectrum.mjs +108 -0
- package/dist/colour/srgb.d.mts +49 -0
- package/dist/colour/srgb.mjs +108 -0
- package/dist/core/constants.d.mts +138 -0
- package/dist/core/constants.mjs +139 -0
- package/dist/core/index.d.mts +3 -1
- package/dist/core/index.mjs +3 -1
- package/dist/core/vec3.d.mts +94 -0
- package/dist/core/vec3.mjs +123 -0
- package/dist/core/worked.d.mts +35 -0
- package/dist/core/worked.mjs +44 -0
- package/dist/electro/cell.d.mts +102 -0
- package/dist/electro/cell.mjs +170 -0
- package/dist/electro/conductivity.d.mts +157 -0
- package/dist/electro/conductivity.mjs +156 -0
- package/dist/electro/couples.d.mts +114 -0
- package/dist/electro/couples.mjs +334 -0
- package/dist/electro/electrolysis.d.mts +96 -0
- package/dist/electro/electrolysis.mjs +274 -0
- package/dist/electro/faraday.d.mts +150 -0
- package/dist/electro/faraday.mjs +118 -0
- package/dist/electro/index.d.mts +6 -0
- package/dist/electro/index.mjs +7 -0
- package/dist/finance/accounting/adjustments.d.mts +17 -0
- package/dist/finance/accounting/adjustments.mjs +202 -0
- package/dist/finance/accounting/analysis.d.mts +8 -0
- package/dist/finance/accounting/analysis.mjs +205 -0
- package/dist/finance/accounting/clubs.d.mts +21 -0
- package/dist/finance/accounting/clubs.mjs +217 -0
- package/dist/finance/accounting/company-statements.d.mts +7 -0
- package/dist/finance/accounting/company-statements.mjs +150 -0
- package/dist/finance/accounting/harness.d.mts +7 -0
- package/dist/finance/accounting/harness.mjs +45 -0
- package/dist/finance/accounting/index.d.mts +18 -0
- package/dist/finance/accounting/index.mjs +18 -0
- package/dist/finance/accounting/journalize.d.mts +16 -0
- package/dist/finance/accounting/journalize.mjs +128 -0
- package/dist/finance/accounting/manufacturing.d.mts +8 -0
- package/dist/finance/accounting/manufacturing.mjs +236 -0
- package/dist/finance/accounting/partnership.d.mts +7 -0
- package/dist/finance/accounting/partnership.mjs +152 -0
- package/dist/finance/accounting/period-case.d.mts +6 -0
- package/dist/finance/accounting/period-case.mjs +71 -0
- package/dist/finance/accounting/post.d.mts +9 -0
- package/dist/finance/accounting/post.mjs +84 -0
- package/dist/finance/accounting/precision.d.mts +9 -0
- package/dist/finance/accounting/precision.mjs +15 -0
- package/dist/finance/accounting/rules.d.mts +21 -0
- package/dist/finance/accounting/rules.mjs +37 -0
- package/dist/finance/accounting/solve.d.mts +28 -0
- package/dist/finance/accounting/solve.mjs +92 -0
- package/dist/finance/accounting/statements.d.mts +7 -0
- package/dist/finance/accounting/statements.mjs +142 -0
- package/dist/finance/accounting/types.d.mts +649 -0
- package/dist/finance/accounting/validate.d.mts +7 -0
- package/dist/finance/accounting/validate.mjs +67 -0
- package/dist/finance/accounting/verification.d.mts +24 -0
- package/dist/finance/accounting/verification.mjs +386 -0
- package/dist/finance/bizsim.d.mts +21 -39
- package/dist/finance/bizsim.mjs +276 -97
- package/dist/finance/index.d.mts +20 -43
- package/dist/finance/index.mjs +19 -77
- package/dist/finance/investment-math.d.mts +7 -0
- package/dist/finance/investment-math.mjs +18 -0
- package/dist/finance/management-accounting/budgeting.d.mts +7 -0
- package/dist/finance/management-accounting/budgeting.mjs +189 -0
- package/dist/finance/management-accounting/cash-budget.d.mts +7 -0
- package/dist/finance/management-accounting/cash-budget.mjs +154 -0
- package/dist/finance/management-accounting/costing.d.mts +8 -0
- package/dist/finance/management-accounting/costing.mjs +175 -0
- package/dist/finance/management-accounting/decisions.d.mts +8 -0
- package/dist/finance/management-accounting/decisions.mjs +164 -0
- package/dist/finance/management-accounting/index.d.mts +13 -0
- package/dist/finance/management-accounting/index.mjs +13 -0
- package/dist/finance/management-accounting/integrated-budget.d.mts +8 -0
- package/dist/finance/management-accounting/integrated-budget.mjs +67 -0
- package/dist/finance/management-accounting/inventory-costing.d.mts +7 -0
- package/dist/finance/management-accounting/inventory-costing.mjs +173 -0
- package/dist/finance/management-accounting/investment-appraisal.d.mts +7 -0
- package/dist/finance/management-accounting/investment-appraisal.mjs +148 -0
- package/dist/finance/management-accounting/management-case.d.mts +8 -0
- package/dist/finance/management-accounting/management-case.mjs +91 -0
- package/dist/finance/management-accounting/master-budget.d.mts +7 -0
- package/dist/finance/management-accounting/master-budget.mjs +137 -0
- package/dist/finance/management-accounting/production-costing.d.mts +8 -0
- package/dist/finance/management-accounting/production-costing.mjs +214 -0
- package/dist/finance/management-accounting/types.d.mts +644 -0
- package/dist/finance/management-accounting/variances.d.mts +7 -0
- package/dist/finance/management-accounting/variances.mjs +150 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +1 -1
- package/dist/math/analysis.d.mts +61 -0
- package/dist/math/analysis.mjs +187 -0
- package/dist/math/answer-check.d.mts +50 -0
- package/dist/math/answer-check.mjs +106 -0
- package/dist/math/calculus.d.mts +4 -9
- package/dist/math/calculus.mjs +216 -7
- package/dist/math/complex.d.mts +93 -0
- package/dist/math/complex.mjs +239 -0
- package/dist/math/expr.d.mts +23 -0
- package/dist/math/expr.mjs +36 -0
- package/dist/math/index.d.mts +8 -22
- package/dist/math/index.mjs +8 -37
- package/dist/math/latex.mjs +2 -1
- package/dist/math/parse.mjs +1 -1
- package/dist/math/poly.d.mts +55 -0
- package/dist/math/poly.mjs +273 -0
- package/dist/math/rearrange.d.mts +14 -0
- package/dist/math/rearrange.mjs +125 -0
- package/dist/math/solve.d.mts +21 -0
- package/dist/math/solve.mjs +75 -0
- package/dist/networking/addressing.d.mts +26 -0
- package/dist/networking/addressing.mjs +33 -0
- package/dist/networking/cloud/access.d.mts +36 -0
- package/dist/networking/cloud/access.mjs +95 -0
- package/dist/networking/cloud/containers.d.mts +43 -0
- package/dist/networking/cloud/containers.mjs +54 -0
- package/dist/networking/cloud/edge.d.mts +17 -0
- package/dist/networking/cloud/edge.mjs +31 -0
- package/dist/networking/cloud/failure-domains.d.mts +19 -0
- package/dist/networking/cloud/failure-domains.mjs +22 -0
- package/dist/networking/cloud/geo-routing.d.mts +22 -0
- package/dist/networking/cloud/geo-routing.mjs +64 -0
- package/dist/networking/cloud/index.d.mts +18 -0
- package/dist/networking/cloud/index.mjs +19 -0
- package/dist/networking/cloud/inference-reliability.d.mts +30 -0
- package/dist/networking/cloud/inference-reliability.mjs +76 -0
- package/dist/networking/cloud/inference.d.mts +118 -0
- package/dist/networking/cloud/inference.mjs +179 -0
- package/dist/networking/cloud/infrastructure.d.mts +45 -0
- package/dist/networking/cloud/infrastructure.mjs +96 -0
- package/dist/networking/cloud/observability.d.mts +24 -0
- package/dist/networking/cloud/observability.mjs +34 -0
- package/dist/networking/cloud/orchestration.d.mts +32 -0
- package/dist/networking/cloud/orchestration.mjs +38 -0
- package/dist/networking/cloud/recovery.d.mts +21 -0
- package/dist/networking/cloud/recovery.mjs +27 -0
- package/dist/networking/cloud/releases.d.mts +42 -0
- package/dist/networking/cloud/releases.mjs +135 -0
- package/dist/networking/cloud/scaling.d.mts +25 -0
- package/dist/networking/cloud/scaling.mjs +65 -0
- package/dist/networking/cloud/secrets.d.mts +39 -0
- package/dist/networking/cloud/secrets.mjs +68 -0
- package/dist/networking/cloud/server-deployment.d.mts +29 -0
- package/dist/networking/cloud/server-deployment.mjs +72 -0
- package/dist/networking/cloud/storage.d.mts +16 -0
- package/dist/networking/cloud/storage.mjs +58 -0
- package/dist/networking/cloud/vpc.d.mts +18 -0
- package/dist/networking/cloud/vpc.mjs +100 -0
- package/dist/networking/delivery.d.mts +34 -0
- package/dist/networking/delivery.mjs +52 -0
- package/dist/networking/index.d.mts +47 -0
- package/dist/networking/index.mjs +47 -0
- package/dist/networking/ipv6.d.mts +28 -0
- package/dist/networking/ipv6.mjs +17 -0
- package/dist/networking/journeys.d.mts +83 -0
- package/dist/networking/journeys.mjs +161 -0
- package/dist/networking/models/airtime.d.mts +87 -0
- package/dist/networking/models/airtime.mjs +130 -0
- package/dist/networking/models/cellular.d.mts +157 -0
- package/dist/networking/models/cellular.mjs +252 -0
- package/dist/networking/models/encapsulation.d.mts +98 -0
- package/dist/networking/models/encapsulation.mjs +132 -0
- package/dist/networking/models/handover.d.mts +116 -0
- package/dist/networking/models/handover.mjs +209 -0
- package/dist/networking/models/handshake.d.mts +90 -0
- package/dist/networking/models/handshake.mjs +122 -0
- package/dist/networking/models/index.d.mts +14 -0
- package/dist/networking/models/index.mjs +15 -0
- package/dist/networking/models/media.d.mts +82 -0
- package/dist/networking/models/media.mjs +188 -0
- package/dist/networking/models/satellite.d.mts +86 -0
- package/dist/networking/models/satellite.mjs +121 -0
- package/dist/networking/models/spectrum.d.mts +83 -0
- package/dist/networking/models/spectrum.mjs +235 -0
- package/dist/networking/models/switch.d.mts +80 -0
- package/dist/networking/models/switch.mjs +155 -0
- package/dist/networking/models/vlan.d.mts +62 -0
- package/dist/networking/models/vlan.mjs +100 -0
- package/dist/networking/models/vpn.d.mts +66 -0
- package/dist/networking/models/vpn.mjs +125 -0
- package/dist/networking/models/wifi-privacy.d.mts +82 -0
- package/dist/networking/models/wifi-privacy.mjs +130 -0
- package/dist/networking/models/wifi.d.mts +240 -0
- package/dist/networking/models/wifi.mjs +562 -0
- package/dist/networking/nat-traversal.d.mts +24 -0
- package/dist/networking/nat-traversal.mjs +38 -0
- package/dist/networking/protocols.d.mts +17 -0
- package/dist/networking/protocols.mjs +57 -0
- package/dist/networking/queue.d.mts +12 -0
- package/dist/networking/queue.mjs +18 -0
- package/dist/networking/route-learning.d.mts +23 -0
- package/dist/networking/route-learning.mjs +43 -0
- package/dist/networking/routing.d.mts +11 -0
- package/dist/networking/routing.mjs +25 -0
- package/dist/networking/signals.d.mts +26 -0
- package/dist/networking/signals.mjs +35 -0
- package/dist/networking/subnet.d.mts +49 -0
- package/dist/networking/subnet.mjs +89 -0
- package/dist/networking/tcp-reliability.d.mts +24 -0
- package/dist/networking/tcp-reliability.mjs +38 -0
- package/dist/networking/topology/contract.d.mts +123 -0
- package/dist/networking/topology/index.d.mts +4 -0
- package/dist/networking/topology/index.mjs +4 -0
- package/dist/networking/topology/presets.d.mts +7 -0
- package/dist/networking/topology/presets.mjs +302 -0
- package/dist/networking/topology/simulation.d.mts +8 -0
- package/dist/networking/topology/simulation.mjs +179 -0
- package/dist/networking/wireless.d.mts +11 -0
- package/dist/networking/wireless.mjs +17 -0
- package/dist/optics/imaging.d.mts +218 -0
- package/dist/optics/imaging.mjs +276 -0
- package/dist/optics/index.d.mts +7 -0
- package/dist/optics/index.mjs +8 -0
- package/dist/optics/laws.d.mts +70 -0
- package/dist/optics/laws.mjs +195 -0
- package/dist/optics/prism.d.mts +148 -0
- package/dist/optics/prism.mjs +197 -0
- package/dist/optics/refraction.d.mts +201 -0
- package/dist/optics/refraction.mjs +270 -0
- package/dist/optics/wave-optics.d.mts +171 -0
- package/dist/optics/wave-optics.mjs +259 -0
- package/dist/physics/ac/index.d.mts +183 -0
- package/dist/physics/ac/index.mjs +203 -0
- package/dist/physics/dynamics/forces.d.mts +98 -0
- package/dist/physics/dynamics/forces.mjs +153 -0
- package/dist/physics/dynamics/friction.d.mts +76 -0
- package/dist/physics/dynamics/friction.mjs +119 -0
- package/dist/physics/dynamics/system.d.mts +68 -0
- package/dist/physics/dynamics/system.mjs +125 -0
- package/dist/physics/electrostatics/index.d.mts +169 -0
- package/dist/physics/electrostatics/index.mjs +249 -0
- package/dist/physics/energy/centre-of-mass.d.mts +115 -0
- package/dist/physics/energy/centre-of-mass.mjs +180 -0
- package/dist/physics/energy/conservation.d.mts +81 -0
- package/dist/physics/energy/conservation.mjs +129 -0
- package/dist/physics/energy/power.d.mts +90 -0
- package/dist/physics/energy/power.mjs +167 -0
- package/dist/physics/energy/spring.d.mts +73 -0
- package/dist/physics/energy/spring.mjs +129 -0
- package/dist/physics/energy/store.d.mts +63 -0
- package/dist/physics/energy/store.mjs +108 -0
- package/dist/physics/energy/theorem.d.mts +65 -0
- package/dist/physics/energy/theorem.mjs +113 -0
- package/dist/physics/energy/work.d.mts +114 -0
- package/dist/physics/energy/work.mjs +219 -0
- package/dist/physics/gravitation/body.d.mts +85 -0
- package/dist/physics/gravitation/body.mjs +168 -0
- package/dist/physics/gravitation/kepler.d.mts +127 -0
- package/dist/physics/gravitation/kepler.mjs +216 -0
- package/dist/physics/gravitation/law.d.mts +117 -0
- package/dist/physics/gravitation/law.mjs +175 -0
- package/dist/physics/gravitation/orbit.d.mts +119 -0
- package/dist/physics/gravitation/orbit.mjs +202 -0
- package/dist/physics/gravitation/potential.d.mts +114 -0
- package/dist/physics/gravitation/potential.mjs +202 -0
- package/dist/physics/gravitation/variation.d.mts +97 -0
- package/dist/physics/gravitation/variation.mjs +175 -0
- package/dist/physics/index.d.mts +35 -0
- package/dist/physics/index.mjs +36 -0
- package/dist/physics/integral-sweep.d.mts +63 -0
- package/dist/physics/integral-sweep.mjs +126 -0
- package/dist/physics/kinematics/equations.d.mts +47 -0
- package/dist/physics/kinematics/equations.mjs +126 -0
- package/dist/physics/kinematics/free-fall.d.mts +53 -0
- package/dist/physics/kinematics/free-fall.mjs +71 -0
- package/dist/physics/kinematics/given.d.mts +16 -0
- package/dist/physics/kinematics/given.mjs +55 -0
- package/dist/physics/kinematics/roots.d.mts +41 -0
- package/dist/physics/kinematics/roots.mjs +72 -0
- package/dist/physics/kinematics/solve.d.mts +52 -0
- package/dist/physics/kinematics/solve.mjs +172 -0
- package/dist/physics/magnetism/biot-savart.d.mts +161 -0
- package/dist/physics/magnetism/biot-savart.mjs +353 -0
- package/dist/physics/magnetism/flux.d.mts +94 -0
- package/dist/physics/magnetism/flux.mjs +313 -0
- package/dist/physics/magnetism/geomagnetism.d.mts +151 -0
- package/dist/physics/magnetism/geomagnetism.mjs +184 -0
- package/dist/physics/magnetism/index.d.mts +12 -0
- package/dist/physics/magnetism/index.mjs +74 -0
- package/dist/physics/magnetism/lorentz.d.mts +28 -0
- package/dist/physics/magnetism/lorentz.mjs +88 -0
- package/dist/physics/magnetism/magnetic-force.d.mts +102 -0
- package/dist/physics/magnetism/magnetic-force.mjs +169 -0
- package/dist/physics/momentum/collide.d.mts +77 -0
- package/dist/physics/momentum/collide.mjs +115 -0
- package/dist/physics/momentum/impulse.d.mts +89 -0
- package/dist/physics/momentum/impulse.mjs +159 -0
- package/dist/physics/momentum/planar.d.mts +60 -0
- package/dist/physics/momentum/planar.mjs +110 -0
- package/dist/physics/projectile.d.mts +107 -0
- package/dist/physics/projectile.mjs +185 -0
- package/dist/physics/rotation/angular.d.mts +85 -0
- package/dist/physics/rotation/angular.mjs +130 -0
- package/dist/physics/rotation/circular.d.mts +79 -0
- package/dist/physics/rotation/circular.mjs +131 -0
- package/dist/physics/rotation/inertia.d.mts +164 -0
- package/dist/physics/rotation/inertia.mjs +332 -0
- package/dist/physics/rotation/torque.d.mts +65 -0
- package/dist/physics/rotation/torque.mjs +134 -0
- package/dist/physics/vectors.d.mts +64 -0
- package/dist/physics/vectors.mjs +114 -0
- package/dist/quantity/index.d.mts +119 -0
- package/dist/quantity/index.mjs +417 -0
- package/dist/relation/derive.d.mts +74 -0
- package/dist/relation/derive.mjs +73 -0
- package/dist/relation/index.d.mts +56 -0
- package/dist/relation/index.mjs +234 -0
- package/dist/scene/evaluators.mjs +1 -1
- package/dist/sim/thermal.mjs +45 -20
- package/dist/thermo/calorimetry.d.mts +207 -0
- package/dist/thermo/calorimetry.mjs +345 -0
- package/dist/thermo/cycles.d.mts +142 -0
- package/dist/thermo/cycles.mjs +256 -0
- package/dist/thermo/entropy.d.mts +87 -0
- package/dist/thermo/entropy.mjs +140 -0
- package/dist/thermo/expansion.d.mts +130 -0
- package/dist/thermo/expansion.mjs +178 -0
- package/dist/thermo/gas.d.mts +197 -0
- package/dist/thermo/gas.mjs +279 -0
- package/dist/thermo/heat-transfer.d.mts +164 -0
- package/dist/thermo/heat-transfer.mjs +217 -0
- package/dist/thermo/index.d.mts +9 -82
- package/dist/thermo/index.mjs +9 -132
- package/dist/thermo/processes.d.mts +95 -0
- package/dist/thermo/processes.mjs +154 -0
- package/dist/thermo/temperature.d.mts +174 -0
- package/dist/thermo/temperature.mjs +236 -0
- package/dist/waves/damping.d.mts +224 -0
- package/dist/waves/damping.mjs +317 -0
- package/dist/waves/doppler.d.mts +72 -0
- package/dist/waves/doppler.mjs +125 -0
- package/dist/waves/index.d.mts +10 -0
- package/dist/waves/index.mjs +10 -0
- package/dist/waves/pendulum.d.mts +130 -0
- package/dist/waves/pendulum.mjs +211 -0
- package/dist/waves/pitch.d.mts +125 -0
- package/dist/waves/pitch.mjs +158 -0
- package/dist/waves/shm.d.mts +170 -0
- package/dist/waves/shm.mjs +279 -0
- package/dist/waves/springs.d.mts +103 -0
- package/dist/waves/springs.mjs +176 -0
- package/dist/waves/superposition.d.mts +124 -0
- package/dist/waves/superposition.mjs +196 -0
- package/dist/waves/wave.d.mts +154 -0
- package/dist/waves/wave.mjs +178 -0
- package/package.json +74 -2
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { fromMinor, toMinor } from "../accounting/precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/management-accounting/budgeting.ts
|
|
4
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
5
|
+
function buildOperatingBudget(facts, policy = DEFAULT_POLICY) {
|
|
6
|
+
const diagnostics = [];
|
|
7
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8
|
+
const check = (value, label, periodId) => {
|
|
9
|
+
if (!Number.isFinite(value) || value < 0) diagnostics.push({
|
|
10
|
+
code: "invalid-input",
|
|
11
|
+
severity: "error",
|
|
12
|
+
periodId,
|
|
13
|
+
message: `${label} must be finite and non-negative.`
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
check(facts.openingFinishedGoodsUnits, "Opening finished-goods units");
|
|
17
|
+
check(facts.openingMaterialUnits, "Opening material units");
|
|
18
|
+
for (const period of facts.periods) {
|
|
19
|
+
if (seen.has(period.id)) diagnostics.push({
|
|
20
|
+
code: "duplicate-period",
|
|
21
|
+
severity: "error",
|
|
22
|
+
periodId: period.id,
|
|
23
|
+
message: `Period ${period.id} is duplicated.`
|
|
24
|
+
});
|
|
25
|
+
seen.add(period.id);
|
|
26
|
+
check(period.salesUnits, "Sales units", period.id);
|
|
27
|
+
check(period.sellingPricePerUnit, "Selling price per unit", period.id);
|
|
28
|
+
check(period.desiredClosingFinishedGoodsUnits, "Desired closing finished-goods units", period.id);
|
|
29
|
+
check(period.materialUnitsPerFinishedUnit, "Material units per finished unit", period.id);
|
|
30
|
+
check(period.desiredClosingMaterialUnits, "Desired closing material units", period.id);
|
|
31
|
+
check(period.materialCostPerUnit, "Material cost per unit", period.id);
|
|
32
|
+
check(period.directLabourHoursPerUnit ?? 0, "Direct labour hours per finished unit", period.id);
|
|
33
|
+
check(period.directLabourRatePerHour ?? 0, "Direct labour rate per hour", period.id);
|
|
34
|
+
check(period.variableProductionOverheadRatePerLabourHour ?? 0, "Variable production overhead rate per labour hour", period.id);
|
|
35
|
+
check(period.fixedProductionOverhead ?? 0, "Fixed production overhead", period.id);
|
|
36
|
+
}
|
|
37
|
+
if (diagnostics.length > 0) return emptyResult(diagnostics);
|
|
38
|
+
const periods = [];
|
|
39
|
+
const trace = [];
|
|
40
|
+
let openingFinishedGoodsUnits = facts.openingFinishedGoodsUnits;
|
|
41
|
+
let openingMaterialUnits = facts.openingMaterialUnits;
|
|
42
|
+
for (const period of facts.periods) {
|
|
43
|
+
const unitsToProduce = period.salesUnits + period.desiredClosingFinishedGoodsUnits - openingFinishedGoodsUnits;
|
|
44
|
+
const materialUnitsRequired = unitsToProduce * period.materialUnitsPerFinishedUnit;
|
|
45
|
+
const unitsToPurchase = materialUnitsRequired + period.desiredClosingMaterialUnits - openingMaterialUnits;
|
|
46
|
+
if (unitsToProduce < 0) diagnostics.push({
|
|
47
|
+
code: "impossible-schedule",
|
|
48
|
+
severity: "error",
|
|
49
|
+
periodId: period.id,
|
|
50
|
+
message: `${period.label} requires negative production; opening finished goods exceed sales plus desired closing inventory.`
|
|
51
|
+
});
|
|
52
|
+
if (unitsToPurchase < 0) diagnostics.push({
|
|
53
|
+
code: "impossible-schedule",
|
|
54
|
+
severity: "error",
|
|
55
|
+
periodId: period.id,
|
|
56
|
+
message: `${period.label} requires negative material purchases; opening materials exceed usage plus desired closing inventory.`
|
|
57
|
+
});
|
|
58
|
+
if (diagnostics.length > 0) break;
|
|
59
|
+
const revenue = money(period.salesUnits * period.sellingPricePerUnit, policy);
|
|
60
|
+
const purchaseCost = money(unitsToPurchase * period.materialCostPerUnit, policy);
|
|
61
|
+
const hoursPerUnit = period.directLabourHoursPerUnit ?? 0;
|
|
62
|
+
const ratePerHour = period.directLabourRatePerHour ?? 0;
|
|
63
|
+
const labourHours = unitsToProduce * hoursPerUnit;
|
|
64
|
+
const labourCost = money(labourHours * ratePerHour, policy);
|
|
65
|
+
const variableRatePerLabourHour = period.variableProductionOverheadRatePerLabourHour ?? 0;
|
|
66
|
+
const variableOverhead = money(labourHours * variableRatePerLabourHour, policy);
|
|
67
|
+
const fixedOverhead = money(period.fixedProductionOverhead ?? 0, policy);
|
|
68
|
+
const totalOverhead = money(variableOverhead + fixedOverhead, policy);
|
|
69
|
+
periods.push({
|
|
70
|
+
id: period.id,
|
|
71
|
+
label: period.label,
|
|
72
|
+
sales: {
|
|
73
|
+
units: period.salesUnits,
|
|
74
|
+
pricePerUnit: period.sellingPricePerUnit,
|
|
75
|
+
revenue
|
|
76
|
+
},
|
|
77
|
+
production: {
|
|
78
|
+
openingFinishedGoodsUnits,
|
|
79
|
+
salesUnits: period.salesUnits,
|
|
80
|
+
desiredClosingFinishedGoodsUnits: period.desiredClosingFinishedGoodsUnits,
|
|
81
|
+
unitsToProduce
|
|
82
|
+
},
|
|
83
|
+
materialsUsage: {
|
|
84
|
+
unitsPerFinishedUnit: period.materialUnitsPerFinishedUnit,
|
|
85
|
+
productionUnits: unitsToProduce,
|
|
86
|
+
materialUnitsRequired
|
|
87
|
+
},
|
|
88
|
+
materialsPurchases: {
|
|
89
|
+
openingMaterialUnits,
|
|
90
|
+
materialUnitsRequired,
|
|
91
|
+
desiredClosingMaterialUnits: period.desiredClosingMaterialUnits,
|
|
92
|
+
unitsToPurchase,
|
|
93
|
+
costPerUnit: period.materialCostPerUnit,
|
|
94
|
+
purchaseCost
|
|
95
|
+
},
|
|
96
|
+
directLabour: {
|
|
97
|
+
hoursPerUnit,
|
|
98
|
+
productionUnits: unitsToProduce,
|
|
99
|
+
labourHours,
|
|
100
|
+
ratePerHour,
|
|
101
|
+
labourCost
|
|
102
|
+
},
|
|
103
|
+
productionOverhead: {
|
|
104
|
+
labourHours,
|
|
105
|
+
variableRatePerLabourHour,
|
|
106
|
+
variableOverhead,
|
|
107
|
+
fixedOverhead,
|
|
108
|
+
totalOverhead
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
trace.push({
|
|
112
|
+
id: `${period.id}:production`,
|
|
113
|
+
kind: "derive",
|
|
114
|
+
rule: "Production = sales + desired closing finished goods − opening finished goods.",
|
|
115
|
+
working: `${period.salesUnits} + ${period.desiredClosingFinishedGoodsUnits} − ${openingFinishedGoodsUnits}`,
|
|
116
|
+
result: unitsToProduce
|
|
117
|
+
}, {
|
|
118
|
+
id: `${period.id}:usage`,
|
|
119
|
+
kind: "derive",
|
|
120
|
+
rule: "Material usage = production × material required per finished unit.",
|
|
121
|
+
working: `${unitsToProduce} × ${period.materialUnitsPerFinishedUnit}`,
|
|
122
|
+
result: materialUnitsRequired
|
|
123
|
+
}, {
|
|
124
|
+
id: `${period.id}:purchases`,
|
|
125
|
+
kind: "derive",
|
|
126
|
+
rule: "Material purchases = usage + desired closing materials − opening materials.",
|
|
127
|
+
working: `${materialUnitsRequired} + ${period.desiredClosingMaterialUnits} − ${openingMaterialUnits}`,
|
|
128
|
+
result: unitsToPurchase
|
|
129
|
+
}, {
|
|
130
|
+
id: `${period.id}:labour`,
|
|
131
|
+
kind: "derive",
|
|
132
|
+
rule: "Direct labour hours = production × labour hours required per finished unit.",
|
|
133
|
+
working: `${unitsToProduce} × ${hoursPerUnit}`,
|
|
134
|
+
result: labourHours
|
|
135
|
+
}, {
|
|
136
|
+
id: `${period.id}:overhead`,
|
|
137
|
+
kind: "derive",
|
|
138
|
+
rule: "Production overhead = variable overhead per labour hour × labour hours + fixed production overhead.",
|
|
139
|
+
working: `${variableRatePerLabourHour} × ${labourHours} + ${fixedOverhead}`,
|
|
140
|
+
result: totalOverhead
|
|
141
|
+
});
|
|
142
|
+
openingFinishedGoodsUnits = period.desiredClosingFinishedGoodsUnits;
|
|
143
|
+
openingMaterialUnits = period.desiredClosingMaterialUnits;
|
|
144
|
+
}
|
|
145
|
+
if (diagnostics.length > 0) return emptyResult(diagnostics);
|
|
146
|
+
return {
|
|
147
|
+
completed: true,
|
|
148
|
+
periods,
|
|
149
|
+
totals: {
|
|
150
|
+
salesUnits: sum(periods, (period) => period.sales.units),
|
|
151
|
+
revenue: money(sum(periods, (period) => period.sales.revenue), policy),
|
|
152
|
+
productionUnits: sum(periods, (period) => period.production.unitsToProduce),
|
|
153
|
+
materialUsageUnits: sum(periods, (period) => period.materialsUsage.materialUnitsRequired),
|
|
154
|
+
materialPurchaseUnits: sum(periods, (period) => period.materialsPurchases.unitsToPurchase),
|
|
155
|
+
materialPurchaseCost: money(sum(periods, (period) => period.materialsPurchases.purchaseCost), policy),
|
|
156
|
+
labourHours: sum(periods, (period) => period.directLabour.labourHours),
|
|
157
|
+
labourCost: money(sum(periods, (period) => period.directLabour.labourCost), policy),
|
|
158
|
+
variableProductionOverhead: money(sum(periods, (period) => period.productionOverhead.variableOverhead), policy),
|
|
159
|
+
fixedProductionOverhead: money(sum(periods, (period) => period.productionOverhead.fixedOverhead), policy),
|
|
160
|
+
totalProductionOverhead: money(sum(periods, (period) => period.productionOverhead.totalOverhead), policy)
|
|
161
|
+
},
|
|
162
|
+
diagnostics,
|
|
163
|
+
trace
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const money = (value, policy) => fromMinor(toMinor(value, policy), policy);
|
|
167
|
+
const sum = (periods, select) => periods.reduce((total, period) => total + select(period), 0);
|
|
168
|
+
const emptyResult = (diagnostics) => ({
|
|
169
|
+
completed: false,
|
|
170
|
+
periods: [],
|
|
171
|
+
totals: {
|
|
172
|
+
salesUnits: 0,
|
|
173
|
+
revenue: 0,
|
|
174
|
+
productionUnits: 0,
|
|
175
|
+
materialUsageUnits: 0,
|
|
176
|
+
materialPurchaseUnits: 0,
|
|
177
|
+
materialPurchaseCost: 0,
|
|
178
|
+
labourHours: 0,
|
|
179
|
+
labourCost: 0,
|
|
180
|
+
variableProductionOverhead: 0,
|
|
181
|
+
fixedProductionOverhead: 0,
|
|
182
|
+
totalProductionOverhead: 0
|
|
183
|
+
},
|
|
184
|
+
diagnostics,
|
|
185
|
+
trace: []
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
export { buildOperatingBudget };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { CashBudgetFacts, CashBudgetResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/cash-budget.d.ts
|
|
5
|
+
declare function buildCashBudget(facts: CashBudgetFacts, policy?: AccountingPolicy): CashBudgetResult;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { buildCashBudget };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { fromMinor, toMinor } from "../accounting/precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/management-accounting/cash-budget.ts
|
|
4
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
5
|
+
function buildCashBudget(facts, policy = DEFAULT_POLICY) {
|
|
6
|
+
const diagnostics = [];
|
|
7
|
+
const check = (value, label, periodId) => {
|
|
8
|
+
if (!Number.isFinite(value) || value < 0) diagnostics.push({
|
|
9
|
+
code: "invalid-input",
|
|
10
|
+
severity: "error",
|
|
11
|
+
periodId,
|
|
12
|
+
message: `${label} must be finite and non-negative.`
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
check(facts.openingCashBalance, "Opening cash balance");
|
|
16
|
+
check(facts.minimumCashBalance ?? 0, "Minimum cash balance");
|
|
17
|
+
validateProfile(facts.collectionProfile, "Collection profile", diagnostics);
|
|
18
|
+
validateProfile(facts.materialPaymentProfile, "Material payment profile", diagnostics);
|
|
19
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const period of facts.periods) {
|
|
21
|
+
if (seen.has(period.id)) diagnostics.push({
|
|
22
|
+
code: "duplicate-period",
|
|
23
|
+
severity: "error",
|
|
24
|
+
periodId: period.id,
|
|
25
|
+
message: `Period ${period.id} is duplicated.`
|
|
26
|
+
});
|
|
27
|
+
seen.add(period.id);
|
|
28
|
+
check(period.salesRevenue, "Sales revenue", period.id);
|
|
29
|
+
check(period.materialPurchases, "Material purchases", period.id);
|
|
30
|
+
check(period.labourCost, "Labour cost", period.id);
|
|
31
|
+
check(period.productionOverhead, "Production overhead", period.id);
|
|
32
|
+
check(period.nonCashProductionOverhead ?? 0, "Non-cash production overhead", period.id);
|
|
33
|
+
check(period.broughtForwardReceipts ?? 0, "Brought-forward receipts", period.id);
|
|
34
|
+
check(period.broughtForwardPayments ?? 0, "Brought-forward payments", period.id);
|
|
35
|
+
check(period.otherReceipts ?? 0, "Other receipts", period.id);
|
|
36
|
+
check(period.otherPayments ?? 0, "Other payments", period.id);
|
|
37
|
+
if ((period.nonCashProductionOverhead ?? 0) > period.productionOverhead) diagnostics.push({
|
|
38
|
+
code: "invalid-input",
|
|
39
|
+
severity: "error",
|
|
40
|
+
periodId: period.id,
|
|
41
|
+
message: "Non-cash production overhead cannot exceed total production overhead."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (diagnostics.length > 0) return emptyResult(diagnostics);
|
|
45
|
+
const receipts = Array(facts.periods.length).fill(0);
|
|
46
|
+
const materialPayments = Array(facts.periods.length).fill(0);
|
|
47
|
+
let closingReceivablesMinor = 0;
|
|
48
|
+
let closingMaterialPayablesMinor = 0;
|
|
49
|
+
facts.periods.forEach((period, sourceIndex) => {
|
|
50
|
+
allocate(toMinor(period.salesRevenue, policy), facts.collectionProfile).forEach(({ offset, amountMinor }) => {
|
|
51
|
+
const target = sourceIndex + offset;
|
|
52
|
+
if (target < receipts.length) receipts[target] = (receipts[target] ?? 0) + amountMinor;
|
|
53
|
+
else closingReceivablesMinor += amountMinor;
|
|
54
|
+
});
|
|
55
|
+
allocate(toMinor(period.materialPurchases, policy), facts.materialPaymentProfile).forEach(({ offset, amountMinor }) => {
|
|
56
|
+
const target = sourceIndex + offset;
|
|
57
|
+
if (target < materialPayments.length) materialPayments[target] = (materialPayments[target] ?? 0) + amountMinor;
|
|
58
|
+
else closingMaterialPayablesMinor += amountMinor;
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const periods = [];
|
|
62
|
+
const trace = [];
|
|
63
|
+
const minimumCashMinor = toMinor(facts.minimumCashBalance ?? 0, policy);
|
|
64
|
+
let openingCashMinor = toMinor(facts.openingCashBalance, policy);
|
|
65
|
+
let totalFinancingMinor = 0;
|
|
66
|
+
facts.periods.forEach((period, index) => {
|
|
67
|
+
const customerReceiptsMinor = receipts[index] ?? 0;
|
|
68
|
+
const totalReceiptsMinor = customerReceiptsMinor + toMinor((period.broughtForwardReceipts ?? 0) + (period.otherReceipts ?? 0), policy);
|
|
69
|
+
const materialPaymentsMinor = materialPayments[index] ?? 0;
|
|
70
|
+
const labourPaymentsMinor = toMinor(period.labourCost, policy);
|
|
71
|
+
const overheadPaymentsMinor = toMinor(period.productionOverhead - (period.nonCashProductionOverhead ?? 0), policy);
|
|
72
|
+
const totalPaymentsMinor = materialPaymentsMinor + labourPaymentsMinor + overheadPaymentsMinor + toMinor((period.broughtForwardPayments ?? 0) + (period.otherPayments ?? 0), policy);
|
|
73
|
+
const preFinancingClosingMinor = openingCashMinor + totalReceiptsMinor - totalPaymentsMinor;
|
|
74
|
+
const financingMinor = Math.max(0, minimumCashMinor - preFinancingClosingMinor);
|
|
75
|
+
const closingCashMinor = preFinancingClosingMinor + financingMinor;
|
|
76
|
+
totalFinancingMinor += financingMinor;
|
|
77
|
+
periods.push({
|
|
78
|
+
id: period.id,
|
|
79
|
+
label: period.label,
|
|
80
|
+
openingCashBalance: fromMinor(openingCashMinor, policy),
|
|
81
|
+
customerReceipts: fromMinor(customerReceiptsMinor, policy),
|
|
82
|
+
totalReceipts: fromMinor(totalReceiptsMinor, policy),
|
|
83
|
+
materialPayments: fromMinor(materialPaymentsMinor, policy),
|
|
84
|
+
labourPayments: fromMinor(labourPaymentsMinor, policy),
|
|
85
|
+
overheadPayments: fromMinor(overheadPaymentsMinor, policy),
|
|
86
|
+
totalPayments: fromMinor(totalPaymentsMinor, policy),
|
|
87
|
+
preFinancingClosingCash: fromMinor(preFinancingClosingMinor, policy),
|
|
88
|
+
financingRequired: fromMinor(financingMinor, policy),
|
|
89
|
+
closingCashBalance: fromMinor(closingCashMinor, policy)
|
|
90
|
+
});
|
|
91
|
+
trace.push({
|
|
92
|
+
id: `${period.id}:cash`,
|
|
93
|
+
kind: "derive",
|
|
94
|
+
rule: "Closing cash before financing = opening cash + receipts − payments.",
|
|
95
|
+
working: `${fromMinor(openingCashMinor, policy)} + ${fromMinor(totalReceiptsMinor, policy)} − ${fromMinor(totalPaymentsMinor, policy)}`,
|
|
96
|
+
result: fromMinor(preFinancingClosingMinor, policy)
|
|
97
|
+
});
|
|
98
|
+
openingCashMinor = closingCashMinor;
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
completed: true,
|
|
102
|
+
periods,
|
|
103
|
+
closingReceivables: fromMinor(closingReceivablesMinor, policy),
|
|
104
|
+
closingMaterialPayables: fromMinor(closingMaterialPayablesMinor, policy),
|
|
105
|
+
totalFinancingRequired: fromMinor(totalFinancingMinor, policy),
|
|
106
|
+
diagnostics,
|
|
107
|
+
trace
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function validateProfile(profile, label, diagnostics) {
|
|
111
|
+
if (profile.length === 0) diagnostics.push({
|
|
112
|
+
code: "invalid-profile",
|
|
113
|
+
severity: "error",
|
|
114
|
+
message: `${label} must contain at least one allocation.`
|
|
115
|
+
});
|
|
116
|
+
const offsets = /* @__PURE__ */ new Set();
|
|
117
|
+
for (const allocation of profile) {
|
|
118
|
+
if (!Number.isInteger(allocation.offset) || allocation.offset < 0 || !Number.isFinite(allocation.proportion) || allocation.proportion < 0 || allocation.proportion > 1 || offsets.has(allocation.offset)) diagnostics.push({
|
|
119
|
+
code: "invalid-profile",
|
|
120
|
+
severity: "error",
|
|
121
|
+
message: `${label} offsets must be unique non-negative integers and proportions must be between zero and one.`
|
|
122
|
+
});
|
|
123
|
+
offsets.add(allocation.offset);
|
|
124
|
+
}
|
|
125
|
+
const total = profile.reduce((sum, allocation) => sum + allocation.proportion, 0);
|
|
126
|
+
if (Math.abs(total - 1) > 1e-9) diagnostics.push({
|
|
127
|
+
code: "invalid-profile",
|
|
128
|
+
severity: "error",
|
|
129
|
+
message: `${label} proportions must total exactly 1.`
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function allocate(totalMinor, profile) {
|
|
133
|
+
let remaining = totalMinor;
|
|
134
|
+
return profile.map((allocation, index) => {
|
|
135
|
+
const amountMinor = index === profile.length - 1 ? remaining : Math.round(totalMinor * allocation.proportion);
|
|
136
|
+
remaining -= amountMinor;
|
|
137
|
+
return {
|
|
138
|
+
offset: allocation.offset,
|
|
139
|
+
amountMinor
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const emptyResult = (diagnostics) => ({
|
|
144
|
+
completed: false,
|
|
145
|
+
periods: [],
|
|
146
|
+
closingReceivables: 0,
|
|
147
|
+
closingMaterialPayables: 0,
|
|
148
|
+
totalFinancingRequired: 0,
|
|
149
|
+
diagnostics,
|
|
150
|
+
trace: []
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
export { buildCashBudget };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { ClassifiedCost, CostClassificationSummary, MarginalAbsorptionFacts, MarginalAbsorptionResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/costing.d.ts
|
|
5
|
+
declare function summarizeClassifiedCosts(costs: readonly ClassifiedCost[]): CostClassificationSummary;
|
|
6
|
+
declare function compareMarginalAndAbsorptionCosting(facts: MarginalAbsorptionFacts, policy?: AccountingPolicy): MarginalAbsorptionResult;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { compareMarginalAndAbsorptionCosting, summarizeClassifiedCosts };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { fromMinor, toMinor } from "../accounting/precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/management-accounting/costing.ts
|
|
4
|
+
const DEFAULT_POLICY = { decimalPlaces: 2 };
|
|
5
|
+
function summarizeClassifiedCosts(costs) {
|
|
6
|
+
const sum = (predicate) => costs.filter(predicate).reduce((total, cost) => total + cost.amount, 0);
|
|
7
|
+
return {
|
|
8
|
+
variableProductionPerUnit: sum((cost) => cost.behavior === "variable" && cost.function === "production" && cost.basis === "per-unit"),
|
|
9
|
+
variableNonProductionPerUnit: sum((cost) => cost.behavior === "variable" && cost.function !== "production" && cost.basis === "per-unit"),
|
|
10
|
+
fixedProduction: sum((cost) => cost.behavior === "fixed" && cost.function === "production" && cost.basis === "period"),
|
|
11
|
+
fixedNonProduction: sum((cost) => cost.behavior === "fixed" && cost.function !== "production" && cost.basis === "period"),
|
|
12
|
+
directCostPerUnit: sum((cost) => cost.traceability === "direct" && cost.basis === "per-unit"),
|
|
13
|
+
indirectPeriodCost: sum((cost) => cost.traceability === "indirect" && cost.basis === "period")
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function compareMarginalAndAbsorptionCosting(facts, policy = DEFAULT_POLICY) {
|
|
17
|
+
const diagnostics = [];
|
|
18
|
+
for (const cost of facts.costs) {
|
|
19
|
+
if (!Number.isFinite(cost.amount) || cost.amount < 0) diagnostics.push({
|
|
20
|
+
code: "invalid-cost",
|
|
21
|
+
severity: "error",
|
|
22
|
+
costId: cost.id,
|
|
23
|
+
message: `${cost.label} must be a finite non-negative amount.`
|
|
24
|
+
});
|
|
25
|
+
if (cost.behavior === "variable" !== (cost.basis === "per-unit")) diagnostics.push({
|
|
26
|
+
code: "invalid-cost",
|
|
27
|
+
severity: "error",
|
|
28
|
+
costId: cost.id,
|
|
29
|
+
message: `${cost.label} must use a per-unit basis when variable and a period basis when fixed.`
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const openingUnits = facts.openingInventoryUnits ?? 0;
|
|
33
|
+
for (const [label, value] of [
|
|
34
|
+
["unitsProduced", facts.unitsProduced],
|
|
35
|
+
["unitsSold", facts.unitsSold],
|
|
36
|
+
["openingInventoryUnits", openingUnits],
|
|
37
|
+
["sellingPricePerUnit", facts.sellingPricePerUnit]
|
|
38
|
+
]) if (!Number.isFinite(value) || value < 0) diagnostics.push({
|
|
39
|
+
code: "invalid-volume",
|
|
40
|
+
severity: "error",
|
|
41
|
+
message: `${label} must be finite and non-negative.`
|
|
42
|
+
});
|
|
43
|
+
if (!Number.isFinite(facts.normalCapacityUnits) || facts.normalCapacityUnits <= 0) diagnostics.push({
|
|
44
|
+
code: "invalid-capacity",
|
|
45
|
+
severity: "error",
|
|
46
|
+
message: "Normal capacity must be finite and positive."
|
|
47
|
+
});
|
|
48
|
+
const closingUnits = openingUnits + facts.unitsProduced - facts.unitsSold;
|
|
49
|
+
if (closingUnits < 0) diagnostics.push({
|
|
50
|
+
code: "invalid-volume",
|
|
51
|
+
severity: "error",
|
|
52
|
+
message: "Units sold cannot exceed opening inventory plus production."
|
|
53
|
+
});
|
|
54
|
+
const emptyStatement = {
|
|
55
|
+
revenue: 0,
|
|
56
|
+
variableProductionCostOfSales: 0,
|
|
57
|
+
fixedProductionCostOfSales: 0,
|
|
58
|
+
variableNonProductionCost: 0,
|
|
59
|
+
fixedNonProductionCost: 0,
|
|
60
|
+
underAbsorption: 0,
|
|
61
|
+
overAbsorption: 0,
|
|
62
|
+
profit: 0
|
|
63
|
+
};
|
|
64
|
+
const emptyValues = {
|
|
65
|
+
closingInventoryUnits: 0,
|
|
66
|
+
fixedOverheadRate: 0,
|
|
67
|
+
absorbedFixedOverhead: 0,
|
|
68
|
+
actualFixedOverhead: 0,
|
|
69
|
+
marginalClosingInventory: 0,
|
|
70
|
+
absorptionClosingInventory: 0,
|
|
71
|
+
inventoryFixedOverheadMovement: 0,
|
|
72
|
+
profitDifference: 0
|
|
73
|
+
};
|
|
74
|
+
const classification = summarizeClassifiedCosts(facts.costs);
|
|
75
|
+
if (diagnostics.length > 0) return {
|
|
76
|
+
classification,
|
|
77
|
+
values: emptyValues,
|
|
78
|
+
marginal: emptyStatement,
|
|
79
|
+
absorption: emptyStatement,
|
|
80
|
+
reconciles: false,
|
|
81
|
+
diagnostics,
|
|
82
|
+
trace: []
|
|
83
|
+
};
|
|
84
|
+
const money = (value) => fromMinor(toMinor(value, policy), policy);
|
|
85
|
+
const revenue = money(facts.unitsSold * facts.sellingPricePerUnit);
|
|
86
|
+
const variableProductionCostOfSales = money(facts.unitsSold * classification.variableProductionPerUnit);
|
|
87
|
+
const variableNonProductionCost = money(facts.unitsSold * classification.variableNonProductionPerUnit);
|
|
88
|
+
const fixedOverheadRate = money(classification.fixedProduction / facts.normalCapacityUnits);
|
|
89
|
+
const actualFixedOverhead = money(facts.actualFixedProductionOverhead ?? classification.fixedProduction);
|
|
90
|
+
const absorbedFixedOverhead = money(facts.unitsProduced * fixedOverheadRate);
|
|
91
|
+
const absorptionDifference = money(absorbedFixedOverhead - actualFixedOverhead);
|
|
92
|
+
const underAbsorption = Math.max(0, -absorptionDifference);
|
|
93
|
+
const overAbsorption = Math.max(0, absorptionDifference);
|
|
94
|
+
const fixedProductionCostOfSales = money(facts.unitsSold * fixedOverheadRate);
|
|
95
|
+
const contribution = money(revenue - variableProductionCostOfSales - variableNonProductionCost);
|
|
96
|
+
const marginalProfit = money(contribution - actualFixedOverhead - classification.fixedNonProduction);
|
|
97
|
+
const grossProfit = money(revenue - variableProductionCostOfSales - fixedProductionCostOfSales);
|
|
98
|
+
const absorptionProfit = money(grossProfit - variableNonProductionCost - classification.fixedNonProduction - underAbsorption + overAbsorption);
|
|
99
|
+
const marginalClosingInventory = money(closingUnits * classification.variableProductionPerUnit);
|
|
100
|
+
const absorptionClosingInventory = money(closingUnits * (classification.variableProductionPerUnit + fixedOverheadRate));
|
|
101
|
+
const inventoryFixedOverheadMovement = money((closingUnits - openingUnits) * fixedOverheadRate);
|
|
102
|
+
const profitDifference = money(absorptionProfit - marginalProfit);
|
|
103
|
+
const reconciles = profitDifference === inventoryFixedOverheadMovement;
|
|
104
|
+
const trace = [
|
|
105
|
+
{
|
|
106
|
+
id: "costing:fixed-rate",
|
|
107
|
+
kind: "derive",
|
|
108
|
+
rule: "Fixed production overhead absorption rate = budgeted fixed production overhead ÷ normal capacity.",
|
|
109
|
+
working: `${classification.fixedProduction} ÷ ${facts.normalCapacityUnits}`,
|
|
110
|
+
result: fixedOverheadRate
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "costing:contribution",
|
|
114
|
+
kind: "derive",
|
|
115
|
+
rule: "Contribution = revenue − all variable costs of sales.",
|
|
116
|
+
working: `${revenue} − ${variableProductionCostOfSales} − ${variableNonProductionCost}`,
|
|
117
|
+
result: contribution
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "costing:absorption",
|
|
121
|
+
kind: "derive",
|
|
122
|
+
rule: "Absorption profit charges fixed production overhead through units sold and corrects under/over-absorption.",
|
|
123
|
+
working: `${grossProfit} − ${variableNonProductionCost} − ${classification.fixedNonProduction} − ${underAbsorption} + ${overAbsorption}`,
|
|
124
|
+
result: absorptionProfit
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: "costing:reconcile",
|
|
128
|
+
kind: "check",
|
|
129
|
+
rule: "Profit difference = change in inventory units × fixed production overhead rate.",
|
|
130
|
+
working: `${closingUnits - openingUnits} × ${fixedOverheadRate}`,
|
|
131
|
+
result: reconciles
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
return {
|
|
135
|
+
classification,
|
|
136
|
+
values: {
|
|
137
|
+
closingInventoryUnits: closingUnits,
|
|
138
|
+
fixedOverheadRate,
|
|
139
|
+
absorbedFixedOverhead,
|
|
140
|
+
actualFixedOverhead,
|
|
141
|
+
marginalClosingInventory,
|
|
142
|
+
absorptionClosingInventory,
|
|
143
|
+
inventoryFixedOverheadMovement,
|
|
144
|
+
profitDifference
|
|
145
|
+
},
|
|
146
|
+
marginal: {
|
|
147
|
+
revenue,
|
|
148
|
+
variableProductionCostOfSales,
|
|
149
|
+
fixedProductionCostOfSales: 0,
|
|
150
|
+
variableNonProductionCost,
|
|
151
|
+
fixedNonProductionCost: classification.fixedNonProduction,
|
|
152
|
+
contribution,
|
|
153
|
+
underAbsorption: 0,
|
|
154
|
+
overAbsorption: 0,
|
|
155
|
+
profit: marginalProfit
|
|
156
|
+
},
|
|
157
|
+
absorption: {
|
|
158
|
+
revenue,
|
|
159
|
+
variableProductionCostOfSales,
|
|
160
|
+
fixedProductionCostOfSales,
|
|
161
|
+
variableNonProductionCost,
|
|
162
|
+
fixedNonProductionCost: classification.fixedNonProduction,
|
|
163
|
+
grossProfit,
|
|
164
|
+
underAbsorption,
|
|
165
|
+
overAbsorption,
|
|
166
|
+
profit: absorptionProfit
|
|
167
|
+
},
|
|
168
|
+
reconciles,
|
|
169
|
+
diagnostics,
|
|
170
|
+
trace
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
export { compareMarginalAndAbsorptionCosting, summarizeClassifiedCosts };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccountingPolicy } from "../accounting/types.mjs";
|
|
2
|
+
import { LimitedFactorProduct, LimitedFactorResult, RelevantCostAlternative, RelevantCostDecisionResult } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/finance/management-accounting/decisions.d.ts
|
|
5
|
+
declare function optimizeLimitedFactor(products: readonly LimitedFactorProduct[], resourceAvailable: number, policy?: AccountingPolicy): LimitedFactorResult;
|
|
6
|
+
declare function evaluateRelevantCostDecision(alternatives: readonly RelevantCostAlternative[], policy?: AccountingPolicy): RelevantCostDecisionResult;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { evaluateRelevantCostDecision, optimizeLimitedFactor };
|