Ruby on Rails application that automates a calculation of merchants’ disbursements payouts and seQura commissions. Link to original challenge: https://sequra.github.io/backend-challenge/
Application uses:
- Ruby version - 3.0.4
- Rails version - 7.1.2
- PostgreSQL version - 14.10
- Sidekiq version - 7.2
- Parsing
merchants.csvfile to validate and save data inmerchantstable - Parsing
orders.csvfile to validate, calculate fee and save data inorderstable - Calculate monthly fees for all existing merchants from
live ondate to current date - Calculate daily and weekly disbursements for all merchants' orders
- Calculate disbursements on daily basis
- Calculate disbursements on weekly basis
Note: Monthly fee calculations for all merchants are calculated from live on date to current date (last calculated month is December 2023), even if there are no orders for December in orders.csv file!
| Year | Number of disbursements | Amount disbursed to merchants | Amount of order fees | Number of monthly fees charged (From minimum monthly fee) | Amount of monthly fee charged (From minimum monthly fee) |
|---|---|---|---|---|---|
| 2022 | 1009 | 29035379.3 | 262968.56 | 46 | 1072.88 |
| 2023 | 7870 | 143096726.46 | 1300058.84 | 214 | 4868.69 |
Dropbox link: https://www.dropbox.com/scl/fo/r3x8xnbbmbqnm6s2mujaa/h?rlkey=2x62x65vkbxy2aru05ui4c8iu&dl=0
.CSV files provided via the original challenge are invalid.
Before start working with the database, ensure you have the PostgreSQL service running: brew services list
git clone git@github.com:denis-mironov/sequra.gitbundle installrake db:create- Filling DB with data:
-
Parsing .CSV files and using rake tasks (time consuming operation):
rake db:migratedownload 'merchants.csv' and 'orders.csv' files via Dropbox link abovecreate new 'db/csv_dumps' directory in the project and put downloaded .CSV files there- run next rake tasks:
rake fill_table_with_data:merchantsrake fill_table_with_data:ordersrake fill_table_with_data:monthly_feesrake disbursements:fill_dailyrake disbursements:fill_weekly
-
Using DB dump (merchants, orders, disbursements and monthly_fees are included):
download 'development_dump.sql' file via Dropbox link abovepsql sequra_development < link_to_downloaded_dump_filerake db:migrate
-
- Install and run Redis service (official Redis documentation)
- Run Sidekiq server with
sidekiqcomand.
rspec spec
rubocop