ofcoop-shared-core 0.1.0-alpha.2 → 0.1.0-alpha.4

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.
@@ -0,0 +1,44 @@
1
+ import type { ScopeRef, ResponseEnvelope } from 'ofcore';
2
+ export interface CoopCapabilityProfileFlags {
3
+ supportsCredit: boolean;
4
+ supportsConsumerOps: boolean;
5
+ supportsMultiunit: boolean;
6
+ supportsMemberSelfService: boolean;
7
+ supportsGovernanceDigital: boolean;
8
+ }
9
+ export interface CoopCapabilityProfileContract extends ScopeRef, CoopCapabilityProfileFlags {
10
+ id: string;
11
+ tenantId: string;
12
+ branchId?: string;
13
+ profileName: string;
14
+ isActive: boolean;
15
+ notes?: string | null;
16
+ version: number;
17
+ lastModified: string;
18
+ deleted: boolean;
19
+ }
20
+ export interface UpsertCoopCapabilityProfileInput extends ScopeRef, CoopCapabilityProfileFlags {
21
+ tenantId: string;
22
+ branchId?: string;
23
+ profileName: string;
24
+ notes?: string | null;
25
+ }
26
+ export interface CoopCapabilityProfileQueryOptions extends Partial<ScopeRef> {
27
+ includeDeleted?: boolean;
28
+ isActive?: boolean;
29
+ }
30
+ export interface GetEffectiveCoopCapabilityProfileInput extends ScopeRef {
31
+ }
32
+ export interface EffectiveCoopCapabilityProfileResult extends CoopCapabilityProfileFlags {
33
+ source: 'branch' | 'tenant' | 'default';
34
+ profileId?: string | null;
35
+ profileName: string;
36
+ tenantId: string;
37
+ branchId?: string | null;
38
+ }
39
+ export interface CoopCapabilityProfileServiceContract {
40
+ upsertCapabilityProfile(input: UpsertCoopCapabilityProfileInput): Promise<ResponseEnvelope<CoopCapabilityProfileContract>>;
41
+ getCapabilityProfileById(profileId: string): Promise<ResponseEnvelope<CoopCapabilityProfileContract | null>>;
42
+ listCapabilityProfiles(options?: CoopCapabilityProfileQueryOptions): Promise<ResponseEnvelope<CoopCapabilityProfileContract[]>>;
43
+ getEffectiveCapabilityProfile(input: GetEffectiveCoopCapabilityProfileInput): Promise<ResponseEnvelope<EffectiveCoopCapabilityProfileResult>>;
44
+ }
@@ -0,0 +1,27 @@
1
+ import type { ScopeRef, ResponseEnvelope } from 'ofcore';
2
+ export interface MemberPosCustomerLinkContract extends ScopeRef {
3
+ id: string;
4
+ sourceDomain: 'ofpos';
5
+ customerId: string;
6
+ memberId: string;
7
+ linkedAt: string;
8
+ linkedBy?: string | null;
9
+ notes?: string | null;
10
+ version: number;
11
+ lastModified: string;
12
+ deleted: boolean;
13
+ }
14
+ export interface UpsertMemberPosCustomerLinkInput extends ScopeRef {
15
+ customerId: string;
16
+ memberId: string;
17
+ linkedBy?: string | null;
18
+ notes?: string | null;
19
+ }
20
+ export interface ResolveMemberPosCustomerLinkInput extends ScopeRef {
21
+ customerId: string;
22
+ }
23
+ export interface MemberPosCustomerLinkServiceContract {
24
+ upsertPosCustomerLink(input: UpsertMemberPosCustomerLinkInput): Promise<ResponseEnvelope<MemberPosCustomerLinkContract>>;
25
+ getPosCustomerLinkByCustomerId(input: ResolveMemberPosCustomerLinkInput): Promise<ResponseEnvelope<MemberPosCustomerLinkContract | null>>;
26
+ resolveMemberIdByPosCustomerId(input: ResolveMemberPosCustomerLinkInput): Promise<ResponseEnvelope<string | null>>;
27
+ }
@@ -0,0 +1,47 @@
1
+ import type { ScopeRef, ResponseEnvelope } from 'ofcore';
2
+ import type { ShuParticipationAssuranceLevel, ShuParticipationSourceType } from './ShuParticipationEntryContract.js';
3
+ export type ParticipationAssuranceCheckStatus = 'pass' | 'warn' | 'fail';
4
+ export type ParticipationAssuranceReadiness = 'strong' | 'mixed' | 'weak';
5
+ export interface ParticipationAssuranceScope extends ScopeRef {
6
+ shuPeriodId: string;
7
+ }
8
+ export interface ParticipationAssuranceBreakdownItem {
9
+ sourceType: ShuParticipationSourceType;
10
+ assuranceLevel: ShuParticipationAssuranceLevel;
11
+ entryCount: number;
12
+ amountTotal: number;
13
+ withEvidenceCount: number;
14
+ evidenceCoveragePercent: number;
15
+ }
16
+ export interface ParticipationAssuranceCheck {
17
+ id: string;
18
+ label: string;
19
+ status: ParticipationAssuranceCheckStatus;
20
+ detail: string;
21
+ meta?: Record<string, unknown>;
22
+ }
23
+ export interface ParticipationAssuranceSummary {
24
+ score: number;
25
+ readiness: ParticipationAssuranceReadiness;
26
+ totalEntries: number;
27
+ totalAmount: number;
28
+ evidenceCoveragePercent: number;
29
+ dominantSourceType: ShuParticipationSourceType | null;
30
+ approvedFormalAmountPercent: number;
31
+ pendingApprovalEntryCount: number;
32
+ lowAssuranceEntryCount: number;
33
+ lowAssuranceAmount: number;
34
+ formalAmountPercent: number;
35
+ }
36
+ export interface ParticipationAssuranceSnapshot {
37
+ generatedAt: string;
38
+ scope: ParticipationAssuranceScope;
39
+ summary: ParticipationAssuranceSummary;
40
+ breakdown: ParticipationAssuranceBreakdownItem[];
41
+ checks: ParticipationAssuranceCheck[];
42
+ }
43
+ export interface GetParticipationAssuranceInput extends ParticipationAssuranceScope {
44
+ }
45
+ export interface ParticipationAssuranceServiceContract {
46
+ getParticipationAssuranceSnapshot(input: GetParticipationAssuranceInput): Promise<ResponseEnvelope<ParticipationAssuranceSnapshot>>;
47
+ }
@@ -1,4 +1,5 @@
1
1
  import type { ScopeRef, ResponseEnvelope } from 'ofcore';
