1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
export const generateMerchantTransactionDataSingleton = (
{ id, name, currency, origin }: { id: number; name?: string; currency?: string; origin?: string },
) => (
{
id,
merchantName: name || `Merchant ${id}`,
currency: currency || "USD",
location: origin || "New York, NY",
transactions: Array.from(Array(Math.floor((Math.random() * 50) + id)).keys()).map((v, index) => ({
id: v,
amount: v * 10,
date: `2020-${id > 9 ? id : `0${id}`}-01`,
// no US fraud trend
// force China/Russia fraud trend
status: id === 1 || id == 2 || id === 5 || (id !== 8 && id !== 9 && index % 2)
? "processed"
: index % 6
? "refunded"
: index % 1
? "pending"
: "declined",
type: id === 1 || id == 2 || id === 5 || (id !== 8 && id !== 9 && index % 2)
? "credit"
: index % 6
? "debit"
: index % 1
? "credit"
: "debit",
})),
}
);
export const generateMerchantTransactionData = () => {
const merchants = [
{ id: 1, name: "Mikes Deli", currency: "USD", origin: "New York, NY" },
{ id: 2, name: "ZippyZaps Zoo", currency: "USD", origin: "Columbus, OH" },
{ id: 3, name: "Carlositas Tacos", currency: "MXN", origin: "Guadalajara, MX" },
{ id: 4, name: "Jojis Manga", currency: "JPY", origin: "Tokyo, JP" },
{ id: 5, name: "Bux Star Coffee", currency: "USD", origin: "Seattle, WA" },
{ id: 6, name: "Pepes Pizza", currency: "EUR", origin: "Rome, IT" },
{ id: 7, name: "Nguen Apparel", currency: "CNY", origin: "Beijing, CN" },
{ id: 8, name: "Ximas Xima", currency: "MZN", origin: "Maputo, MZ" },
{ id: 9, name: "Putin's Pub", currency: "RUB", origin: "Moscow, RU" },
{ id: 10, name: "Fay's Falafel", currency: "ILS", origin: "Jerusalem, IL" },
];
return merchants.map((m) => (generateMerchantTransactionDataSingleton(m)));
};
// console.log(generateMerchantTransactionData());
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
August 28, 2024