Purshew: Chase Bank set up shop in +234
Built with NestJS, this service offers a robust and scalable server-side application for accounting purposes. The API leverages GraphQL for efficient data querying and manipulation, ensuring high performance and flexibility. It utilizes Drizzle ORM for seamless database operations, and PostgreSQL for reliable data storage and retrieval.
-
clone the repo
git clone https://github.com/kwadwoatta/purshew.git
-
cd into the repo
cd purshew
-
copy .env.example to .env and fill them out
-
install all dependencies
pnpm install
-
start the postgres (database) service
docker compose up -d
-
generate SQL migrations for the drizzle schema definitions
pnpm drizzle-kit generate:pg
-
push the generated SQL migrations to the postgres database
pnpm tsx db/migrate.ts
-
seed the transaction templates
pnpm tsx db/seed.ts
-
(optional) start the drizzle-kit studio to interact with your database
pnpm drizzle-kit studio
-
start the app in development mode
pnpm start:dev
-
visit url in Altair or Graphql client of choice
http://[::1]:3000/graphql
-
signing up a user
mutation { signup(signup: { email: "test@mail.com", password: "123" }) { access_token } }
-
copy access token and set as Header for subsequent requests
Authorization: Bearer {your access token}
-
execute template for Kwame's initial opening balance
mutation { executeTransactionTemplate( executeTransactionTemplateInput: { template: kwame_initial_capital amount: 50000.00 } ) }
-
execute template for Kwame's purchase of GHS 20,000 worth of System Units
mutation { executeTransactionTemplate( executeTransactionTemplateInput: { template: kwame_system_unit_purchase amount: 20000.00 } ) }
-
execute template for Kwame's sale of GHS 10,000 worth of System Units
mutation { executeTransactionTemplate( executeTransactionTemplateInput: { template: kwame_system_unit_sale amount: 10000.00 } ) }
Here is a PostgreSQL stored procedure for generating a balance sheet:
CREATE OR REPLACE PROCEDURE balance_sheet(INOUT result_set refcursor)
LANGUAGE plpgsql
AS $$
BEGIN
OPEN result_set FOR
SELECT
debit_account_name AS "Debit Account",
debit_amount AS "Amount",
credit_account_name AS "Credit Account",
credit_amount AS "Amount",
description AS "Description"
FROM
transactions
UNION ALL
SELECT
'TOTAL' AS debit_account_name,
SUM(debit_amount) AS debit_amount,
'TOTAL' AS credit_account_name,
SUM(credit_amount) AS credit_amount,
NULL AS description
FROM
transactions;
END;
$$;
- Author - Prince Ofori
- Twitter - @KwadwoTheAtta
Purshew API is MIT licensed.