2
+ import type { FinanceJournalEntry } from 'offinance-shared-core';
2
3
  /**
3
4
  * Jenis partisipasi anggota untuk perhitungan JUA.
4
5
  * - 'pinjaman' : volume pinjaman aktif (KSP — proporsi bunga/pokok)
@@ -9,11 +10,34 @@ import type { ScopeRef, ResponseEnvelope } from 'ofcore';
9
10
  * - 'jasa' : nilai jasa yang digunakan/diberikan (jasa)
10
11
  */
11
12
  export type ShuParticipationType = 'pinjaman' | 'simpanan_aktif' | 'pembelian' | 'produksi' | 'pemasaran' | 'jasa';
13
+ export type ShuParticipationSourceType = 'bridge' | 'manual_via_offinance' | 'manual_direct' | 'import';
14
+ export type ShuParticipationAssuranceLevel = 'high' | 'medium' | 'low';
15
+ export type ShuParticipationApprovalStatus = 'not_required' | 'pending_approval' | 'approved' | 'rejected';
12
16
  export interface ShuParticipationEntryContract extends ScopeRef {
13
17
  id: string;
14
18
  shuPeriodId: string;
15
19
  memberId: string;
16
20
  participationType: ShuParticipationType;
21
+ sourceType: ShuParticipationSourceType;
22
+ assuranceLevel: ShuParticipationAssuranceLevel;
23
+ approvalStatus: ShuParticipationApprovalStatus;
24
+ /** Unit usaha/kelompok usaha asal partisipasi bila relevan. */
25
+ unitBusinessId?: string | null;
26
+ /** Referensi canonical ke dokumen/artefak bukti minimum. */
27
+ evidenceRef?: string | null;
28
+ /** Tipe referensi sumber formal, mis. offinance_manual_recap atau pos_sale_summary. */
29
+ sourceReferenceType?: string | null;
30
+ /** Id referensi sumber formal dari domain/rekap asal. */
31
+ sourceReferenceId?: string | null;
32
+ /** Aktor/operator yang mencatat entry ini bila tersedia. */
33
+ recordedBy?: string | null;
34
+ /** Waktu pencatatan canonical entry. */
35
+ recordedAt: string;
36
+ approvedAt?: string | null;
37
+ approvedBy?: string | null;
38
+ approvalRef?: string | null;
39
+ rejectedAt?: string | null;
40
+ rejectionReason?: string | null;
17
41
  /** Nilai/volume dalam satuan IDR atau unit usaha yang disepakati */
18
42
  amount: number;
19
43
  /** Keterangan tambahan (referensi transaksi, dll.) */
@@ -26,16 +50,72 @@ export interface RecordShuParticipationInput extends ScopeRef {
26
50
  shuPeriodId: string;
27
51
  memberId: string;
28
52
  participationType: ShuParticipationType;
53
+ sourceType: ShuParticipationSourceType;
54
+ unitBusinessId?: string | null;
55
+ evidenceRef?: string | null;
56
+ sourceReferenceType?: string | null;
57
+ sourceReferenceId?: string | null;
58
+ recordedBy?: string | null;
29
59
  amount: number;
30
60
  notes?: string | null;
31
61
  }
32
62
  export interface BulkRecordShuParticipationInput {
33
63
  entries: RecordShuParticipationInput[];
34
64
  }
65
+ export interface RecordShuParticipationFromOffinanceJournalInput extends ScopeRef {
66
+ shuPeriodId: string;
67
+ memberId: string;
68
+ participationType: ShuParticipationType;
69
+ amount: number;
70
+ unitBusinessId?: string | null;
71
+ recordedBy?: string | null;
72
+ notes?: string | null;
73
+ journal: Pick<FinanceJournalEntry, 'id' | 'tenantId' | 'branchId' | 'status' | 'reference' | 'evidenceRef' | 'occurredAt' | 'postedAt'>;
74
+ }
75
+ export interface PosSaleParticipationSummary {
76
+ saleId: string;
77
+ saleDate: string;
78
+ customerId?: string | null;
79
+ total: number;
80
+ finalTotal: number;
81
+ transactionCurrencyCode?: string | null;
82
+ totalInBaseCurrency?: number | null;
83
+ finalTotalInBaseCurrency?: number | null;
84
+ note?: string | null;
85
+ }
86
+ export interface RecordShuParticipationFromPosSaleSummaryInput extends ScopeRef {
87
+ shuPeriodId: string;
88
+ memberId: string;
89
+ amount?: number | null;
90
+ unitBusinessId?: string | null;
91
+ recordedBy?: string | null;
92
+ notes?: string | null;
93
+ saleSummary: PosSaleParticipationSummary;
94
+ }
95
+ export interface RecordShuParticipationFromPosSaleSummaryByCustomerLinkInput extends ScopeRef {
96
+ shuPeriodId: string;
97
+ amount?: number | null;
98
+ unitBusinessId?: string | null;
99
+ recordedBy?: string | null;
100
+ notes?: string | null;
101
+ saleSummary: PosSaleParticipationSummary & {
102
+ customerId: string;
103
+ };
104
+ }
105
+ export interface ApproveShuParticipationInput {
106
+ approvedBy: string;
107
+ approvedAt?: string;
108
+ approvalRef?: string | null;
109
+ }
110
+ export interface RejectShuParticipationInput {
111
+ rejectionReason: string;
112
+ rejectedAt?: string;
113
+ }
35
114
  export interface ShuParticipationQueryOptions extends Partial<ScopeRef> {
36
115
  includeDeleted?: boolean;
37
116
  memberId?: string;
38
117
  participationType?: ShuParticipationType;
118
+ approvalStatus?: ShuParticipationApprovalStatus;
39
119
  }
40
120
  export interface MemberParticipationSummary {
41
121
  memberId: string;
@@ -45,6 +125,16 @@ export interface MemberParticipationSummary {
45
125
  export interface ShuParticipationServiceContract {
46
126
  /** Catat satu entri partisipasi anggota untuk periode SHU tertentu */
47
127
  recordParticipation(input: RecordShuParticipationInput): Promise<ResponseEnvelope<ShuParticipationEntryContract>>;
128
+ /** Catat partisipasi anggota dari jurnal finance posted yang sah dari offinance. */
129
+ recordParticipationFromOffinanceJournal(input: RecordShuParticipationFromOffinanceJournalInput): Promise<ResponseEnvelope<ShuParticipationEntryContract>>;
130
+ /** Catat partisipasi anggota dari ringkasan sale POS dengan member yang sudah ditentukan secara eksplisit. */
131
+ recordParticipationFromPosSaleSummary(input: RecordShuParticipationFromPosSaleSummaryInput): Promise<ResponseEnvelope<ShuParticipationEntryContract>>;
132
+ /** Catat partisipasi dari sale POS dengan member yang di-resolve dari linkage customer POS -> member coop. */
133
+ recordParticipationFromPosSaleSummaryByCustomerLink(input: RecordShuParticipationFromPosSaleSummaryByCustomerLinkInput): Promise<ResponseEnvelope<ShuParticipationEntryContract>>;
134
+ /** Approval formal minimum untuk entry yang memang melalui jalur pending formal. */
135
+ approveParticipationEntry(entryId: string, input: ApproveShuParticipationInput): Promise<ResponseEnvelope<ShuParticipationEntryContract>>;
136
+ rejectParticipationEntry(entryId: string, input: RejectShuParticipationInput): Promise<ResponseEnvelope<ShuParticipationEntryContract>>;
137
+ getParticipationEntryById(entryId: string): Promise<ResponseEnvelope<ShuParticipationEntryContract | null>>;
48
138
  /** Bulk record untuk efisiensi saat import dari sistem lain */
49
139
  bulkRecordParticipation(input: BulkRecordShuParticipationInput): Promise<ResponseEnvelope<ShuParticipationEntryContract[]>>;
50
140
  /** List semua entri partisipasi untuk sebuah periode */
@@ -13,8 +13,10 @@ import type { ShuConfigContract, ShuConfigQueryOptions, ShuConfigScope } from '.
13
13
  import type { GovernanceAgendaItemContract, GovernanceDecisionArchive, GovernanceMeetingContract, GovernanceMeetingQueryOptions, GovernanceVoteContract } from '../contracts/GovernanceContract.js';
14
14
  import type { LeadershipAppointmentContract, LeadershipAppointmentQueryOptions } from '../contracts/LeadershipAppointmentContract.js';
15
15
  import type { ShuParticipationEntryContract, ShuParticipationQueryOptions } from '../contracts/ShuParticipationEntryContract.js';
16
+ import type { CoopCapabilityProfileContract, CoopCapabilityProfileQueryOptions } from '../contracts/CoopCapabilityProfileContract.js';
16
17
  import type { CoopCommunityProfileContract, CommunityProfileQueryOptions } from '../contracts/CoopCommunityProfileContract.js';
17
18
  import type { MemberDependentContract, MemberDependentQueryOptions } from '../contracts/MemberDependentContract.js';
19
+ import type { MemberPosCustomerLinkContract } from '../contracts/MemberPosCustomerLinkContract.js';
18
20
  interface MemberExitStateRow {
19
21
  id: string;
20
22
  stage: 'requested' | 'settled' | 'canceled';
@@ -58,6 +60,17 @@ export declare class MemberWaConsentRepository {
58
60
  set(memberId: string, consent: MemberWaConsentInput): Promise<MemberWaConsentRow>;
59
61
  get(memberId: string): Promise<MemberWaConsentRow | null>;
60
62
  }
63
+ export declare class MemberPosCustomerLinkRepository {
64
+ private readonly db;
65
+ constructor(db: DbAdapter);
66
+ create(row: MemberPosCustomerLinkContract): Promise<MemberPosCustomerLinkContract>;
67
+ update(id: string, row: MemberPosCustomerLinkContract): Promise<MemberPosCustomerLinkContract>;
68
+ findByCustomerId(input: {
69
+ customerId: string;
70
+ tenantId?: string | null;
71
+ branchId?: string | null;
72
+ }): Promise<MemberPosCustomerLinkContract | null>;
73
+ }
61
74
  export declare class MemberExitStateRepository {
62
75
  private readonly db;
63
76
  constructor(db: DbAdapter);
@@ -213,6 +226,8 @@ export declare class ShuParticipationEntryRepository {
213
226
  constructor(db: DbAdapter);
214
227
  create(row: ShuParticipationEntryContract): Promise<ShuParticipationEntryContract>;
215
228
  createMany(rows: ShuParticipationEntryContract[]): Promise<ShuParticipationEntryContract[]>;
229
+ getById(id: string): Promise<ShuParticipationEntryContract | null>;
230
+ update(id: string, updates: Partial<ShuParticipationEntryContract>): Promise<ShuParticipationEntryContract>;
216
231
  listByPeriod(shuPeriodId: string, options?: ShuParticipationQueryOptions): Promise<ShuParticipationEntryContract[]>;
217
232
  }
218
233
  export declare class CommunityProfileRepository {
@@ -223,6 +238,14 @@ export declare class CommunityProfileRepository {
223
238
  getById(id: string): Promise<CoopCommunityProfileContract | null>;
224
239
  list(options?: CommunityProfileQueryOptions): Promise<CoopCommunityProfileContract[]>;
225
240
  }
241
+ export declare class CapabilityProfileRepository {
242
+ private readonly db;
243
+ constructor(db: DbAdapter);
244
+ create(row: CoopCapabilityProfileContract): Promise<CoopCapabilityProfileContract>;
245
+ update(id: string, updates: Partial<CoopCapabilityProfileContract>): Promise<CoopCapabilityProfileContract>;
246
+ getById(id: string): Promise<CoopCapabilityProfileContract | null>;
247
+ list(options?: CoopCapabilityProfileQueryOptions): Promise<CoopCapabilityProfileContract[]>;
248
+ }
226
249
  export declare class MemberDependentRepository {
227
250
  private readonly db;
228
251
  constructor(db: DbAdapter);
@@ -234,6 +257,7 @@ export declare class MemberDependentRepository {
234
257
  export interface OfcoopRepositories {
235
258
  memberRepository: MemberRepository;
236
259
  memberWaConsentRepository: MemberWaConsentRepository;
260
+ memberPosCustomerLinkRepository: MemberPosCustomerLinkRepository;
237
261
  memberExitStateRepository: MemberExitStateRepository;
238
262
  memberNumberPolicyRepository: MemberNumberPolicyRepository;
239
263
  governanceMeetingRepository: GovernanceMeetingRepository;
@@ -252,6 +276,7 @@ export interface OfcoopRepositories {
252
276
  shuAllocationRepository: ShuAllocationRepository;
253
277
  leadershipAppointmentRepository: LeadershipAppointmentRepository;
254
278
  shuParticipationEntryRepository: ShuParticipationEntryRepository;
279
+ capabilityProfileRepository: CapabilityProfileRepository;
255
280
  communityProfileRepository: CommunityProfileRepository;
256
281
  memberDependentRepository: MemberDependentRepository;
257
282
  }
@@ -21,8 +21,10 @@ export declare const OFCOOP_TABLES: {
21
21
  readonly governanceDecisionArchives: "ofcoop_governance_decision_archives";
22
22
  readonly leadershipAppointments: "ofcoop_leadership_appointments";
23
23
  readonly shuParticipationEntries: "ofcoop_shu_participation_entries";
24
+ readonly capabilityProfiles: "ofcoop_capability_profiles";
24
25
  readonly communityProfiles: "ofcoop_community_profiles";
25
26
  readonly memberDependents: "ofcoop_member_dependents";
27
+ readonly memberPosCustomerLinks: "ofcoop_member_pos_customer_links";
26
28
  readonly users: "ofcoop_users";
27
29
  readonly roles: "ofcoop_roles";
28
30
  };
@@ -1,4 +1,6 @@
1
1
  import type { SavingLedgerContract } from '../contracts/SavingLedgerContract.js';
2
+ import { type FinanceAccount, type FinanceDbAdapterLike, type FinanceProjectionServicesRef, type FinanceSyncEnqueuer, type JournalDraftInput } from 'offinance-shared-core';
3
+ import type { ServiceRuntimeOptions } from '../services/impl/runtimeSupport.js';
2
4
  export interface ScopedAccountMapping<TMapping> {
3
5
  default: TMapping;
4
6
  byTenant?: Record<string, Partial<TMapping>>;
@@ -30,4 +32,21 @@ export interface ProjectCoopSavingFinanceInput {
30
32
  journalId?: string;
31
33
  referencePrefix?: string;
32
34
  }
35
+ export interface BuildCoopSavingJournalDraftOptions {
36
+ ledgerProfileId: string;
37
+ financeDomainId?: string;
38
+ }
39
+ export interface CreateCoopSavingFinanceRuntimeOptions {
40
+ dbAdapter: FinanceDbAdapterLike;
41
+ resolveFinanceServices: () => FinanceProjectionServicesRef | null;
42
+ resolveLedgerProfileId: () => string;
43
+ resolveSyncEnqueuer?: () => FinanceSyncEnqueuer | null;
44
+ requiredAccounts: FinanceAccount[];
45
+ savingAccountMapping: ScopedAccountMapping<CoopSavingAccountMapping>;
46
+ financeDomainId?: string;
47
+ missingServicesErrorCode?: string;
48
+ missingLedgerProfileErrorCode?: string;
49
+ }
33
50
  export declare function projectSavingLedgerToScopedFinance(input: ProjectCoopSavingFinanceInput): CoopSavingFinanceProjection;
51
+ export declare function buildJournalDraftFromCoopSavingFinanceProjection(projection: CoopSavingFinanceProjection, options: BuildCoopSavingJournalDraftOptions): JournalDraftInput;
52
+ export declare function createCoopSavingFinanceRuntimeOptions(options: CreateCoopSavingFinanceRuntimeOptions): Partial<ServiceRuntimeOptions>;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export * from './contracts/ShuParticipationEntryContract.js';
2
+ export * from './contracts/CoopCapabilityProfileContract.js';
2
3
  export * from './contracts/CoopCommunityProfileContract.js';
3
4
  export * from './contracts/MemberDependentContract.js';
5
+ export * from './contracts/MemberPosCustomerLinkContract.js';
4
6
  export * from './contracts/MemberContract.js';
5
7
  export * from './contracts/SavingLedgerContract.js';
6
8
  export * from './contracts/ShuContract.js';
7
9
  export * from './contracts/MemberNumberPolicyContract.js';
8
10
  export * from './contracts/ComplianceReadinessContract.js';
11
+ export * from './contracts/ParticipationAssuranceContract.js';
9
12
  export * from './contracts/SavingPolicyContract.js';
10
13
  export * from './contracts/SavingComplianceSnapshotContract.js';
11
14
  export * from './contracts/ShuConfigContract.js';
@@ -22,6 +25,7 @@ export * from './services/SavingLedgerService.js';
22
25
  export * from './services/ShuService.js';
23
26
  export * from './services/MemberNumberPolicyService.js';
24
27
  export * from './services/ComplianceReadinessService.js';
28
+ export * from './services/ParticipationAssuranceService.js';
25
29
  export * from './services/SavingPolicyService.js';
26
30
  export * from './services/SavingComplianceSnapshotService.js';
27
31
  export * from './services/ShuConfigService.js';
@@ -54,8 +58,10 @@ export * from './services/createOfcoopDomainAuditCompositionProviders.js';
54
58
  export * from './services/createOfauthCompositionProviders.js';
55
59
  export * from './services/errors.js';
56
60
  export * from './services/ShuParticipationEntryService.js';
61
+ export * from './services/CoopCapabilityProfileService.js';
57
62
  export * from './services/CoopCommunityProfileService.js';
58
63
  export * from './services/MemberDependentService.js';
64
+ export * from './services/MemberPosCustomerLinkService.js';
59
65
  export * from './services/createDbAdapterOfcoopServices.js';
60
66
  export * from './finance/offinanceProjection.js';
61
67
  export * from './data/schemas.js';