@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,150 @@
|
|
|
1
|
+
import { DEFAULT_ACCOUNTING_POLICY, fromMinor, toMinor } from "./precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/company-statements.ts
|
|
4
|
+
const line = (id, label, amount, kind = "detail", treatment) => ({
|
|
5
|
+
id,
|
|
6
|
+
label,
|
|
7
|
+
amount,
|
|
8
|
+
kind,
|
|
9
|
+
...treatment ? { treatment } : {}
|
|
10
|
+
});
|
|
11
|
+
const section = (id, title, lines) => ({
|
|
12
|
+
id,
|
|
13
|
+
title,
|
|
14
|
+
lines
|
|
15
|
+
});
|
|
16
|
+
function solveLimitedCompanyStatements(facts, policy = DEFAULT_ACCOUNTING_POLICY) {
|
|
17
|
+
const diagnostics = [];
|
|
18
|
+
for (const [name, value] of Object.entries(facts)) if (!Number.isFinite(value) || value < 0) diagnostics.push({
|
|
19
|
+
code: "invalid-adjustment",
|
|
20
|
+
severity: "error",
|
|
21
|
+
message: `${name} must be a finite non-negative amount.`
|
|
22
|
+
});
|
|
23
|
+
const zero = {
|
|
24
|
+
grossProfit: 0,
|
|
25
|
+
operatingProfit: 0,
|
|
26
|
+
profitBeforeTax: 0,
|
|
27
|
+
profitForYear: 0,
|
|
28
|
+
closingRetainedEarnings: 0,
|
|
29
|
+
totalEquity: 0,
|
|
30
|
+
totalLiabilities: 0,
|
|
31
|
+
totalAssets: 0,
|
|
32
|
+
totalEquityAndLiabilities: 0,
|
|
33
|
+
balanceDifference: 0
|
|
34
|
+
};
|
|
35
|
+
if (diagnostics.length > 0) return {
|
|
36
|
+
incomeStatement: [],
|
|
37
|
+
statementOfChangesInEquity: [],
|
|
38
|
+
statementOfFinancialPosition: [],
|
|
39
|
+
values: zero,
|
|
40
|
+
balances: false,
|
|
41
|
+
diagnostics,
|
|
42
|
+
trace: []
|
|
43
|
+
};
|
|
44
|
+
const m = (value) => toMinor(value, policy);
|
|
45
|
+
const out = (value) => fromMinor(value, policy);
|
|
46
|
+
const grossProfit = m(facts.revenue) - m(facts.costOfSales);
|
|
47
|
+
const operatingProfit = grossProfit - m(facts.operatingExpenses);
|
|
48
|
+
const profitBeforeTax = operatingProfit - m(facts.financeCosts);
|
|
49
|
+
const profitForYear = profitBeforeTax - m(facts.taxExpense);
|
|
50
|
+
const closingRetainedEarnings = m(facts.openingRetainedEarnings) + profitForYear - m(facts.dividendsDeclared);
|
|
51
|
+
const totalEquity = m(facts.ordinaryShareCapital) + m(facts.sharePremium ?? 0) + m(facts.generalReserve ?? 0) + closingRetainedEarnings;
|
|
52
|
+
const totalLiabilities = m(facts.debentures) + m(facts.currentLiabilities);
|
|
53
|
+
const totalAssets = m(facts.nonCurrentAssets) + m(facts.currentAssets);
|
|
54
|
+
const totalEquityAndLiabilities = totalEquity + totalLiabilities;
|
|
55
|
+
const balanceDifference = totalAssets - totalEquityAndLiabilities;
|
|
56
|
+
const values = {
|
|
57
|
+
grossProfit: out(grossProfit),
|
|
58
|
+
operatingProfit: out(operatingProfit),
|
|
59
|
+
profitBeforeTax: out(profitBeforeTax),
|
|
60
|
+
profitForYear: out(profitForYear),
|
|
61
|
+
closingRetainedEarnings: out(closingRetainedEarnings),
|
|
62
|
+
totalEquity: out(totalEquity),
|
|
63
|
+
totalLiabilities: out(totalLiabilities),
|
|
64
|
+
totalAssets: out(totalAssets),
|
|
65
|
+
totalEquityAndLiabilities: out(totalEquityAndLiabilities),
|
|
66
|
+
balanceDifference: out(balanceDifference)
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
incomeStatement: [section("trading", "Trading", [
|
|
70
|
+
line("revenue", "Revenue", facts.revenue, "detail", "add"),
|
|
71
|
+
line("cost-of-sales", "Cost of sales", facts.costOfSales, "detail", "subtract"),
|
|
72
|
+
line("gross-profit", "Gross profit", values.grossProfit, "subtotal", "result")
|
|
73
|
+
]), section("operations", "Operations and finance", [
|
|
74
|
+
line("operating-expenses", "Operating expenses", facts.operatingExpenses, "detail", "subtract"),
|
|
75
|
+
line("operating-profit", "Operating profit", values.operatingProfit, "subtotal", "result"),
|
|
76
|
+
line("finance-costs", "Finance costs", facts.financeCosts, "detail", "subtract"),
|
|
77
|
+
line("profit-before-tax", "Profit before tax", values.profitBeforeTax, "subtotal", "result"),
|
|
78
|
+
line("tax-expense", "Income tax expense", facts.taxExpense, "detail", "subtract"),
|
|
79
|
+
line("profit-for-year", "Profit for the year", values.profitForYear, "total", "result")
|
|
80
|
+
])],
|
|
81
|
+
statementOfChangesInEquity: [section("retained-earnings", "Retained earnings", [
|
|
82
|
+
line("opening-retained", "Opening retained earnings", facts.openingRetainedEarnings, "detail", "add"),
|
|
83
|
+
line("profit-for-year-equity", "Profit for the year", values.profitForYear, "detail", "add"),
|
|
84
|
+
line("dividends", "Dividends declared", facts.dividendsDeclared, "detail", "subtract"),
|
|
85
|
+
line("closing-retained", "Closing retained earnings", values.closingRetainedEarnings, "total", "result")
|
|
86
|
+
])],
|
|
87
|
+
statementOfFinancialPosition: [
|
|
88
|
+
section("assets", "Assets", [
|
|
89
|
+
line("non-current-assets", "Non-current assets", facts.nonCurrentAssets),
|
|
90
|
+
line("current-assets", "Current assets", facts.currentAssets),
|
|
91
|
+
line("total-assets", "Total assets", values.totalAssets, "total", "result")
|
|
92
|
+
]),
|
|
93
|
+
section("equity", "Equity", [
|
|
94
|
+
line("ordinary-share-capital", "Ordinary share capital", facts.ordinaryShareCapital),
|
|
95
|
+
line("share-premium", "Share premium", facts.sharePremium ?? 0),
|
|
96
|
+
line("general-reserve", "General reserve", facts.generalReserve ?? 0),
|
|
97
|
+
line("retained-earnings-position", "Retained earnings", values.closingRetainedEarnings),
|
|
98
|
+
line("total-equity", "Total equity", values.totalEquity, "subtotal", "result")
|
|
99
|
+
]),
|
|
100
|
+
section("liabilities", "Liabilities", [
|
|
101
|
+
line("debentures", "Debentures", facts.debentures),
|
|
102
|
+
line("current-liabilities", "Current liabilities", facts.currentLiabilities),
|
|
103
|
+
line("equity-and-liabilities", "Total equity and liabilities", values.totalEquityAndLiabilities, "total", "result")
|
|
104
|
+
])
|
|
105
|
+
],
|
|
106
|
+
values,
|
|
107
|
+
balances: balanceDifference === 0,
|
|
108
|
+
diagnostics,
|
|
109
|
+
trace: [
|
|
110
|
+
{
|
|
111
|
+
id: "company:profit",
|
|
112
|
+
kind: "derive",
|
|
113
|
+
rule: "Profit for the year follows trading, operating, finance and tax stages.",
|
|
114
|
+
working: `${facts.revenue} − ${facts.costOfSales} − ${facts.operatingExpenses} − ${facts.financeCosts} − ${facts.taxExpense}`,
|
|
115
|
+
result: values.profitForYear
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "company:retained",
|
|
119
|
+
kind: "derive",
|
|
120
|
+
rule: "Closing retained earnings = opening retained earnings + profit for the year − dividends.",
|
|
121
|
+
working: `${facts.openingRetainedEarnings} + ${values.profitForYear} − ${facts.dividendsDeclared}`,
|
|
122
|
+
result: values.closingRetainedEarnings
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "company:dividend",
|
|
126
|
+
kind: "classify",
|
|
127
|
+
rule: "A dividend is a distribution of profit, not an operating expense.",
|
|
128
|
+
working: `${facts.dividendsDeclared} deducted in changes in equity`,
|
|
129
|
+
result: "appropriation of retained earnings"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "company:position",
|
|
133
|
+
kind: "check",
|
|
134
|
+
rule: "Assets must equal equity plus liabilities; debentures are liabilities, not share capital.",
|
|
135
|
+
working: `${values.totalAssets} − ${values.totalEquityAndLiabilities}`,
|
|
136
|
+
result: balanceDifference === 0
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function solveDividendSettledCompanyScenario(base, dividendsDeclared, policy = DEFAULT_ACCOUNTING_POLICY) {
|
|
142
|
+
return solveLimitedCompanyStatements({
|
|
143
|
+
...base,
|
|
144
|
+
dividendsDeclared,
|
|
145
|
+
currentAssets: base.currentAssets - (dividendsDeclared - base.dividendsDeclared)
|
|
146
|
+
}, policy);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
export { solveDividendSettledCompanyScenario, solveLimitedCompanyStatements };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccountingCase, AccountingCaseResult } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/harness.d.ts
|
|
4
|
+
/** Runs a curriculum case through the same engine used by interactive labs. */
|
|
5
|
+
declare function runAccountingCase(problem: AccountingCase): AccountingCaseResult;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { runAccountingCase };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { solveBusinessProblem, solveJournal } from "./solve.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/harness.ts
|
|
4
|
+
function check(name, actual, expected) {
|
|
5
|
+
return {
|
|
6
|
+
name,
|
|
7
|
+
passed: Array.isArray(actual) && Array.isArray(expected) ? actual.length === expected.length && actual.every((value, index) => value === expected[index]) : actual === expected,
|
|
8
|
+
expected,
|
|
9
|
+
actual
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** Runs a curriculum case through the same engine used by interactive labs. */
|
|
13
|
+
function runAccountingCase(problem) {
|
|
14
|
+
if (problem.events == null === (problem.entries == null)) throw new Error(`Accounting case ${problem.id} must define exactly one of events or entries.`);
|
|
15
|
+
const solution = problem.events ? solveBusinessProblem({
|
|
16
|
+
accounts: problem.accounts,
|
|
17
|
+
events: problem.events,
|
|
18
|
+
policy: problem.policy
|
|
19
|
+
}) : solveJournal({
|
|
20
|
+
accounts: problem.accounts,
|
|
21
|
+
entries: problem.entries,
|
|
22
|
+
policy: problem.policy
|
|
23
|
+
});
|
|
24
|
+
const checks = [];
|
|
25
|
+
const expected = problem.expect;
|
|
26
|
+
if (expected.acceptedEntries != null) checks.push(check("accepted entries", solution.acceptedEntries.length, expected.acceptedEntries));
|
|
27
|
+
if (expected.rejectedEntries != null) checks.push(check("rejected entries", solution.rejectedEntries.length, expected.rejectedEntries));
|
|
28
|
+
if (expected.trialBalanceTotal != null) checks.push(check("trial balance total", solution.trialBalance.debitTotal, expected.trialBalanceTotal));
|
|
29
|
+
if (expected.profit != null) checks.push(check("profit", solution.equation.profit, expected.profit));
|
|
30
|
+
if (expected.assets != null) checks.push(check("assets", solution.equation.assets, expected.assets));
|
|
31
|
+
if (expected.liabilities != null) checks.push(check("liabilities", solution.equation.liabilities, expected.liabilities));
|
|
32
|
+
if (expected.equity != null) checks.push(check("equity", solution.equation.equity, expected.equity));
|
|
33
|
+
if (expected.diagnosticCodes != null) checks.push(check("diagnostic codes", solution.diagnostics.map((item) => item.code).sort(), [...expected.diagnosticCodes].sort()));
|
|
34
|
+
checks.push(check("trial balance invariant", String(solution.trialBalance.balances), "true"));
|
|
35
|
+
checks.push(check("accounting equation invariant", String(solution.equation.balances), "true"));
|
|
36
|
+
return {
|
|
37
|
+
caseId: problem.id,
|
|
38
|
+
passed: checks.every((item) => item.passed),
|
|
39
|
+
checks,
|
|
40
|
+
solution
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { runAccountingCase };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AccountCategory, AccountDefinition, AccountRole, AccountingCase, AccountingCaseResult, AccountingCheck, AccountingDiagnostic, AccountingEquation, AccountingExpectation, AccountingPolicy, AccountingSolution, AdjustmentFact, AdjustmentResult, BankReconciliationItem, BankReconciliationResult, BusinessEvent, ClubMember, ClubMemberState, ClubMemberTiming, ClubStatementFacts, ClubStatementResult, ClubSubscriptionResult, ControlAccountFacts, ControlAccountResult, ExplanationStep, FinancialAnalysisComparison, FinancialAnalysisFacts, FinancialAnalysisResult, FinancialRatioAssessment, FinancialRatioBenchmark, FinancialRatioFamily, FinancialRatioKey, FinancialRatioMetric, FinancialStatements, JournalEntry, JournalLine, LedgerAccount, LedgerPosting, LimitedCompanyStatementFacts, LimitedCompanyStatementResult, ManufacturingAccountFacts, ManufacturingAccountResult, ManufacturingFlowStage, ManufacturingTradingFacts, ManufacturingTradingResult, PartnerAppropriation, PartnerFacts, PartnershipAgreement, PartnershipResult, PostingSide, SoleTraderPeriodCase, SoleTraderPeriodResult, SoleTraderStatementFacts, SoleTraderStatementResult, StatementLine, StatementSection, SuspenseCorrectionFact, SuspenseDiscoveredError, SuspenseMovement, SuspenseReconstructionFacts, SuspenseReconstructionResult, TrialBalance, TrialBalanceErrorDiagnosis, TrialBalanceErrorType, TrialBalanceLine } from "./types.mjs";
|
|
2
|
+
import { DEFAULT_ACCOUNTING_POLICY, amountScale, fromMinor, toMinor } from "./precision.mjs";
|
|
3
|
+
import { changeSide, deriveNaturalEquation, normalBalance, statementOf, totalsBalance } from "./rules.mjs";
|
|
4
|
+
import { validateChart, validateJournalEntry } from "./validate.mjs";
|
|
5
|
+
import { journalizeBusinessEvent, journalizeBusinessEvents } from "./journalize.mjs";
|
|
6
|
+
import { applyAdjustments, produceAdjustment } from "./adjustments.mjs";
|
|
7
|
+
import { createSuspenseCorrection, diagnoseTrialBalanceError, reconcileBank, reconstructSuspenseAccount, solveControlAccount } from "./verification.mjs";
|
|
8
|
+
import { solveCashSettledSoleTraderScenario, solveSoleTraderStatements } from "./statements.mjs";
|
|
9
|
+
import { salaryForEqualPartnershipShares, solvePartnershipAppropriation } from "./partnership.mjs";
|
|
10
|
+
import { solveDividendSettledCompanyScenario, solveLimitedCompanyStatements } from "./company-statements.mjs";
|
|
11
|
+
import { CLUB_MEMBER_STATES, clubMemberCrossesYear, clubMemberTiming, solveClubStatements, solveClubSubscriptions } from "./clubs.mjs";
|
|
12
|
+
import { solveManufacturingAccount, solveManufacturingTradingFlow } from "./manufacturing.mjs";
|
|
13
|
+
import { solveSoleTraderPeriod } from "./period-case.mjs";
|
|
14
|
+
import { analyzeFinancialPerformance, assessFinancialPerformance, compareFinancialPerformance } from "./analysis.mjs";
|
|
15
|
+
import { runAccountingCase } from "./harness.mjs";
|
|
16
|
+
import { deriveEquation, deriveStatements, deriveTrialBalance, postLedger } from "./post.mjs";
|
|
17
|
+
import { SolveJournalOptions, solveBusinessProblem, solveJournal } from "./solve.mjs";
|
|
18
|
+
export { AccountCategory, AccountDefinition, AccountRole, AccountingCase, AccountingCaseResult, AccountingCheck, AccountingDiagnostic, AccountingEquation, AccountingExpectation, AccountingPolicy, AccountingSolution, AdjustmentFact, AdjustmentResult, BankReconciliationItem, BankReconciliationResult, BusinessEvent, CLUB_MEMBER_STATES, ClubMember, ClubMemberState, ClubMemberTiming, ClubStatementFacts, ClubStatementResult, ClubSubscriptionResult, ControlAccountFacts, ControlAccountResult, DEFAULT_ACCOUNTING_POLICY, ExplanationStep, FinancialAnalysisComparison, FinancialAnalysisFacts, FinancialAnalysisResult, FinancialRatioAssessment, FinancialRatioBenchmark, FinancialRatioFamily, FinancialRatioKey, FinancialRatioMetric, FinancialStatements, JournalEntry, JournalLine, LedgerAccount, LedgerPosting, LimitedCompanyStatementFacts, LimitedCompanyStatementResult, ManufacturingAccountFacts, ManufacturingAccountResult, ManufacturingFlowStage, ManufacturingTradingFacts, ManufacturingTradingResult, PartnerAppropriation, PartnerFacts, PartnershipAgreement, PartnershipResult, PostingSide, SoleTraderPeriodCase, SoleTraderPeriodResult, SoleTraderStatementFacts, SoleTraderStatementResult, SolveJournalOptions, StatementLine, StatementSection, SuspenseCorrectionFact, SuspenseDiscoveredError, SuspenseMovement, SuspenseReconstructionFacts, SuspenseReconstructionResult, TrialBalance, TrialBalanceErrorDiagnosis, TrialBalanceErrorType, TrialBalanceLine, amountScale, analyzeFinancialPerformance, applyAdjustments, assessFinancialPerformance, changeSide, clubMemberCrossesYear, clubMemberTiming, compareFinancialPerformance, createSuspenseCorrection, deriveEquation, deriveNaturalEquation, deriveStatements, deriveTrialBalance, diagnoseTrialBalanceError, fromMinor, journalizeBusinessEvent, journalizeBusinessEvents, normalBalance, postLedger, produceAdjustment, reconcileBank, reconstructSuspenseAccount, runAccountingCase, salaryForEqualPartnershipShares, solveBusinessProblem, solveCashSettledSoleTraderScenario, solveClubStatements, solveClubSubscriptions, solveControlAccount, solveDividendSettledCompanyScenario, solveJournal, solveLimitedCompanyStatements, solveManufacturingAccount, solveManufacturingTradingFlow, solvePartnershipAppropriation, solveSoleTraderPeriod, solveSoleTraderStatements, statementOf, toMinor, totalsBalance, validateChart, validateJournalEntry };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { journalizeBusinessEvent, journalizeBusinessEvents } from "./journalize.mjs";
|
|
2
|
+
import { DEFAULT_ACCOUNTING_POLICY, amountScale, fromMinor, toMinor } from "./precision.mjs";
|
|
3
|
+
import { changeSide, deriveNaturalEquation, normalBalance, statementOf, totalsBalance } from "./rules.mjs";
|
|
4
|
+
import { deriveEquation, deriveStatements, deriveTrialBalance, postLedger } from "./post.mjs";
|
|
5
|
+
import { validateChart, validateJournalEntry } from "./validate.mjs";
|
|
6
|
+
import { solveBusinessProblem, solveJournal } from "./solve.mjs";
|
|
7
|
+
import { applyAdjustments, produceAdjustment } from "./adjustments.mjs";
|
|
8
|
+
import { createSuspenseCorrection, diagnoseTrialBalanceError, reconcileBank, reconstructSuspenseAccount, solveControlAccount } from "./verification.mjs";
|
|
9
|
+
import { solveCashSettledSoleTraderScenario, solveSoleTraderStatements } from "./statements.mjs";
|
|
10
|
+
import { salaryForEqualPartnershipShares, solvePartnershipAppropriation } from "./partnership.mjs";
|
|
11
|
+
import { solveDividendSettledCompanyScenario, solveLimitedCompanyStatements } from "./company-statements.mjs";
|
|
12
|
+
import { CLUB_MEMBER_STATES, clubMemberCrossesYear, clubMemberTiming, solveClubStatements, solveClubSubscriptions } from "./clubs.mjs";
|
|
13
|
+
import { solveManufacturingAccount, solveManufacturingTradingFlow } from "./manufacturing.mjs";
|
|
14
|
+
import { solveSoleTraderPeriod } from "./period-case.mjs";
|
|
15
|
+
import { analyzeFinancialPerformance, assessFinancialPerformance, compareFinancialPerformance } from "./analysis.mjs";
|
|
16
|
+
import { runAccountingCase } from "./harness.mjs";
|
|
17
|
+
|
|
18
|
+
export { CLUB_MEMBER_STATES, DEFAULT_ACCOUNTING_POLICY, amountScale, analyzeFinancialPerformance, applyAdjustments, assessFinancialPerformance, changeSide, clubMemberCrossesYear, clubMemberTiming, compareFinancialPerformance, createSuspenseCorrection, deriveEquation, deriveNaturalEquation, deriveStatements, deriveTrialBalance, diagnoseTrialBalanceError, fromMinor, journalizeBusinessEvent, journalizeBusinessEvents, normalBalance, postLedger, produceAdjustment, reconcileBank, reconstructSuspenseAccount, runAccountingCase, salaryForEqualPartnershipShares, solveBusinessProblem, solveCashSettledSoleTraderScenario, solveClubStatements, solveClubSubscriptions, solveControlAccount, solveDividendSettledCompanyScenario, solveJournal, solveLimitedCompanyStatements, solveManufacturingAccount, solveManufacturingTradingFlow, solvePartnershipAppropriation, solveSoleTraderPeriod, solveSoleTraderStatements, statementOf, toMinor, totalsBalance, validateChart, validateJournalEntry };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AccountDefinition, AccountingDiagnostic, BusinessEvent, ExplanationStep, JournalEntry } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/journalize.d.ts
|
|
4
|
+
interface JournalizedEvent {
|
|
5
|
+
entry?: JournalEntry;
|
|
6
|
+
diagnostics: AccountingDiagnostic[];
|
|
7
|
+
trace: ExplanationStep[];
|
|
8
|
+
}
|
|
9
|
+
declare function journalizeBusinessEvent(event: BusinessEvent, accounts: readonly AccountDefinition[]): JournalizedEvent;
|
|
10
|
+
declare function journalizeBusinessEvents(events: readonly BusinessEvent[], accounts: readonly AccountDefinition[]): {
|
|
11
|
+
entries: JournalEntry[];
|
|
12
|
+
diagnostics: AccountingDiagnostic[];
|
|
13
|
+
trace: ExplanationStep[];
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { journalizeBusinessEvent, journalizeBusinessEvents };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//#region src/finance/accounting/journalize.ts
|
|
2
|
+
function accountForRole(accounts, role, eventId) {
|
|
3
|
+
const matches = accounts.filter((account) => account.role === role);
|
|
4
|
+
if (matches.length === 0) return { diagnostic: {
|
|
5
|
+
code: "missing-role",
|
|
6
|
+
severity: "error",
|
|
7
|
+
entryId: eventId,
|
|
8
|
+
message: `No account is assigned the ${role} role.`
|
|
9
|
+
} };
|
|
10
|
+
if (matches.length > 1) return { diagnostic: {
|
|
11
|
+
code: "ambiguous-role",
|
|
12
|
+
severity: "error",
|
|
13
|
+
entryId: eventId,
|
|
14
|
+
message: `More than one account is assigned the ${role} role.`
|
|
15
|
+
} };
|
|
16
|
+
return { account: matches[0] };
|
|
17
|
+
}
|
|
18
|
+
function journalizeBusinessEvent(event, accounts) {
|
|
19
|
+
const diagnostics = [];
|
|
20
|
+
const trace = [{
|
|
21
|
+
id: `${event.id}:classify`,
|
|
22
|
+
kind: "classify",
|
|
23
|
+
rule: "Classify the business event before choosing accounts.",
|
|
24
|
+
working: event.type,
|
|
25
|
+
result: event.type
|
|
26
|
+
}];
|
|
27
|
+
const required = [];
|
|
28
|
+
const specs = [];
|
|
29
|
+
const add = (role, side, amount = event.amount) => {
|
|
30
|
+
required.push(role);
|
|
31
|
+
specs.push({
|
|
32
|
+
role,
|
|
33
|
+
side,
|
|
34
|
+
amount
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
switch (event.type) {
|
|
38
|
+
case "owner-investment":
|
|
39
|
+
add("cash", "debit");
|
|
40
|
+
add("capital", "credit");
|
|
41
|
+
break;
|
|
42
|
+
case "borrow":
|
|
43
|
+
add("cash", "debit");
|
|
44
|
+
add("loan", "credit");
|
|
45
|
+
break;
|
|
46
|
+
case "buy-equipment":
|
|
47
|
+
add("equipment", "debit");
|
|
48
|
+
add(event.settlement === "cash" ? "cash" : "payable", "credit");
|
|
49
|
+
break;
|
|
50
|
+
case "buy-inventory":
|
|
51
|
+
add("inventory", "debit");
|
|
52
|
+
add(event.settlement === "cash" ? "cash" : "payable", "credit");
|
|
53
|
+
break;
|
|
54
|
+
case "sale":
|
|
55
|
+
add(event.settlement === "cash" ? "cash" : "receivable", "debit");
|
|
56
|
+
add("revenue", "credit");
|
|
57
|
+
if (event.cost != null) {
|
|
58
|
+
add("cost-of-sales", "debit", event.cost);
|
|
59
|
+
add("inventory", "credit", event.cost);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case "pay-expense":
|
|
63
|
+
add("expense", "debit");
|
|
64
|
+
add("cash", "credit");
|
|
65
|
+
break;
|
|
66
|
+
case "owner-drawings":
|
|
67
|
+
add("drawings", "debit");
|
|
68
|
+
add("cash", "credit");
|
|
69
|
+
break;
|
|
70
|
+
case "collect-receivable":
|
|
71
|
+
add("cash", "debit");
|
|
72
|
+
add("receivable", "credit");
|
|
73
|
+
break;
|
|
74
|
+
case "pay-payable":
|
|
75
|
+
add("payable", "debit");
|
|
76
|
+
add("cash", "credit");
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
80
|
+
for (const role of new Set(required)) {
|
|
81
|
+
const result = accountForRole(accounts, role, event.id);
|
|
82
|
+
if (result.diagnostic) diagnostics.push(result.diagnostic);
|
|
83
|
+
if (result.account) resolved.set(role, result.account);
|
|
84
|
+
}
|
|
85
|
+
if (diagnostics.length > 0) return {
|
|
86
|
+
diagnostics,
|
|
87
|
+
trace
|
|
88
|
+
};
|
|
89
|
+
const lines = specs.map((spec) => ({
|
|
90
|
+
accountId: resolved.get(spec.role).id,
|
|
91
|
+
side: spec.side,
|
|
92
|
+
amount: spec.amount
|
|
93
|
+
}));
|
|
94
|
+
const narration = event.narration ?? event.type.replaceAll("-", " ");
|
|
95
|
+
trace.push({
|
|
96
|
+
id: `${event.id}:journalize`,
|
|
97
|
+
kind: "journalize",
|
|
98
|
+
rule: "Every event changes at least two accounts with equal debits and credits.",
|
|
99
|
+
working: lines.map((line) => `${line.side} ${line.accountId} ${line.amount}`).join("; "),
|
|
100
|
+
result: "journal prepared"
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
entry: {
|
|
104
|
+
id: event.id,
|
|
105
|
+
narration,
|
|
106
|
+
lines
|
|
107
|
+
},
|
|
108
|
+
diagnostics,
|
|
109
|
+
trace
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function journalizeBusinessEvents(events, accounts) {
|
|
113
|
+
const entries = [], diagnostics = [], trace = [];
|
|
114
|
+
for (const event of events) {
|
|
115
|
+
const result = journalizeBusinessEvent(event, accounts);
|
|
116
|
+
if (result.entry) entries.push(result.entry);
|
|
117
|
+
diagnostics.push(...result.diagnostics);
|
|
118
|
+
trace.push(...result.trace);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
entries,
|
|
122
|
+
diagnostics,
|
|
123
|
+
trace
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { journalizeBusinessEvent, journalizeBusinessEvents };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AccountingPolicy, ManufacturingAccountFacts, ManufacturingAccountResult, ManufacturingTradingFacts, ManufacturingTradingResult } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/manufacturing.d.ts
|
|
4
|
+
declare function solveManufacturingAccount(facts: ManufacturingAccountFacts, policy?: AccountingPolicy): ManufacturingAccountResult;
|
|
5
|
+
/** Carries factory output through finished-goods inventory into cost of sales and gross profit. */
|
|
6
|
+
declare function solveManufacturingTradingFlow(facts: ManufacturingTradingFacts, policy?: AccountingPolicy): ManufacturingTradingResult;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { solveManufacturingAccount, solveManufacturingTradingFlow };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { DEFAULT_ACCOUNTING_POLICY, fromMinor, toMinor } from "./precision.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/manufacturing.ts
|
|
4
|
+
function solveManufacturingAccount(facts, policy = DEFAULT_ACCOUNTING_POLICY) {
|
|
5
|
+
const diagnostics = [];
|
|
6
|
+
for (const [name, value] of Object.entries(facts)) if (!Number.isFinite(value) || value < 0) diagnostics.push({
|
|
7
|
+
code: "invalid-adjustment",
|
|
8
|
+
severity: "error",
|
|
9
|
+
message: `${name} must be a finite non-negative amount.`
|
|
10
|
+
});
|
|
11
|
+
if (facts.closingRawMaterials > facts.openingRawMaterials + facts.purchasesOfRawMaterials) diagnostics.push({
|
|
12
|
+
code: "invalid-adjustment",
|
|
13
|
+
severity: "error",
|
|
14
|
+
message: "Closing raw materials cannot exceed all raw materials available."
|
|
15
|
+
});
|
|
16
|
+
const zero = {
|
|
17
|
+
materialsConsumed: 0,
|
|
18
|
+
primeCost: 0,
|
|
19
|
+
totalFactoryCost: 0,
|
|
20
|
+
costOfProduction: 0,
|
|
21
|
+
invertedClosingWipResult: 0,
|
|
22
|
+
inversionDifference: 0,
|
|
23
|
+
stages: [],
|
|
24
|
+
statement: [],
|
|
25
|
+
diagnostics,
|
|
26
|
+
trace: []
|
|
27
|
+
};
|
|
28
|
+
if (diagnostics.length > 0) return zero;
|
|
29
|
+
const m = (value) => toMinor(value, policy), out = (value) => fromMinor(value, policy);
|
|
30
|
+
const materialsConsumed = m(facts.openingRawMaterials) + m(facts.purchasesOfRawMaterials) - m(facts.closingRawMaterials);
|
|
31
|
+
const primeCost = materialsConsumed + m(facts.directLabour) + m(facts.directExpenses);
|
|
32
|
+
const totalFactoryCost = primeCost + m(facts.factoryOverheads);
|
|
33
|
+
const costOfProduction = totalFactoryCost + m(facts.openingWorkInProgress) - m(facts.closingWorkInProgress);
|
|
34
|
+
if (costOfProduction < 0) {
|
|
35
|
+
diagnostics.push({
|
|
36
|
+
code: "invalid-adjustment",
|
|
37
|
+
severity: "error",
|
|
38
|
+
message: "Closing work in progress cannot exceed factory cost plus opening work in progress."
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
...zero,
|
|
42
|
+
diagnostics
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const inverted = totalFactoryCost + m(facts.openingWorkInProgress) + m(facts.closingWorkInProgress);
|
|
46
|
+
const stages = [
|
|
47
|
+
{
|
|
48
|
+
key: "materials",
|
|
49
|
+
label: "Raw materials consumed",
|
|
50
|
+
amount: out(materialsConsumed),
|
|
51
|
+
direction: "in"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "labour",
|
|
55
|
+
label: "Direct labour",
|
|
56
|
+
amount: facts.directLabour,
|
|
57
|
+
direction: "in"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: "direct-expenses",
|
|
61
|
+
label: "Direct expenses",
|
|
62
|
+
amount: facts.directExpenses,
|
|
63
|
+
direction: "in",
|
|
64
|
+
reaches: "prime-cost"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "overheads",
|
|
68
|
+
label: "Factory overheads",
|
|
69
|
+
amount: facts.factoryOverheads,
|
|
70
|
+
direction: "in",
|
|
71
|
+
reaches: "total-factory-cost"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: "opening-wip",
|
|
75
|
+
label: "Opening work in progress",
|
|
76
|
+
amount: facts.openingWorkInProgress,
|
|
77
|
+
direction: "in"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
key: "closing-wip",
|
|
81
|
+
label: "Closing work in progress",
|
|
82
|
+
amount: facts.closingWorkInProgress,
|
|
83
|
+
direction: "out",
|
|
84
|
+
reaches: "cost-of-production"
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
const line = (id, label, amount, kind = "detail", treatment) => ({
|
|
88
|
+
id,
|
|
89
|
+
label,
|
|
90
|
+
amount,
|
|
91
|
+
kind,
|
|
92
|
+
...treatment ? { treatment } : {}
|
|
93
|
+
});
|
|
94
|
+
const statement = [{
|
|
95
|
+
id: "manufacturing",
|
|
96
|
+
title: "Manufacturing account",
|
|
97
|
+
lines: [
|
|
98
|
+
line("opening-materials", "Opening raw materials", facts.openingRawMaterials, "detail", "add"),
|
|
99
|
+
line("purchases-materials", "Purchases of raw materials", facts.purchasesOfRawMaterials, "detail", "add"),
|
|
100
|
+
line("closing-materials", "Closing raw materials", facts.closingRawMaterials, "detail", "subtract"),
|
|
101
|
+
line("materials-consumed", "Raw materials consumed", out(materialsConsumed), "subtotal", "result"),
|
|
102
|
+
line("direct-labour", "Direct labour", facts.directLabour, "detail", "add"),
|
|
103
|
+
line("direct-expenses", "Direct expenses", facts.directExpenses, "detail", "add"),
|
|
104
|
+
line("prime-cost", "Prime cost", out(primeCost), "subtotal", "result"),
|
|
105
|
+
line("factory-overheads", "Factory overheads", facts.factoryOverheads, "detail", "add"),
|
|
106
|
+
line("factory-cost", "Total factory cost", out(totalFactoryCost), "subtotal", "result"),
|
|
107
|
+
line("opening-wip", "Opening work in progress", facts.openingWorkInProgress, "detail", "add"),
|
|
108
|
+
line("closing-wip", "Closing work in progress", facts.closingWorkInProgress, "detail", "subtract"),
|
|
109
|
+
line("cost-of-production", "Cost of production", out(costOfProduction), "total", "result")
|
|
110
|
+
]
|
|
111
|
+
}];
|
|
112
|
+
return {
|
|
113
|
+
materialsConsumed: out(materialsConsumed),
|
|
114
|
+
primeCost: out(primeCost),
|
|
115
|
+
totalFactoryCost: out(totalFactoryCost),
|
|
116
|
+
costOfProduction: out(costOfProduction),
|
|
117
|
+
invertedClosingWipResult: out(inverted),
|
|
118
|
+
inversionDifference: out(inverted - costOfProduction),
|
|
119
|
+
stages,
|
|
120
|
+
statement,
|
|
121
|
+
diagnostics,
|
|
122
|
+
trace: [
|
|
123
|
+
{
|
|
124
|
+
id: "manufacturing:materials",
|
|
125
|
+
kind: "derive",
|
|
126
|
+
rule: "Raw materials consumed = opening inventory + purchases − closing inventory.",
|
|
127
|
+
working: `${facts.openingRawMaterials} + ${facts.purchasesOfRawMaterials} − ${facts.closingRawMaterials}`,
|
|
128
|
+
result: out(materialsConsumed)
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "manufacturing:prime",
|
|
132
|
+
kind: "derive",
|
|
133
|
+
rule: "Prime cost contains direct materials, direct labour and direct expenses.",
|
|
134
|
+
working: `${out(materialsConsumed)} + ${facts.directLabour} + ${facts.directExpenses}`,
|
|
135
|
+
result: out(primeCost)
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "manufacturing:factory",
|
|
139
|
+
kind: "derive",
|
|
140
|
+
rule: "Total factory cost = prime cost + factory overheads.",
|
|
141
|
+
working: `${out(primeCost)} + ${facts.factoryOverheads}`,
|
|
142
|
+
result: out(totalFactoryCost)
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "manufacturing:production",
|
|
146
|
+
kind: "derive",
|
|
147
|
+
rule: "Cost of production = factory cost + opening work in progress − closing work in progress.",
|
|
148
|
+
working: `${out(totalFactoryCost)} + ${facts.openingWorkInProgress} − ${facts.closingWorkInProgress}`,
|
|
149
|
+
result: out(costOfProduction)
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "manufacturing:sign-check",
|
|
153
|
+
kind: "check",
|
|
154
|
+
rule: "Adding instead of deducting closing work in progress overstates production by twice that closing amount.",
|
|
155
|
+
working: `${out(inverted)} − ${out(costOfProduction)}`,
|
|
156
|
+
result: out(inverted - costOfProduction)
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** Carries factory output through finished-goods inventory into cost of sales and gross profit. */
|
|
162
|
+
function solveManufacturingTradingFlow(facts, policy = DEFAULT_ACCOUNTING_POLICY) {
|
|
163
|
+
const manufacturing = solveManufacturingAccount(facts, policy);
|
|
164
|
+
const diagnostics = [...manufacturing.diagnostics];
|
|
165
|
+
for (const name of [
|
|
166
|
+
"openingFinishedGoods",
|
|
167
|
+
"closingFinishedGoods",
|
|
168
|
+
"revenue"
|
|
169
|
+
]) {
|
|
170
|
+
const value = facts[name];
|
|
171
|
+
if (!Number.isFinite(value) || value < 0) diagnostics.push({
|
|
172
|
+
code: "invalid-adjustment",
|
|
173
|
+
severity: "error",
|
|
174
|
+
message: `${name} must be a finite non-negative amount.`
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const zero = {
|
|
178
|
+
manufacturing,
|
|
179
|
+
goodsAvailableForSale: 0,
|
|
180
|
+
costOfSales: 0,
|
|
181
|
+
grossProfit: 0,
|
|
182
|
+
diagnostics,
|
|
183
|
+
trace: manufacturing.trace
|
|
184
|
+
};
|
|
185
|
+
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) return zero;
|
|
186
|
+
const m = (value) => toMinor(value, policy);
|
|
187
|
+
const out = (value) => fromMinor(value, policy);
|
|
188
|
+
const goodsAvailableForSale = m(facts.openingFinishedGoods) + m(manufacturing.costOfProduction);
|
|
189
|
+
if (m(facts.closingFinishedGoods) > goodsAvailableForSale) {
|
|
190
|
+
diagnostics.push({
|
|
191
|
+
code: "invalid-adjustment",
|
|
192
|
+
severity: "error",
|
|
193
|
+
message: "Closing finished goods cannot exceed goods available for sale."
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
...zero,
|
|
197
|
+
diagnostics
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const costOfSales = goodsAvailableForSale - m(facts.closingFinishedGoods);
|
|
201
|
+
const grossProfit = m(facts.revenue) - costOfSales;
|
|
202
|
+
return {
|
|
203
|
+
manufacturing,
|
|
204
|
+
goodsAvailableForSale: out(goodsAvailableForSale),
|
|
205
|
+
costOfSales: out(costOfSales),
|
|
206
|
+
grossProfit: out(grossProfit),
|
|
207
|
+
diagnostics,
|
|
208
|
+
trace: [
|
|
209
|
+
...manufacturing.trace,
|
|
210
|
+
{
|
|
211
|
+
id: "manufacturing:available-for-sale",
|
|
212
|
+
kind: "derive",
|
|
213
|
+
rule: "Goods available for sale = opening finished goods + cost of production.",
|
|
214
|
+
working: `${facts.openingFinishedGoods} + ${manufacturing.costOfProduction}`,
|
|
215
|
+
result: out(goodsAvailableForSale)
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: "manufacturing:cost-of-sales",
|
|
219
|
+
kind: "derive",
|
|
220
|
+
rule: "Cost of sales = goods available for sale − closing finished goods.",
|
|
221
|
+
working: `${out(goodsAvailableForSale)} − ${facts.closingFinishedGoods}`,
|
|
222
|
+
result: out(costOfSales)
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: "manufacturing:gross-profit",
|
|
226
|
+
kind: "derive",
|
|
227
|
+
rule: "Gross profit = revenue − cost of sales.",
|
|
228
|
+
working: `${facts.revenue} − ${out(costOfSales)}`,
|
|
229
|
+
result: out(grossProfit)
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
export { solveManufacturingAccount, solveManufacturingTradingFlow };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccountingPolicy, PartnerFacts, PartnershipAgreement, PartnershipResult } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/finance/accounting/partnership.d.ts
|
|
4
|
+
declare function solvePartnershipAppropriation(agreement: PartnershipAgreement, partners: readonly PartnerFacts[], policy?: AccountingPolicy): PartnershipResult;
|
|
5
|
+
declare function salaryForEqualPartnershipShares(agreement: PartnershipAgreement, partners: readonly PartnerFacts[], policy?: AccountingPolicy): number | null;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { salaryForEqualPartnershipShares, solvePartnershipAppropriation };
|