@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/dist/index.d.cts
CHANGED
|
@@ -383,6 +383,11 @@ declare class FiscalYear {
|
|
|
383
383
|
private fiscalStatus;
|
|
384
384
|
private constructor();
|
|
385
385
|
static create(id: Uuid, year: number, start: CalendarDate, end: CalendarDate, explicitPeriods?: PeriodDefinition[] | null): FiscalYear;
|
|
386
|
+
/**
|
|
387
|
+
* Aus Persistenz wiederherstellen: Status und Perioden explizit übernehmen
|
|
388
|
+
* (kein Neuaufbau, keine Validierung) — Pendant zu PHPs `FiscalYear::restore`.
|
|
389
|
+
*/
|
|
390
|
+
static restore(id: Uuid, year: number, start: CalendarDate, end: CalendarDate, status: FiscalYearStatus, periods: Period[]): FiscalYear;
|
|
386
391
|
private static monthlyPeriods;
|
|
387
392
|
status(): FiscalYearStatus;
|
|
388
393
|
isClosed(): boolean;
|
|
@@ -447,6 +452,11 @@ declare class OpenItem {
|
|
|
447
452
|
readonly partnerId: Uuid | null;
|
|
448
453
|
private readonly settlementList;
|
|
449
454
|
constructor(id: Uuid, kind: OpenItemKind, originEntryId: Uuid, originLineIndex: number, money: Money, voucherId: Uuid, openedAt: CalendarDate, partnerId?: Uuid | null);
|
|
455
|
+
/**
|
|
456
|
+
* Aus Persistenz wiederherstellen: bereits validierte Ausgleiche direkt setzen
|
|
457
|
+
* (keine erneute Prüfung) — Pendant zu PHPs `OpenItem::restore`.
|
|
458
|
+
*/
|
|
459
|
+
static restore(id: Uuid, kind: OpenItemKind, originEntryId: Uuid, originLineIndex: number, money: Money, voucherId: Uuid, openedAt: CalendarDate, partnerId: Uuid | null, settlements: Settlement[]): OpenItem;
|
|
450
460
|
settlements(): Settlement[];
|
|
451
461
|
remaining(): Money;
|
|
452
462
|
/** Restbetrag zum Stichtag (null = heute/alles). */
|
|
@@ -525,6 +535,26 @@ declare class Asset {
|
|
|
525
535
|
planMonthDate(planMonth: number): CalendarDate;
|
|
526
536
|
isMonthBooked(planMonth: number): boolean;
|
|
527
537
|
recordDepreciation(planMonth: number, date: CalendarDate, amount: Money, entryId: Uuid): void;
|
|
538
|
+
/** AfA-Lebenslauf in persistierbarer Form — Pendant zu PHPs `depreciationsForPersistence`. */
|
|
539
|
+
depreciationsForPersistence(): Array<{
|
|
540
|
+
planMonth: number;
|
|
541
|
+
date: string;
|
|
542
|
+
amount: {
|
|
543
|
+
amount: string;
|
|
544
|
+
currency: string;
|
|
545
|
+
};
|
|
546
|
+
entryId: string;
|
|
547
|
+
}>;
|
|
548
|
+
/**
|
|
549
|
+
* Aus Persistenz wiederherstellen: Stammdaten + AfA-Lebenslauf + Abgangsstatus
|
|
550
|
+
* direkt setzen (keine erneute Prüfung) — Pendant zu PHPs `Asset::restore`.
|
|
551
|
+
*/
|
|
552
|
+
static restore(id: Uuid, name: string, assetClass: string, assetAccount: AccountNumber, acquisitionCost: Money, acquiredOn: CalendarDate, route: AssetRoute, usefulLifeMonths: number | null, monthlySchedule: Money[], voucherId: Uuid, depreciations: ReadonlyArray<{
|
|
553
|
+
planMonth: number;
|
|
554
|
+
date: CalendarDate;
|
|
555
|
+
amount: Money;
|
|
556
|
+
entryId: Uuid;
|
|
557
|
+
}>, disposed: boolean, disposedOn: CalendarDate | null): Asset;
|
|
528
558
|
accumulatedDepreciationAt(asOf: CalendarDate | null): Money;
|
|
529
559
|
bookValueAt(asOf: CalendarDate | null): Money;
|
|
530
560
|
scheduleSummary(): Record<string, string>;
|
|
@@ -1208,6 +1238,22 @@ declare class Tenant {
|
|
|
1208
1238
|
readonly ids: IdGenerator;
|
|
1209
1239
|
constructor(id: Uuid, name: string, baseCurrency: Currency, accounts: AccountRepository, fiscalYears: FiscalYearRepository, vouchers: VoucherRepository, journal: JournalRepository, openItems: OpenItemRepository, assets: AssetRepository, partners: PartnerRepository, audit: AuditTrail, ledger: Ledger, tax: TaxService, assetService: AssetService, costing: CostingService, partnerService: PartnerService, mappings: MappingRegistry, clock: Clock, ids: IdGenerator);
|
|
1210
1240
|
static inMemory(name: string, baseCurrency: Currency, clock?: Clock, ids?: IdGenerator, dimensions?: DimensionRegistry, taxCodes?: TaxCodeRegistry, taxProfile?: TaxProfile, mappings?: MappingRegistry): Tenant;
|
|
1241
|
+
/**
|
|
1242
|
+
* Mandant aus beliebigen Ports bauen (Service-Verdrahtung bleibt hier im Kern).
|
|
1243
|
+
* `inMemory` nutzt das mit In-Memory-Ports; der Persistenz-Adapter
|
|
1244
|
+
* (`@superheld/summae-knex`) reicht DB-gestützte Ports herein — derselbe
|
|
1245
|
+
* `Tenant`, nur andere Ports.
|
|
1246
|
+
*/
|
|
1247
|
+
static fromPorts(tenantId: Uuid, name: string, baseCurrency: Currency, ports: {
|
|
1248
|
+
accounts: AccountRepository;
|
|
1249
|
+
fiscalYears: FiscalYearRepository;
|
|
1250
|
+
vouchers: VoucherRepository;
|
|
1251
|
+
journal: JournalRepository;
|
|
1252
|
+
openItems: OpenItemRepository;
|
|
1253
|
+
assets: AssetRepository;
|
|
1254
|
+
partners: PartnerRepository;
|
|
1255
|
+
audit: AuditTrail;
|
|
1256
|
+
}, clock: Clock, ids: IdGenerator, dimensions?: DimensionRegistry, taxCodes?: TaxCodeRegistry, taxProfile?: TaxProfile, mappings?: MappingRegistry): Tenant;
|
|
1211
1257
|
}
|
|
1212
1258
|
|
|
1213
1259
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -383,6 +383,11 @@ declare class FiscalYear {
|
|
|
383
383
|
private fiscalStatus;
|
|
384
384
|
private constructor();
|
|
385
385
|
static create(id: Uuid, year: number, start: CalendarDate, end: CalendarDate, explicitPeriods?: PeriodDefinition[] | null): FiscalYear;
|
|
386
|
+
/**
|
|
387
|
+
* Aus Persistenz wiederherstellen: Status und Perioden explizit übernehmen
|
|
388
|
+
* (kein Neuaufbau, keine Validierung) — Pendant zu PHPs `FiscalYear::restore`.
|
|
389
|
+
*/
|
|
390
|
+
static restore(id: Uuid, year: number, start: CalendarDate, end: CalendarDate, status: FiscalYearStatus, periods: Period[]): FiscalYear;
|
|
386
391
|
private static monthlyPeriods;
|
|
387
392
|
status(): FiscalYearStatus;
|
|
388
393
|
isClosed(): boolean;
|
|
@@ -447,6 +452,11 @@ declare class OpenItem {
|
|
|
447
452
|
readonly partnerId: Uuid | null;
|
|
448
453
|
private readonly settlementList;
|
|
449
454
|
constructor(id: Uuid, kind: OpenItemKind, originEntryId: Uuid, originLineIndex: number, money: Money, voucherId: Uuid, openedAt: CalendarDate, partnerId?: Uuid | null);
|
|
455
|
+
/**
|
|
456
|
+
* Aus Persistenz wiederherstellen: bereits validierte Ausgleiche direkt setzen
|
|
457
|
+
* (keine erneute Prüfung) — Pendant zu PHPs `OpenItem::restore`.
|
|
458
|
+
*/
|
|
459
|
+
static restore(id: Uuid, kind: OpenItemKind, originEntryId: Uuid, originLineIndex: number, money: Money, voucherId: Uuid, openedAt: CalendarDate, partnerId: Uuid | null, settlements: Settlement[]): OpenItem;
|
|
450
460
|
settlements(): Settlement[];
|
|
451
461
|
remaining(): Money;
|
|
452
462
|
/** Restbetrag zum Stichtag (null = heute/alles). */
|
|
@@ -525,6 +535,26 @@ declare class Asset {
|
|
|
525
535
|
planMonthDate(planMonth: number): CalendarDate;
|
|
526
536
|
isMonthBooked(planMonth: number): boolean;
|
|
527
537
|
recordDepreciation(planMonth: number, date: CalendarDate, amount: Money, entryId: Uuid): void;
|
|
538
|
+
/** AfA-Lebenslauf in persistierbarer Form — Pendant zu PHPs `depreciationsForPersistence`. */
|
|
539
|
+
depreciationsForPersistence(): Array<{
|
|
540
|
+
planMonth: number;
|
|
541
|
+
date: string;
|
|
542
|
+
amount: {
|
|
543
|
+
amount: string;
|
|
544
|
+
currency: string;
|
|
545
|
+
};
|
|
546
|
+
entryId: string;
|
|
547
|
+
}>;
|
|
548
|
+
/**
|
|
549
|
+
* Aus Persistenz wiederherstellen: Stammdaten + AfA-Lebenslauf + Abgangsstatus
|
|
550
|
+
* direkt setzen (keine erneute Prüfung) — Pendant zu PHPs `Asset::restore`.
|
|
551
|
+
*/
|
|
552
|
+
static restore(id: Uuid, name: string, assetClass: string, assetAccount: AccountNumber, acquisitionCost: Money, acquiredOn: CalendarDate, route: AssetRoute, usefulLifeMonths: number | null, monthlySchedule: Money[], voucherId: Uuid, depreciations: ReadonlyArray<{
|
|
553
|
+
planMonth: number;
|
|
554
|
+
date: CalendarDate;
|
|
555
|
+
amount: Money;
|
|
556
|
+
entryId: Uuid;
|
|
557
|
+
}>, disposed: boolean, disposedOn: CalendarDate | null): Asset;
|
|
528
558
|
accumulatedDepreciationAt(asOf: CalendarDate | null): Money;
|
|
529
559
|
bookValueAt(asOf: CalendarDate | null): Money;
|
|
530
560
|
scheduleSummary(): Record<string, string>;
|
|
@@ -1208,6 +1238,22 @@ declare class Tenant {
|
|
|
1208
1238
|
readonly ids: IdGenerator;
|
|
1209
1239
|
constructor(id: Uuid, name: string, baseCurrency: Currency, accounts: AccountRepository, fiscalYears: FiscalYearRepository, vouchers: VoucherRepository, journal: JournalRepository, openItems: OpenItemRepository, assets: AssetRepository, partners: PartnerRepository, audit: AuditTrail, ledger: Ledger, tax: TaxService, assetService: AssetService, costing: CostingService, partnerService: PartnerService, mappings: MappingRegistry, clock: Clock, ids: IdGenerator);
|
|
1210
1240
|
static inMemory(name: string, baseCurrency: Currency, clock?: Clock, ids?: IdGenerator, dimensions?: DimensionRegistry, taxCodes?: TaxCodeRegistry, taxProfile?: TaxProfile, mappings?: MappingRegistry): Tenant;
|
|
1241
|
+
/**
|
|
1242
|
+
* Mandant aus beliebigen Ports bauen (Service-Verdrahtung bleibt hier im Kern).
|
|
1243
|
+
* `inMemory` nutzt das mit In-Memory-Ports; der Persistenz-Adapter
|
|
1244
|
+
* (`@superheld/summae-knex`) reicht DB-gestützte Ports herein — derselbe
|
|
1245
|
+
* `Tenant`, nur andere Ports.
|
|
1246
|
+
*/
|
|
1247
|
+
static fromPorts(tenantId: Uuid, name: string, baseCurrency: Currency, ports: {
|
|
1248
|
+
accounts: AccountRepository;
|
|
1249
|
+
fiscalYears: FiscalYearRepository;
|
|
1250
|
+
vouchers: VoucherRepository;
|
|
1251
|
+
journal: JournalRepository;
|
|
1252
|
+
openItems: OpenItemRepository;
|
|
1253
|
+
assets: AssetRepository;
|
|
1254
|
+
partners: PartnerRepository;
|
|
1255
|
+
audit: AuditTrail;
|
|
1256
|
+
}, clock: Clock, ids: IdGenerator, dimensions?: DimensionRegistry, taxCodes?: TaxCodeRegistry, taxProfile?: TaxProfile, mappings?: MappingRegistry): Tenant;
|
|
1211
1257
|
}
|
|
1212
1258
|
|
|
1213
1259
|
/**
|
package/dist/index.js
CHANGED
|
@@ -819,6 +819,13 @@ var FiscalYear = class _FiscalYear {
|
|
|
819
819
|
const periods = explicitPeriods === null ? _FiscalYear.monthlyPeriods(start, end) : explicitPeriods.map((d) => new Period(d.period, d.start, d.end));
|
|
820
820
|
return new _FiscalYear(id, year, start, end, periods);
|
|
821
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* Aus Persistenz wiederherstellen: Status und Perioden explizit übernehmen
|
|
824
|
+
* (kein Neuaufbau, keine Validierung) — Pendant zu PHPs `FiscalYear::restore`.
|
|
825
|
+
*/
|
|
826
|
+
static restore(id, year, start, end, status, periods) {
|
|
827
|
+
return new _FiscalYear(id, year, start, end, periods, status);
|
|
828
|
+
}
|
|
822
829
|
static monthlyPeriods(start, end) {
|
|
823
830
|
const periods = [];
|
|
824
831
|
let cursor = start;
|
|
@@ -942,7 +949,7 @@ var AuditRecord = class {
|
|
|
942
949
|
};
|
|
943
950
|
|
|
944
951
|
// src/ledger/open-item.ts
|
|
945
|
-
var OpenItem = class {
|
|
952
|
+
var OpenItem = class _OpenItem {
|
|
946
953
|
constructor(id, kind, originEntryId, originLineIndex, money, voucherId, openedAt, partnerId = null) {
|
|
947
954
|
this.id = id;
|
|
948
955
|
this.kind = kind;
|
|
@@ -962,6 +969,15 @@ var OpenItem = class {
|
|
|
962
969
|
openedAt;
|
|
963
970
|
partnerId;
|
|
964
971
|
settlementList = [];
|
|
972
|
+
/**
|
|
973
|
+
* Aus Persistenz wiederherstellen: bereits validierte Ausgleiche direkt setzen
|
|
974
|
+
* (keine erneute Prüfung) — Pendant zu PHPs `OpenItem::restore`.
|
|
975
|
+
*/
|
|
976
|
+
static restore(id, kind, originEntryId, originLineIndex, money, voucherId, openedAt, partnerId, settlements) {
|
|
977
|
+
const item = new _OpenItem(id, kind, originEntryId, originLineIndex, money, voucherId, openedAt, partnerId);
|
|
978
|
+
item.settlementList.push(...settlements);
|
|
979
|
+
return item;
|
|
980
|
+
}
|
|
965
981
|
settlements() {
|
|
966
982
|
return this.settlementList;
|
|
967
983
|
}
|
|
@@ -1834,7 +1850,7 @@ function lastDayOfMonthAfter(base, monthsToAdd) {
|
|
|
1834
1850
|
`${String(year).padStart(4, "0")}-${String(month0 + 1).padStart(2, "0")}-${String(lastDay).padStart(2, "0")}`
|
|
1835
1851
|
);
|
|
1836
1852
|
}
|
|
1837
|
-
var Asset = class {
|
|
1853
|
+
var Asset = class _Asset {
|
|
1838
1854
|
constructor(id, name, assetClass, assetAccount, acquisitionCost, acquiredOn, route, usefulLifeMonths, monthlySchedule, voucherId) {
|
|
1839
1855
|
this.id = id;
|
|
1840
1856
|
this.name = name;
|
|
@@ -1886,6 +1902,44 @@ var Asset = class {
|
|
|
1886
1902
|
recordDepreciation(planMonth, date, amount, entryId) {
|
|
1887
1903
|
this.depreciations.push({ planMonth, date, amount, entryId });
|
|
1888
1904
|
}
|
|
1905
|
+
/** AfA-Lebenslauf in persistierbarer Form — Pendant zu PHPs `depreciationsForPersistence`. */
|
|
1906
|
+
depreciationsForPersistence() {
|
|
1907
|
+
return this.depreciations.map((booking) => ({
|
|
1908
|
+
planMonth: booking.planMonth,
|
|
1909
|
+
date: booking.date.iso,
|
|
1910
|
+
amount: booking.amount.toJSON(),
|
|
1911
|
+
entryId: booking.entryId.value
|
|
1912
|
+
}));
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Aus Persistenz wiederherstellen: Stammdaten + AfA-Lebenslauf + Abgangsstatus
|
|
1916
|
+
* direkt setzen (keine erneute Prüfung) — Pendant zu PHPs `Asset::restore`.
|
|
1917
|
+
*/
|
|
1918
|
+
static restore(id, name, assetClass, assetAccount, acquisitionCost, acquiredOn, route, usefulLifeMonths, monthlySchedule, voucherId, depreciations, disposed, disposedOn) {
|
|
1919
|
+
const asset = new _Asset(
|
|
1920
|
+
id,
|
|
1921
|
+
name,
|
|
1922
|
+
assetClass,
|
|
1923
|
+
assetAccount,
|
|
1924
|
+
acquisitionCost,
|
|
1925
|
+
acquiredOn,
|
|
1926
|
+
route,
|
|
1927
|
+
usefulLifeMonths,
|
|
1928
|
+
monthlySchedule,
|
|
1929
|
+
voucherId
|
|
1930
|
+
);
|
|
1931
|
+
for (const booking of depreciations) {
|
|
1932
|
+
asset.depreciations.push({
|
|
1933
|
+
planMonth: booking.planMonth,
|
|
1934
|
+
date: booking.date,
|
|
1935
|
+
amount: booking.amount,
|
|
1936
|
+
entryId: booking.entryId
|
|
1937
|
+
});
|
|
1938
|
+
}
|
|
1939
|
+
asset.disposed = disposed;
|
|
1940
|
+
asset.disposedOn = disposedOn;
|
|
1941
|
+
return asset;
|
|
1942
|
+
}
|
|
1889
1943
|
accumulatedDepreciationAt(asOf) {
|
|
1890
1944
|
let sum = this.acquisitionCost.subtract(this.acquisitionCost);
|
|
1891
1945
|
for (const booking of this.depreciations) {
|
|
@@ -3948,14 +4002,37 @@ var Tenant = class _Tenant {
|
|
|
3948
4002
|
ids;
|
|
3949
4003
|
static inMemory(name, baseCurrency, clock = new SystemClock(), ids, dimensions = DimensionRegistry.empty(), taxCodes = TaxCodeRegistry.empty(), taxProfile = TaxProfile.default(), mappings = MappingRegistry.empty()) {
|
|
3950
4004
|
const idGen = ids ?? new UuidV7IdGenerator(clock);
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
4005
|
+
return _Tenant.fromPorts(
|
|
4006
|
+
idGen.next(),
|
|
4007
|
+
// Mandanten-ID = erste generierte ID (Determinismus)
|
|
4008
|
+
name,
|
|
4009
|
+
baseCurrency,
|
|
4010
|
+
{
|
|
4011
|
+
accounts: new InMemoryAccountRepository(),
|
|
4012
|
+
fiscalYears: new InMemoryFiscalYearRepository(),
|
|
4013
|
+
vouchers: new InMemoryVoucherRepository(),
|
|
4014
|
+
journal: new InMemoryJournalRepository(),
|
|
4015
|
+
openItems: new InMemoryOpenItemRepository(),
|
|
4016
|
+
assets: new InMemoryAssetRepository(),
|
|
4017
|
+
partners: new InMemoryPartnerRepository(),
|
|
4018
|
+
audit: new InMemoryAuditTrail()
|
|
4019
|
+
},
|
|
4020
|
+
clock,
|
|
4021
|
+
idGen,
|
|
4022
|
+
dimensions,
|
|
4023
|
+
taxCodes,
|
|
4024
|
+
taxProfile,
|
|
4025
|
+
mappings
|
|
4026
|
+
);
|
|
4027
|
+
}
|
|
4028
|
+
/**
|
|
4029
|
+
* Mandant aus beliebigen Ports bauen (Service-Verdrahtung bleibt hier im Kern).
|
|
4030
|
+
* `inMemory` nutzt das mit In-Memory-Ports; der Persistenz-Adapter
|
|
4031
|
+
* (`@superheld/summae-knex`) reicht DB-gestützte Ports herein — derselbe
|
|
4032
|
+
* `Tenant`, nur andere Ports.
|
|
4033
|
+
*/
|
|
4034
|
+
static fromPorts(tenantId, name, baseCurrency, ports, clock, ids, dimensions = DimensionRegistry.empty(), taxCodes = TaxCodeRegistry.empty(), taxProfile = TaxProfile.default(), mappings = MappingRegistry.empty()) {
|
|
4035
|
+
const { accounts, fiscalYears, vouchers, journal, openItems, assets, partners, audit } = ports;
|
|
3959
4036
|
const ledger = new Ledger(
|
|
3960
4037
|
baseCurrency,
|
|
3961
4038
|
accounts,
|
|
@@ -3966,14 +4043,14 @@ var Tenant = class _Tenant {
|
|
|
3966
4043
|
audit,
|
|
3967
4044
|
dimensions,
|
|
3968
4045
|
clock,
|
|
3969
|
-
|
|
4046
|
+
ids
|
|
3970
4047
|
);
|
|
3971
4048
|
const tax = new TaxService(baseCurrency, taxCodes, taxProfile, journal);
|
|
3972
|
-
const assetService = new AssetService(baseCurrency, assets, fiscalYears, vouchers, ledger,
|
|
3973
|
-
const costing = new CostingService(baseCurrency, accounts, journal,
|
|
3974
|
-
const partnerService = new PartnerService(partners, audit, clock,
|
|
4049
|
+
const assetService = new AssetService(baseCurrency, assets, fiscalYears, vouchers, ledger, ids);
|
|
4050
|
+
const costing = new CostingService(baseCurrency, accounts, journal, ids);
|
|
4051
|
+
const partnerService = new PartnerService(partners, audit, clock, ids);
|
|
3975
4052
|
return new _Tenant(
|
|
3976
|
-
|
|
4053
|
+
tenantId,
|
|
3977
4054
|
name,
|
|
3978
4055
|
baseCurrency,
|
|
3979
4056
|
accounts,
|
|
@@ -3991,7 +4068,7 @@ var Tenant = class _Tenant {
|
|
|
3991
4068
|
partnerService,
|
|
3992
4069
|
mappings,
|
|
3993
4070
|
clock,
|
|
3994
|
-
|
|
4071
|
+
ids
|
|
3995
4072
|
);
|
|
3996
4073
|
}
|
|
3997
4074
|
};
|