Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tx and VAT + Various things #39

Merged
merged 94 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
949faab
First version of entry and transaction db entity design.
Oct 30, 2024
01f7109
Begin to design to VAT configration (for Switzerland) don't know if i…
Oct 31, 2024
31e4275
Vat rate contarcts and mappers
Oct 31, 2024
b3626ba
Vat rate, minimal base service. Change account to add the Active param.
Oct 31, 2024
1462427
New account field
Oct 31, 2024
28eb57f
git ignore to always ignore my local cert
Oct 31, 2024
3918eda
Active/Inactive account + add a filter in the BlazorView
Oct 31, 2024
af3c77a
IsActive account in Blazor
Oct 31, 2024
4529983
Correction of bug in unique index for security api.
Oct 31, 2024
3c71f96
Big commit: rename accounting api to accounting-structure.api
fdonnet Oct 31, 2024
08e8154
Rename accounting contracts prj + namespace
fdonnet Oct 31, 2024
8addb53
New backend prj to manage VAT or Sales tax
fdonnet Nov 1, 2024
2cc1438
Correct db name for accounting_struct_api and security api for table …
fdonnet Nov 1, 2024
cedd489
Put in place vatsales tax api
fdonnet Nov 1, 2024
1acb732
Sales tax vat first endpoint
fdonnet Nov 1, 2024
0a20564
Some progress on SalesOrVatTax
fdonnet Nov 1, 2024
9ddc02c
typo
fdonnet Nov 1, 2024
2a420e3
typo
fdonnet Nov 1, 2024
49e9334
Again a new better way to manage token at each call... not only when …
fdonnet Nov 1, 2024
5809d38
Ok, token management is working better and in minikube too. Only sess…
fdonnet Nov 1, 2024
40f9248
comment
fdonnet Nov 1, 2024
b4a7584
prob certifi, i don't know why it works now
fdonnet Nov 1, 2024
5ba1466
Prepare for tax rates endpoints
fdonnet Nov 2, 2024
1f3669d
Cleanup endpoint for integration tests
fdonnet Nov 2, 2024
f636ec0
Ready to test new api accounting_sales_vat tax
fdonnet Nov 2, 2024
995ad0c
Test ready 2
fdonnet Nov 2, 2024
a8f6ddb
Test add taxrates, modify to dateonly for the valid to, valid from
fdonnet Nov 2, 2024
69224be
Test fro TaxRates
fdonnet Nov 2, 2024
a5e8e73
Very minimal health endpoint for accounting struct api
fdonnet Nov 3, 2024
7f3b498
Change applications routes
fdonnet Nov 3, 2024
c64ad34
Only use health check for DEV, return true if in PROD
fdonnet Nov 3, 2024
2e98aba
Chnage data seed for application in struct api
fdonnet Nov 3, 2024
13c2551
Account data in sales-vat tax module.
fdonnet Nov 4, 2024
557c1d2
Some progress on attaching tax rates to account with a target tax rat…
fdonnet Nov 4, 2024
674dfb3
Add account tax rates config and init base data
fdonnet Nov 4, 2024
8fdaee4
Add accountTaxratecongfigs tests
fdonnet Nov 4, 2024
58c6927
Delete account taxrate config
fdonnet Nov 4, 2024
3cdc6e9
Rename and account tax rate config delete operation.
fdonnet Nov 4, 2024
0b17697
Renaming
fdonnet Nov 4, 2024
f1bf809
comment
fdonnet Nov 4, 2024
562b725
Remove not used using
fdonnet Nov 5, 2024
31006cc
Test delete account rate config.
fdonnet Nov 5, 2024
5ebde6a
Consumers account in VAT Tax Api
fdonnet Nov 5, 2024
a9fb76b
Account consumers in tax api. Seems to work.
fdonnet Nov 5, 2024
ea0f0ee
renaming
fdonnet Nov 5, 2024
7c1ab14
Remove useless navigation property I don't use.
fdonnet Nov 5, 2024
e39152c
Clean all the useless navigation properties
fdonnet Nov 5, 2024
b9b238c
Not working but some progress on creating a not bad model.
fdonnet Nov 5, 2024
1c55a3d
Rename Feature erro type
Nov 6, 2024
02875ea
Prepare transaction service
Nov 6, 2024
9d25ec4
Load initial accounts data
Nov 6, 2024
2d3495a
TaxRate in transaction API
Nov 6, 2024
7005de0
Rename typo
Nov 6, 2024
0e9547e
Some progress rename
Nov 6, 2024
576cff8
Renaming
Nov 6, 2024
15060cd
Consumer for tax rates in transaction API
Nov 6, 2024
5a19969
Dont' forget to populate tenant_id in events.
Nov 6, 2024
4f3b9e4
no browser launch for api
fdonnet Nov 6, 2024
d682734
Replace audit field in all model by a value object and adapt the chan…
Nov 7, 2024
00817e5
docker support for tx api
Nov 7, 2024
52c9539
Prepare for Submit TX
Nov 7, 2024
d0a70c5
Begin for tx submit
Nov 7, 2024
98969f9
Ok, very first steps for submiting a TX
fdonnet Nov 8, 2024
111c77a
First tx submit (with minimal and naive checks).
fdonnet Nov 8, 2024
a6aeca4
Renaming
fdonnet Nov 8, 2024
2e9ffc4
Clean not needed using.
fdonnet Nov 8, 2024
6861307
Not bad, before trying to loop only one time to mangage TX simple ent…
fdonnet Nov 8, 2024
0db1674
Loop on entries check info.
fdonnet Nov 8, 2024
2093795
Submit transaction: first minimal version. (not checking from VAT api…
fdonnet Nov 8, 2024
ac25ce9
Cleanup db enpoint for TX api. For testing.
fdonnet Nov 8, 2024
5141c5c
First submit TX test OK.
fdonnet Nov 8, 2024
ecdd453
Base routes testing for submit TX (security)
fdonnet Nov 8, 2024
49a4879
Some tests
fdonnet Nov 8, 2024
bd16901
Tx minimal first submit version
fdonnet Nov 11, 2024
1df19a3
Saga or not ?
fdonnet Nov 11, 2024
ba716f7
Entry link for tax/vat entries that will be linked to other entries
fdonnet Nov 11, 2024
85709f9
comment
fdonnet Nov 11, 2024
2c127d2
Seems to work to add a simple tx without tax validation.
Nov 12, 2024
a56614f
Some packages update
Nov 13, 2024
76edc61
Blazor not used thing
Nov 13, 2024
6c73815
Ok Tx submit with state in the DB
Nov 13, 2024
d5ebfe4
Fake consumer for tax validation
Nov 13, 2024
17490c2
Publish the state of a TX for other components...
Nov 13, 2024
e468758
Not working masstransit state serialization, very strange....
Nov 13, 2024
646f2cc
Masstransit: strinjson Enum error....
Nov 13, 2024
cc95110
See why it's bugged on update but now the masstransit queue seems to …
fdonnet Nov 13, 2024
a9f12d8
Correction bug for update
Nov 14, 2024
deefd3f
Seems to work.
Nov 14, 2024
cb3fd02
Seems to work good.
Nov 14, 2024
d2d23d2
force ubik name as docker compose project
Nov 14, 2024
95e6b53
Config for minikube for accounting-tx and accounting-tax
fdonnet Nov 14, 2024
bbd49e3
comment in README
fdonnet Nov 14, 2024
343a5d8
update readme
fdonnet Nov 15, 2024
91d21db
Remove unused usings
fdonnet Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/src/mycert.cer
85 changes: 54 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
NEW BIG PR implemented:
LAST BIG PR implemented:

- security api and tenant management
- remove authorization via roles from keycloack
- implement Yarp as a proxy and authorization manager (call the security api and forward request to backend apis, authorization via policy requierments for each route)
- remove masstransit for request/response, keep it only for events (pub/sub)
- review and simplify the test parts (complete review) => only integration tests for the moment. No real backend functions to unit test.
- Blazor app now calls the Yarp proxy
- double-entry preparation
- 2 new backend apis (tx and sales-or-vat-tax)
- Blazor better token management

Next steps between:

- vat-sales tax module implementation
- .Net 9 (Blazor adaptations)
- SingalR hub to trace tx status
- Blazor double-entry ui
- Aspire (re-test the thing)
- will see...

# Ubik - Accounting

Expand All @@ -26,11 +32,11 @@ At this stage, **DO NOT USE THIS SYSTEM ON A PRODUCTION** environnement.

## For the Kubernetes/Minikube guys

For detailed instructions on deploying locally with Minikube, please refer to the [local deployment guide](./deploy/deploy-local-readme.md).
For detailed instructions on deploying locally with Minikube (full experience), please refer to the [local deployment guide](./deploy/deploy-local-readme.md).

## Build and Run

At the root of the repository. "Mount" the dependencies with Docker by running this command in your terminal:
**At the root of the repository**, "Mount" the dependencies with Docker by running this command in your terminal:

`docker compose -f .\docker-compose.yml -f .\docker-integration-tests.yml up -d`

Expand All @@ -43,11 +49,15 @@ At the root of the repository. "Mount" the dependencies with Docker by running t
> - Pgadmin: to admin your dbs if needed
> - Apis: backend apis (security/accounting) for integration testing

### Ready to play
### Ready to play and debug

#### Run backend Apis or define a multiple projects startup

`dotnet run --launch-profile https --project ./src/Ubik.Accounting.SalesOrVatTax.Api/Ubik.Accounting.SalesOrVatTax.Api.csproj`

#### Run backend Apis
`dotnet run --launch-profile https --project ./src/Ubik.Accounting.Transaction.Api/Ubik.Accounting.Transaction.Api.csproj`

`dotnet run --launch-profile https --project ./src/Ubik.Accounting.Api/Ubik.Accounting.Api.csproj`
`dotnet run --launch-profile https --project ./src/Ubik.Accounting.Structure.Api/Ubik.Accounting.Structure.Api.csproj`

`dotnet run --launch-profile https --project ./src/Ubik.Security.Api/Ubik.Security.Api.csproj`

Expand All @@ -59,10 +69,7 @@ At the root of the repository. "Mount" the dependencies with Docker by running t

`dotnet run --launch-profile https --project ./src/Ubik.Accounting.WebApp/Ubik.Accounting.WebApp.csproj`

And now, you can access the very first version of a the Blazor 8 webapp here <https://localhost:7249>

*Don't change the ports of the api and the blazor apps. It's hard coded in the Blazor prj (need to be changed) because no service discovery for the moment.*
*In Debug, create a multiple project startup that runs all this stuff*
And now (when all the stuff are up and running), you can access the very first version of a the Blazor 8 webapp here <https://localhost:7249>

### All the things are up

Expand All @@ -82,40 +89,54 @@ Try to log with different access rights and play with the only available "Accoun

Now you can run your preferred code editor and start to deep dive... (see below)

## External libs

| Package | For what |
|----------- | -------- |
| [Asp.Versioning](https://github.com/dotnet/aspnet-api-versioning) | automatic versioning of API (controllers / endpoints) |
| EfCore | commands and ez queries + data init etc |
| [Dapper](https://github.com/DapperLib/Dapper) | some read queries |
| [EFCore.NamingConvention](https://github.com/efcore/EFCore.NamingConventions) | force EF core to postgres SnakeCase => way better if you need to use Dapper too |
| [LanguageExt.Core](https://github.com/louthy/language-ext) | use Either<Left, Right> pattern |
| [Masstransit](https://github.com/MassTransit/MassTransit) | message bus abstraction + inbox/outbox pattern |

## Yarp Proxy

-- Ubik.YarpProxy --

Manages all the authorization stuff by calling the security api and forward the requests to the backend. (cool af)
Manages all the authorization stuff by calling the security api and forward the requests to the backend.

## Security Api

-- Ubik.Security.Api --

Used by the proxy to manage authorizations and exposes admin and user endpoints to manage the authorizations/users/tenants config.

## Accounting Api
## Accounting structure Api

-- Ubik.Accounting.Api --
-- Ubik.Accounting.Structure.Api --

Some used external libs:
Manages the accounting structure.

| Package | For what |
|----------- | -------- |
| [Asp.Versioning](https://github.com/dotnet/aspnet-api-versioning) | automatic versioning of API (controllers / endpoints) |
| EfCore | commands and ez queries + data init etc |
| [Dapper](https://github.com/DapperLib/Dapper) | some read queries |
| [EFCore.NamingConvention](https://github.com/efcore/EFCore.NamingConventions) | force EF core to postgres SnakeCase => way better if you need to use Dapper too |
| [LanguageExt.Core](https://github.com/louthy/language-ext) | use Either<Left, Right> pattern |
| [Masstransit](https://github.com/MassTransit/MassTransit) | message bus abstraction + inbox/outbox pattern |
## Accounting tx Api

-- Ubik.Accounting.Transaction.Api --

For the moment, implement the submit Tx endpoint and create some states and events related to future Txs management.

# Accounting sales or VAT tax

-- Ubik.Accounting.SalesOrVatTax.Api --

Will implement all the rules related to sales or VAT taxes and validate a Tx when needed. Will be used to declare and enforce the rules. (for each country etc)

## Features folder in backend Apis

Contains the core features (in Vertical Slices mode).

- Command and query services
- When a command is executed with success, an event is published to the message bus (pub/sub)
- Functional `Either<Error, Result>` patterns in all layers to transfer errors between layer and to keep the code not too dirty. (not an expert but I like it)
- Functional `Either<Error, Result>` patterns in all layers to transfer errors between layer and to keep the code not too dirty.

## Frontend Blazor

Expand Down Expand Up @@ -149,7 +170,7 @@ Send some love on github to this projects...
- Typed HttpClient to access the backend api
- Tailwind config - Tailwind Flowbite design layout etc
- A very minimal reverse proxy controller that allows components (automode) to call the backend api when they are WASM.
- Some stuff about security (Token cache service, UserService with circuit, middleware)
- Some stuff about security (Token cache service)

In program.cs, you can access the config of:

Expand All @@ -158,6 +179,8 @@ In program.cs, you can access the config of:
- Cookie auth with OpenIdC (connection + refresh token in OnValidatePrincipal)
- ...

=> next, implement new .Net 9 Blazor stuff related to authentication and render modes.

### Ubik.Accounting.WebApp.Client

(client-auto side)
Expand All @@ -184,7 +207,7 @@ In program.cs, you can access the config of:

## Others

-- Ubik.Accounting.ApiService.Common -- / -- Ubik.Db.Common -- / -- Ubik.Accounting.Contracts --
-- Ubik.Accounting.ApiService.Common -- / -- Ubik.Db.Common -- / -- Ubik.xxx.Contracts --

- Common config things that can be reused in other projects
- This part will maybe grow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: accounting-api
name: accounting-structure-api
labels:
app: accounting-api
app: accounting-structure-api
spec:
replicas: 1
selector:
matchLabels:
app: accounting-api
app: accounting-structure-api
template:
metadata:
labels:
app: accounting-api
app: accounting-structure-api
spec:
containers:
- name: accounting-api
image: ubik-accounting-api-test:latest
- name: accounting-structure-api
image: ubik-accounting-structure-api-test:latest
imagePullPolicy: Never
env:
- name: ConnectionStrings__AccountingContext
value: 'Host=ubik-postgres-postgresql;Port=5432;Database=ubik_accounting;Username=postgres;Password=test01'
value: 'Host=ubik-postgres-postgresql;Port=5432;Database=ubik_accounting_struct;Username=postgres;Password=test01'
- name: ASPNETCORE_ENVIRONMENT
value: Development
- name: MessageBroker__Host
Expand All @@ -41,10 +41,10 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: accounting-api
name: accounting-structure-api
spec:
selector:
app: accounting-api
app: accounting-structure-api
ports:
- protocol: TCP
port: 80
Expand Down
51 changes: 51 additions & 0 deletions deploy/accounting-tax-api/accounting-tax-api-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: accounting-sales-vat-tax-api
labels:
app: accounting-sales-vat-tax-api
spec:
replicas: 1
selector:
matchLabels:
app: accounting-sales-vat-tax-api
template:
metadata:
labels:
app: accounting-sales-vat-tax-api
spec:
containers:
- name: accounting-sales-vat-tax-api
image: ubik-accounting-sales-vat-tax-api-test:latest
imagePullPolicy: Never
env:
- name: ConnectionStrings__AccountingSalesTaxDbContext
value: 'Host=ubik-postgres-postgresql;Port=5432;Database=ubik_accounting_salestax;Username=postgres;Password=test01'
- name: ASPNETCORE_ENVIRONMENT
value: Development
- name: MessageBroker__Host
value: 'amqp://ubik-rabbitmq:5672'
- name: AuthServer__MetadataAddress
value: "https://keycloak-local/realms/ubik/.well-known/openid-configuration"
- name: AuthServer__Authority
value: "https://keycloak-local/realms/ubik"
- name: AuthServer__AuthorizationUrl
value: "https://keycloak-local/realms/ubik/protocol/openid-connect/auth"
- name: AuthServer__TokenUrl
value: "https://keycloak-local/realms/ubik/protocol/openid-connect/token"
- name: AuthManagerKeyCloakClient__RootUrl
value: "http://keycloak-local/"
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: accounting-sales-vat-tax-api
spec:
selector:
app: accounting-sales-vat-tax-api
ports:
- protocol: TCP
port: 80
targetPort: 8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: accounting-transaction-api
labels:
app: accounting-transaction-api
spec:
replicas: 1
selector:
matchLabels:
app: accounting-transaction-api
template:
metadata:
labels:
app: accounting-transaction-api
spec:
containers:
- name: accounting-transaction-api
image: ubik-accounting-tx-api-test:latest
imagePullPolicy: Never
env:
- name: ConnectionStrings__AccountingTxContext
value: 'Host=ubik-postgres-postgresql;Port=5432;Database=ubik_accounting_tx;Username=postgres;Password=test01'
- name: ASPNETCORE_ENVIRONMENT
value: Development
- name: MessageBroker__Host
value: 'amqp://ubik-rabbitmq:5672'
- name: AuthServer__MetadataAddress
value: "https://keycloak-local/realms/ubik/.well-known/openid-configuration"
- name: AuthServer__Authority
value: "https://keycloak-local/realms/ubik"
- name: AuthServer__AuthorizationUrl
value: "https://keycloak-local/realms/ubik/protocol/openid-connect/auth"
- name: AuthServer__TokenUrl
value: "https://keycloak-local/realms/ubik/protocol/openid-connect/token"
- name: AuthManagerKeyCloakClient__RootUrl
value: "http://keycloak-local/"
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: accounting-transaction-api
spec:
selector:
app: accounting-transaction-api
ports:
- protocol: TCP
port: 80
targetPort: 8080
38 changes: 33 additions & 5 deletions deploy/deploy-local-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Contains config to access the already existing postgres db

### Generate self signed certificate (if you want to change them in ingress)

To remember the commands only:
To remember the commands only (you can skip this part):

`openssl req -newkey rsa:2048 -nodes -keyout tls.key -out tls.csr`

Expand All @@ -73,19 +73,47 @@ To remember the commands only:

`helm install ubik-cache bitnami/redis -f ./redis/values-dev.yaml`

## Accounting Api
## Accounting Structure Api

Build image

`docker build -t ubik-accounting-api-test:latest -f ../src/Ubik.Accounting.Api/Dockerfile ../`
`docker build -t ubik-accounting-structure-api-test:latest -f ../src/Ubik.Accounting.Structure.Api/Dockerfile ../`

Load image in minikube

`minikube image load ubik-accounting-api-test:latest`
`minikube image load ubik-accounting-structure-api-test:latest`

Apply deployement

`kubectl apply -f ./accounting-api/accounting-api-deploy.yaml`
`kubectl apply -f ./accounting-structure-api/accounting-structure-api-deploy.yaml`

## Accounting Transaction Api

Build image

`docker build -t ubik-accounting-tx-api-test:latest -f ../src/Ubik.Accounting.Transaction.Api/Dockerfile ../`

Load image in minikube

`minikube image load ubik-accounting-tx-api-test:latest`

Apply deployement

`kubectl apply -f ./accounting-transaction-api/accounting-transaction-api-deploy.yaml`

## Accounting Sales Vat Tax Api

Build image

`docker build -t ubik-accounting-sales-vat-tax-api-test:latest -f ../src/Ubik.Accounting.SalesOrVatTax.Api/Dockerfile ../`

Load image in minikube

`minikube image load ubik-accounting-sales-vat-tax-api-test:latest`

Apply deployement

`kubectl apply -f ./accounting-tax-api/accounting-tax-api-deploy.yaml`

## Security api

Expand Down
2 changes: 1 addition & 1 deletion deploy/keycloack/ingress-for-keycloack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-origin: "http://ubik-proxy, http://ubik-webapp, https://ubik-webapp"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS, DELETE"
nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,X-CustomHeader,X-LANG,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Api-Key,X-Device-Id,Access-Control-Allow-Origin"
nginx.ingress.kubernetes.io/configuration-snippet: |
Expand Down
Loading