@better-giving/donation 1.1.15 → 1.1.16

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.
@@ -196,6 +196,7 @@ export declare namespace Donation {
196
196
  title?: DonorTitle;
197
197
  firstName: string;
198
198
  lastName: string;
199
+ companyName?: string;
199
200
  email: string;
200
201
  address?: DonorAddress;
201
202
  /** signifies eligibility to UK Gift Aid, defaults to `false` for crypto donations */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/donation",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "devDependencies": {
5
5
  "@better-giving/config": "1.1.2"
6
6
  },
package/src/donation.mts CHANGED
@@ -292,6 +292,7 @@ export declare namespace Donation {
292
292
  title?: DonorTitle;
293
293
  firstName: string;
294
294
  lastName: string;
295
+ companyName?: string;
295
296
  email: string;
296
297
  address?: DonorAddress;
297
298
  /** signifies eligibility to UK Gift Aid, defaults to `false` for crypto donations */
@@ -1,54 +0,0 @@
1
- import type { Donation } from "./donation.mjs";
2
-
3
- type FinalRecord = Pick<
4
- Donation.V2DBRecord,
5
- | "amount"
6
- | "appUsed"
7
- | "chainName"
8
- | "charityName"
9
- | "claimed"
10
- | "denomination"
11
- | "email"
12
- | "endowmentId"
13
- | "feeAllowance"
14
- | "fiatRamp"
15
- | "fiscalSponsored"
16
- | "inHonorOf"
17
- | "isRecurring"
18
- | "network"
19
- | "nonProfitMsg"
20
- | "paymentMethod"
21
- | "programId"
22
- | "programName"
23
- | "splitLiq"
24
- | "tipAmount"
25
- | "transactionDate"
26
- | "transactionId"
27
- | "tributeNotif"
28
- | "usdValue"
29
- >;
30
-
31
- interface SettledAmounts {
32
- settledFee: number;
33
- settledNet: number;
34
- }
35
-
36
- /** donation is to fund */
37
- interface Fund {
38
- fund_id?: string;
39
- fund_name?: string;
40
- fund_members?: number[];
41
- }
42
-
43
- export type FinalRecorderPayload = {
44
- /** intent to delete */
45
- intentId?: string;
46
- hideBgTip: boolean;
47
-
48
- /** donation message */
49
- donor_message?: string;
50
- donor_public?: boolean;
51
- } & FinalRecord &
52
- SettledAmounts &
53
- Fund &
54
- (Donation.WithKYC | Donation.WithoutKYC);
@@ -1,20 +0,0 @@
1
- /**
2
- * @param amount endow amount + tip
3
- * @param rate 0-1, to be applied to amount @example `amount * rate`
4
- * @param flat flat amount added to `amount * rate`. NOTE: make sure that this is in the same unit as `amount`
5
- * @returns number
6
- */
7
- export const getMinFeeAllowance = (
8
- amount: number,
9
- rate: number,
10
- flat = 0
11
- ): number => {
12
- /**
13
- * fee(1) = amount * rate + flat
14
- * fee(2) = (amount + fee(1)) * rate + flat
15
- * fee(3) = (amount + fee(2)) * rate + flat
16
- * i.e. F₍ₙ₎ = a · ∑ᵏ⁼¹ⁿ (rᵏ) + f · ∑ᵏ⁼⁰ⁿ⁻¹ (rᵏ)
17
- * which converges to this formula: n approaches infinity
18
- */
19
- return (amount * rate + flat) / (1 - rate);
20
- };
@@ -1,104 +0,0 @@
1
- import * as v from "valibot";
2
- import {
3
- type Frequency,
4
- donationSource,
5
- donorTitle,
6
- tributeNotif,
7
- uuid,
8
- } from "./intent.mjs";
9
-
10
- const str = v.pipe(v.string(), v.trim());
11
- const requiredStr = v.pipe(str, v.nonEmpty());
12
-
13
- const int = v.pipe(v.number(), v.integer());
14
- const money = v.pipe(v.number(), v.minValue(0));
15
-
16
- const donorAddress = v.object({
17
- streetAddress: requiredStr,
18
- city: str,
19
- state: str,
20
- zipCode: requiredStr,
21
- /** country name */
22
- country: requiredStr,
23
- });
24
-
25
- const donor = v.object({
26
- title: donorTitle,
27
- firstName: requiredStr,
28
- lastName: requiredStr,
29
- email: v.pipe(str, v.email()),
30
- address: v.optional(donorAddress),
31
- ukGiftAid: v.optional(v.boolean()),
32
- });
33
-
34
- export const oldIntent = v.pipe(
35
- v.object({
36
- transactionId: v.optional(str),
37
- type: v.optional(v.picklist(["one-time", "subscription"])),
38
- amount: money,
39
- tipAmount: money,
40
- feeAllowance: money,
41
- currency: v.optional(str),
42
- endowmentId: v.pipe(int, v.minValue(1)),
43
- programId: v.optional(uuid),
44
- programName: v.optional(str),
45
- splitLiq: v.pipe(int, v.minValue(0), v.maxValue(100)),
46
- donor,
47
- inHonorOf: v.optional(str),
48
- tributeNotif: v.optional(tributeNotif),
49
- source: donationSource,
50
- denomination: v.optional(str),
51
- chainId: v.optional(str),
52
- chainName: v.optional(str),
53
- }),
54
- v.transform((input) => ({
55
- amount: {
56
- amount: input.amount,
57
- currency: input.currency ? input.currency : (input.denomination ?? ""),
58
- tip: input.tipAmount,
59
- feeAllowance: input.feeAllowance,
60
- },
61
- recipient: input.endowmentId,
62
- program:
63
- input.programId && input.programName
64
- ? {
65
- id: input.programId,
66
- name: input.programName,
67
- }
68
- : undefined,
69
- donor: {
70
- title: input.donor.title,
71
- firstName: input.donor.firstName,
72
- lastName: input.donor.lastName,
73
- email: input.donor.email,
74
- address: input.donor.address
75
- ? {
76
- street: input.donor.address.streetAddress,
77
- city: input.donor.address.city,
78
- state: input.donor.address.state,
79
- zipCode: input.donor.address.zipCode,
80
- country: input.donor.address.country,
81
- ukGiftAid: input.donor.ukGiftAid,
82
- }
83
- : undefined,
84
- },
85
- source: input.source,
86
- tribute: input.inHonorOf
87
- ? {
88
- fullName: input.inHonorOf,
89
- notif: input.tributeNotif
90
- ? {
91
- toEmail: input.tributeNotif.toEmail,
92
- toFullName: input.tributeNotif.toFullName,
93
- fromMsg: input.tributeNotif.fromMsg,
94
- }
95
- : undefined,
96
- }
97
- : undefined,
98
- frequency: (input.type === "subscription"
99
- ? "recurring"
100
- : (input.type ?? "one-time")) as Frequency,
101
- viaName: input.chainName ?? "fiat",
102
- viaId: input.chainId ? input.chainId : (input.transactionId ?? "fiat"),
103
- }))
104
- );