@superheld/summae-core 0.1.0 → 0.2.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/README.md +1 -1
- package/dist/index.cjs +93 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +93 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ const susa = ops.project('trialBalance', { fiscalYear: 2026, throughPeriod: 12 }
|
|
|
20
20
|
|
|
21
21
|
**📖 Vollständige Dokumentation** — Installation, Initialisierung, komplette
|
|
22
22
|
API-Referenz (alle Operationen & Projektionen), Value Objects, Fehlerkatalog:
|
|
23
|
-
**[summae-Handbuch](
|
|
23
|
+
**[summae-Handbuch](https://github.com/Superheld/summae/blob/main/docs/handbuch/README.md)**.
|
|
24
24
|
|
|
25
25
|
> Build aus dem Repo: `pnpm build` (tsup → `dist/`). Im Workspace zeigen die
|
|
26
26
|
> `exports` auf die TS-Source (vitest/tsx ohne Build); beim Publish überschreibt
|
package/dist/index.cjs
CHANGED
|
@@ -825,6 +825,13 @@ var FiscalYear = class _FiscalYear {
|
|
|
825
825
|
const periods = explicitPeriods === null ? _FiscalYear.monthlyPeriods(start, end) : explicitPeriods.map((d) => new Period(d.period, d.start, d.end));
|
|
826
826
|
return new _FiscalYear(id, year, start, end, periods);
|
|
827
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Aus Persistenz wiederherstellen: Status und Perioden explizit übernehmen
|
|
830
|
+
* (kein Neuaufbau, keine Validierung) — Pendant zu PHPs `FiscalYear::restore`.
|
|
831
|
+
*/
|
|
832
|
+
static restore(id, year, start, end, status, periods) {
|
|
833
|
+
return new _FiscalYear(id, year, start, end, periods, status);
|
|
834
|
+
}
|
|
828
835
|
static monthlyPeriods(start, end) {
|
|
829
836
|
const periods = [];
|
|
830
837
|
let cursor = start;
|
|
@@ -948,7 +955,7 @@ var AuditRecord = class {
|
|
|
948
955
|
};
|
|
949
956
|
|
|
950
957
|
// src/ledger/open-item.ts
|
|
951
|
-
var OpenItem = class {
|
|
958
|
+
var OpenItem = class _OpenItem {
|
|
952
959
|
constructor(id, kind, originEntryId, originLineIndex, money, voucherId, openedAt, partnerId = null) {
|
|
953
960
|
this.id = id;
|
|
954
961
|
this.kind = kind;
|
|
@@ -968,6 +975,15 @@ var OpenItem = class {
|
|
|
968
975
|
openedAt;
|
|
969
976
|
partnerId;
|
|
970
977
|
settlementList = [];
|
|
978
|
+
/**
|
|
979
|
+
* Aus Persistenz wiederherstellen: bereits validierte Ausgleiche direkt setzen
|
|
980
|
+
* (keine erneute Prüfung) — Pendant zu PHPs `OpenItem::restore`.
|
|
981
|
+
*/
|
|
982
|
+
static restore(id, kind, originEntryId, originLineIndex, money, voucherId, openedAt, partnerId, settlements) {
|
|
983
|
+
const item = new _OpenItem(id, kind, originEntryId, originLineIndex, money, voucherId, openedAt, partnerId);
|
|
984
|
+
item.settlementList.push(...settlements);
|
|
985
|
+
return item;
|
|
986
|
+
}
|
|
971
987
|
settlements() {
|
|
972
988
|
return this.settlementList;
|
|
973
989
|
}
|
|
@@ -1840,7 +1856,7 @@ function lastDayOfMonthAfter(base, monthsToAdd) {
|
|
|
1840
1856
|
`${String(year).padStart(4, "0")}-${String(month0 + 1).padStart(2, "0")}-${String(lastDay).padStart(2, "0")}`
|
|
1841
1857
|
);
|
|
1842
1858
|
}
|
|
1843
|
-
var Asset = class {
|
|
1859
|
+
var Asset = class _Asset {
|
|
1844
1860
|
constructor(id, name, assetClass, assetAccount, acquisitionCost, acquiredOn, route, usefulLifeMonths, monthlySchedule, voucherId) {
|
|
1845
1861
|
this.id = id;
|
|
1846
1862
|
this.name = name;
|
|
@@ -1892,6 +1908,44 @@ var Asset = class {
|
|
|
1892
1908
|
recordDepreciation(planMonth, date, amount, entryId) {
|
|
1893
1909
|
this.depreciations.push({ planMonth, date, amount, entryId });
|
|
1894
1910
|
}
|
|
1911
|
+
/** AfA-Lebenslauf in persistierbarer Form — Pendant zu PHPs `depreciationsForPersistence`. */
|
|
1912
|
+
depreciationsForPersistence() {
|
|
1913
|
+
return this.depreciations.map((booking) => ({
|
|
1914
|
+
planMonth: booking.planMonth,
|
|
1915
|
+
date: booking.date.iso,
|
|
1916
|
+
amount: booking.amount.toJSON(),
|
|
1917
|
+
entryId: booking.entryId.value
|
|
1918
|
+
}));
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Aus Persistenz wiederherstellen: Stammdaten + AfA-Lebenslauf + Abgangsstatus
|
|
1922
|
+
* direkt setzen (keine erneute Prüfung) — Pendant zu PHPs `Asset::restore`.
|
|
1923
|
+
*/
|
|
1924
|
+
static restore(id, name, assetClass, assetAccount, acquisitionCost, acquiredOn, route, usefulLifeMonths, monthlySchedule, voucherId, depreciations, disposed, disposedOn) {
|
|
1925
|
+
const asset = new _Asset(
|
|
1926
|
+
id,
|
|
1927
|
+
name,
|
|
1928
|
+
assetClass,
|
|
1929
|
+
assetAccount,
|
|
1930
|
+
acquisitionCost,
|
|
1931
|
+
acquiredOn,
|
|
1932
|
+
route,
|
|
1933
|
+
usefulLifeMonths,
|
|
1934
|
+
monthlySchedule,
|
|
1935
|
+
voucherId
|
|
1936
|
+
);
|
|
1937
|
+
for (const booking of depreciations) {
|
|
1938
|
+
asset.depreciations.push({
|
|
1939
|
+
planMonth: booking.planMonth,
|
|
1940
|
+
date: booking.date,
|
|
1941
|
+
amount: booking.amount,
|
|
1942
|
+
entryId: booking.entryId
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
asset.disposed = disposed;
|
|
1946
|
+
asset.disposedOn = disposedOn;
|
|
1947
|
+
return asset;
|
|
1948
|
+
}
|
|
1895
1949
|
accumulatedDepreciationAt(asOf) {
|
|
1896
1950
|
let sum = this.acquisitionCost.subtract(this.acquisitionCost);
|
|
1897
1951
|
for (const booking of this.depreciations) {
|
|
@@ -3954,14 +4008,37 @@ var Tenant = class _Tenant {
|
|
|
3954
4008
|
ids;
|
|
3955
4009
|
static inMemory(name, baseCurrency, clock = new SystemClock(), ids, dimensions = DimensionRegistry.empty(), taxCodes = TaxCodeRegistry.empty(), taxProfile = TaxProfile.default(), mappings = MappingRegistry.empty()) {
|
|
3956
4010
|
const idGen = ids ?? new UuidV7IdGenerator(clock);
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
4011
|
+
return _Tenant.fromPorts(
|
|
4012
|
+
idGen.next(),
|
|
4013
|
+
// Mandanten-ID = erste generierte ID (Determinismus)
|
|
4014
|
+
name,
|
|
4015
|
+
baseCurrency,
|
|
4016
|
+
{
|
|
4017
|
+
accounts: new InMemoryAccountRepository(),
|
|
4018
|
+
fiscalYears: new InMemoryFiscalYearRepository(),
|
|
4019
|
+
vouchers: new InMemoryVoucherRepository(),
|
|
4020
|
+
journal: new InMemoryJournalRepository(),
|
|
4021
|
+
openItems: new InMemoryOpenItemRepository(),
|
|
4022
|
+
assets: new InMemoryAssetRepository(),
|
|
4023
|
+
partners: new InMemoryPartnerRepository(),
|
|
4024
|
+
audit: new InMemoryAuditTrail()
|
|
4025
|
+
},
|
|
4026
|
+
clock,
|
|
4027
|
+
idGen,
|
|
4028
|
+
dimensions,
|
|
4029
|
+
taxCodes,
|
|
4030
|
+
taxProfile,
|
|
4031
|
+
mappings
|
|
4032
|
+
);
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* Mandant aus beliebigen Ports bauen (Service-Verdrahtung bleibt hier im Kern).
|
|
4036
|
+
* `inMemory` nutzt das mit In-Memory-Ports; der Persistenz-Adapter
|
|
4037
|
+
* (`@superheld/summae-knex`) reicht DB-gestützte Ports herein — derselbe
|
|
4038
|
+
* `Tenant`, nur andere Ports.
|
|
4039
|
+
*/
|
|
4040
|
+
static fromPorts(tenantId, name, baseCurrency, ports, clock, ids, dimensions = DimensionRegistry.empty(), taxCodes = TaxCodeRegistry.empty(), taxProfile = TaxProfile.default(), mappings = MappingRegistry.empty()) {
|
|
4041
|
+
const { accounts, fiscalYears, vouchers, journal, openItems, assets, partners, audit } = ports;
|
|
3965
4042
|
const ledger = new Ledger(
|
|
3966
4043
|
baseCurrency,
|
|
3967
4044
|
accounts,
|
|
@@ -3972,14 +4049,14 @@ var Tenant = class _Tenant {
|
|
|
3972
4049
|
audit,
|
|
3973
4050
|
dimensions,
|
|
3974
4051
|
clock,
|
|
3975
|
-
|
|
4052
|
+
ids
|
|
3976
4053
|
);
|
|
3977
4054
|
const tax = new TaxService(baseCurrency, taxCodes, taxProfile, journal);
|
|
3978
|
-
const assetService = new AssetService(baseCurrency, assets, fiscalYears, vouchers, ledger,
|
|
3979
|
-
const costing = new CostingService(baseCurrency, accounts, journal,
|
|
3980
|
-
const partnerService = new PartnerService(partners, audit, clock,
|
|
4055
|
+
const assetService = new AssetService(baseCurrency, assets, fiscalYears, vouchers, ledger, ids);
|
|
4056
|
+
const costing = new CostingService(baseCurrency, accounts, journal, ids);
|
|
4057
|
+
const partnerService = new PartnerService(partners, audit, clock, ids);
|
|
3981
4058
|
return new _Tenant(
|
|
3982
|
-
|
|
4059
|
+
tenantId,
|
|
3983
4060
|
name,
|
|
3984
4061
|
baseCurrency,
|
|
3985
4062
|
accounts,
|
|
@@ -3997,7 +4074,7 @@ var Tenant = class _Tenant {
|
|
|
3997
4074
|
partnerService,
|
|
3998
4075
|
mappings,
|
|
3999
4076
|
clock,
|
|
4000
|
-
|
|
4077
|
+
ids
|
|
4001
4078
|
);
|
|
4002
4079
|
}
|
|
4003
4080
|
};
|