Skip to content

feat: sell a product

Paul Jarleton requested to merge feat/#14_sell_product into main

Summary

This PR introduce a route POST /products/{productId}/sell that updates the stocks according to the amount of product sold.

What's in the box

SQL

This feature rely heavily on constraint against within the database itself as follow:

CREATE TABLE inventory (
    art_id        int CONSTRAINT inventory_unique_article_id PRIMARY KEY,
    name          varchar NOT NULL,
    stock         integer NOT NULL CHECK ( stock >= 0 )
);

DB Decode error improvements

There is now a clear separation when using a decoder from the api side and from the database which fix the error path where a decoding error from the database would be tagged as 400.

Inventory repo

The update of a product rely on the update of each articles. therefore this PR introduce a new update function in the inventory repo that update the stock value.

The error channel has also been refined to include latest error handling system

Merge request reports