diff --git a/starter-artifacts/src/CorePayments.Infrastructure/Repository/CustomerRepository.cs b/starter-artifacts/src/CorePayments.Infrastructure/Repository/CustomerRepository.cs index bc4f63c..87f0aa2 100644 --- a/starter-artifacts/src/CorePayments.Infrastructure/Repository/CustomerRepository.cs +++ b/starter-artifacts/src/CorePayments.Infrastructure/Repository/CustomerRepository.cs @@ -28,8 +28,6 @@ namespace CorePayments.Infrastructure.Repository QueryDefinition query = new QueryDefinition("select * from c where c.type = @docType order by c.accountId") .WithParameter("@docType", Constants.DocumentTypes.AccountSummary); - await TriggerTrackingEvent($"Retrieving paged account summary with page size {pageSize}."); - return await PagedQuery(query, pageSize, null, continuationToken); } diff --git a/starter-artifacts/src/account-generator/Program.cs b/starter-artifacts/src/account-generator/Program.cs index 8149991..11bc603 100644 --- a/starter-artifacts/src/account-generator/Program.cs +++ b/starter-artifacts/src/account-generator/Program.cs @@ -1,4 +1,5 @@ using Bogus; +using Bogus.Distributions.Gaussian; using CorePayments.Infrastructure; using CorePayments.Infrastructure.Domain.Entities; using Microsoft.Azure.Cosmos; @@ -166,10 +167,37 @@ namespace account_generator .RuleFor(u => u.overdraftLimit, (f, u) => 5000) .RuleFor(u => u.memberSince, (f, u) => f.Date.Past(20)); + var accountSummary = orderFaker.Generate(); + var memberSinceDate = accountSummary.memberSince.Date; + var currentDate = DateTime.UtcNow; + var isNegative = false; + + var transactionFaker = new Faker() + .RuleFor(u => u.id, (f, u) => f.Random.Guid().ToString()) + .RuleFor(u => u.accountId, (f, u) => accountId) + .RuleFor(u => u.amount, (f, u) => + { + isNegative = f.Random.Bool(0.8f); // 80% chance of being negative + var minAmount = isNegative ? -5000 : 5; // adjust the minimum value based on negativity + var maxAmount = isNegative ? -5 : 5000; // adjust the maximum value based on negativity + return Convert.ToDouble(f.Finance.Amount(minAmount, maxAmount, 2)); + }) + .RuleFor(u => u.type, (f, u) => isNegative ? "Debit" : "Credit") + .RuleFor(u => u.description, (f, u) => f.Lorem.Sentence()) + .RuleFor(u => u.merchant, (f, u) => f.Company.CompanyName()) + .RuleFor(u => u.timestamp, (f, u) => f.Date.Between(memberSinceDate, currentDate)); + + var transactions = transactionFaker.GenerateBetween(4, 8); + tasks.Add( _pollyRetryPolicy.ExecuteAsync(async () => { - await transactionsContainer.UpsertItemAsync(orderFaker.Generate(), new PartitionKey(accountId)); + await transactionsContainer.UpsertItemAsync(accountSummary, new PartitionKey(accountId)); + + foreach (var transaction in transactions) + { + await transactionsContainer.UpsertItemAsync(transaction, new PartitionKey(accountId)); + } } ).ContinueWith(t => { diff --git a/starter-artifacts/ui/package-lock.json b/starter-artifacts/ui/package-lock.json index 8a977da..0b52409 100644 --- a/starter-artifacts/ui/package-lock.json +++ b/starter-artifacts/ui/package-lock.json @@ -15,6 +15,7 @@ "eslint-config-next": "13.4.5", "flowbite-react": "^0.4.7", "lodash": "^4.17.21", + "moment": "^2.29.4", "next": "13.4.5", "postcss": "^8.4.24", "react": "18.2.0", @@ -2933,6 +2934,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/starter-artifacts/ui/package.json b/starter-artifacts/ui/package.json index 9ad4627..0dedeeb 100644 --- a/starter-artifacts/ui/package.json +++ b/starter-artifacts/ui/package.json @@ -16,6 +16,7 @@ "eslint-config-next": "13.4.5", "flowbite-react": "^0.4.7", "lodash": "^4.17.21", + "moment": "^2.29.4", "next": "13.4.5", "postcss": "^8.4.24", "react": "18.2.0", diff --git a/starter-artifacts/ui/src/components/forms/new-account.js b/starter-artifacts/ui/src/components/forms/new-account.js index 3253c08..4e7e830 100644 --- a/starter-artifacts/ui/src/components/forms/new-account.js +++ b/starter-artifacts/ui/src/components/forms/new-account.js @@ -8,7 +8,7 @@ const NewAccountForm = ({ setOpenModal }) => { const [error, setError] = useState(''); const [form, setForm] = useState({ - id: '0909090908', + id: '', accountType: 'Checking', balance: '', customerGreetingName: '', @@ -18,7 +18,7 @@ const NewAccountForm = ({ setOpenModal }) => { const [isLoading, setIsLoading] = useState(false); const onClickCancel = () => { setForm({ - id: '0909090908', + id: '', accountType: '', balance: '', customerGreetingName: '', @@ -37,7 +37,7 @@ const NewAccountForm = ({ setOpenModal }) => { setOpenModal(false); setIsLoading(false); setForm({ - id: '0909090908', + id: '', accountType: 'Checking', balance: '', customerGreetingName: '', @@ -52,6 +52,7 @@ const NewAccountForm = ({ setOpenModal }) => { }); }; + const onChangeAccountId = (e) => setForm({ ...form, id: e.target.value }); const onChangeAccountType = (accountType) => setForm({ ...form, accountType }); const onChangeCustomerGreetingName = (e) => setForm({ ...form, customerGreetingName: e.target.value }); @@ -60,6 +61,18 @@ const NewAccountForm = ({ setOpenModal }) => { return (
+
+
+
+ +