The best way to control Claude Code, Codex and more from any computer or phone

main
ts 20 lines 758 Bytes
Raw
1 import * as Domain from "@alchemy.run/domain";
2 import * as Effect from "effect/Effect";
3 import { Account } from "../Account/Account.aggregate.ts";
4 import { SettlementOnClosedAccount } from "../Account/RecordSettlement.command.ts";
5 import { Payments } from "./Payments.external.ts";
6
7 /** Whenever money settles on a closed account, refund it. */
8 export class SettlementRefund extends Domain.Policy("SettlementRefund", {
9 from: Account,
10 on: [SettlementOnClosedAccount],
11 }) {}
12
13 export const SettlementRefundLive = SettlementRefund.toLayer(
14 Effect.gen(function* () {
15 const payments = yield* Payments;
16 return Effect.fn(function* ({ event }) {
17 yield* payments.refund({ settlementId: event.settlementId, amount: event.amount });
18 });
19 }),
20 );