Skip to main content

Inventory management system project.

 Objective: 

    Enable efficient tracking and management of store inventory to ensure products are available when needed.

Technology: 

  1. PHP 8.2
  2. Codeigniter framework 4.6.1
  3. Codeigniter shield (Auth library) 1.1.0 
  4. Firecamp for restAPI testing 
  5. Notepad++ code writing (light weight)
  6. mySQL

 Plan:

  1. First people will authenticate using email and password then, Other API access by using Bearer token.

 


 Challenges:

  1. Product can measured by different property - {weight, size or volume}
  2. Product amount will vary occasionally - {festival, demand}
  3. Types of inventory operation - {add, sale, return, remove, adjust, transfer}
1.First challenge: 
    Whenever measure one material in different measurement then, That material is different product because, It may be in different phase [solid, liquid, gas]. Example- when buying fruit in solid measured as kg , if buying fruit measured in volume. So, same fruit come under different product - fruit, juice. But, if buy oil it can measured in volume and weight also, this is the actual issue. Here i just fixed or assigned quantity_type (measuring) and Unit (kg, ltr) on creating product. So, if need to mention same product in different unit should create each product for each unit. 
 
2.Second challenge:
    Product amount change occasionally (festival, offer, etc.) and another currency (INR, USD etc,). So, I created currency table to mention different currency. It solve whenever user request amount for different currency it will get respective amount. That not only solved issue, after amount change remain. So, I created amount table as ledger with currency_id, amount and effective_from(date) it solved issue by getting last record for respective currency id.
 
3. Third challenge:
    Whenever new(add) product come from supplier it will increase the stock, Like if product damaged it will remove from stock. Whenever product sale to user it will decrease the stock, Like that if product return from customer it will increase stock. Whenever product transfer from one warehouse to another it will decrease stock. If human accreditation or counting error happen should adjust stock value (increase or decrease) . So, Every operation as recorded as a new record with changing quantity, change_type and current_val.
 

 RestAPI's:

1. Auth:
    Login:  
                method - POST
                url - /api/login
      header - content-type: application/x-www-form-urlencoded
      body - form-data - email
                                 - password
 
    Logout:  
                method - POST
                url - /api/logout 
                header - Authorization: Bearer $access_token
 
2.First step or initialization 
   Create category:
                method - POST
                url - /api/category
                header -  Authorization: Bearer $access_token;
                               content-type: application/x-www-form-urlencoded
                body - name: $category_name
                           description: $description
                           parent: $parent_category_id
     
 Get all product category details:
              method - GET
              url - /api/category
              header -  Authorization: Bearer $access_token;
Get single product category details:
              method - GET
              url - /api/category/$category_id
              header -  Authorization: Bearer $access_token;
Update product category details:
              method - PUT
              url - /api/category/$category_id
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -  category_id: $category_id 
                           name: $category_name
                           description: $description
                           parent: $parent_category_id
Create currency:
              method - POST
              url - /api/currency
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   name: $currency_name
                           code : $currency_code
                           symbol: $currency_symbol
Create Quantity Unit:
              method - POST
              url - /api/unit
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   name: $unit_name
                           symbol: $unit_symbol
Create Quantity Type:
             method -  POST
              url - /api/quantity-type
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   name: $quantity_type_name
3. Product 
Create product:
              method -  POST
              url - /api/product
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   name: $product_name
                           description: $product_description
                           sku_id: $product_sku_id
                           category_id: $category_id
                           amount: $product_amount
                           currency_code: $currency_code
                           quantity_name: $quantity_name
                           unit_name: $unit_name
Modify product details:
              method -  PUT
              url - /api/product
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   product_id: $product_id
                           name: $product_name
                           description: $product_description
                           sku_id: $product_sku_id
                           category_id: $category_id
                           amount: $product_amount
                           currency_code: $currency_code
                           status: $product_status
Get All product:
              method -  GET
              url - /api/product
              header -  Authorization: Bearer $access_token;
Get single product:
              method -  GET
              url - /api/product/$product_id
              header -  Authorization: Bearer $access_token;
Delete product:
              method -  DELETE
              url - /api/product
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   product_id: $product_id
 4. Inventory:
Add or modify product inventory:
              method -  POST
              url - /api/product
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   product_id: $product_id
                           change_type : $inventory_change_type
                           operation: $inventory_operation
                           change_quantity: $change_value
                           inventory_note: $inventory_note
Get single product inventory:
              method -  GET
              url - /api/product
              header -  Authorization: Bearer $access_token;
                             content-type: application/x-www-form-urlencoded;
              body -   product_id: $product_id
 

Comments

Popular posts from this blog

PHP can run AI models - no need Python

 Objective:     Run AI models only using php. Now this is possible with  https://github.com/CodeWithKyrian/transformers-php  this library. I have tried object detection and question answering using this library. Technology:       1.  PHP 8.2 Initialization:     Guide -  https://transformers.codewithkyrian.com/getting-started 1. Initialize project by composer init cmd. 2. Install transformer library by  composer require codewithkyrian/transformers cmd. 3. Enable ffi extention in php.ini       extension = ffi      ffi.enable = true 4. Enable opcache      opcache.jit = tracing 5. Increase memory limit      memory_limit = 512M I. Object detection: ( https://transformers.codewithkyrian.com/object-detection )     Object detection can improve web application perspective . Example:  Retail applications can speed up checkout by automatically recognizing ...

Don't assign value to reference variable.

Objective:          I just tried to create linked list in php.  Challenges:     In php array is sufficient for most data types (simple array, multi-dimensional array and key-value associative array). But, i just tried using  stdClass Object ( pre-defined interfaces and class ). Here, I created one stdClass with reference key and it reference to another class up to final and that final class  reference key is null. Here I used reference key as reference variable. Once i started assigning reference value to this key it assigning new value to it and old one erased. $a = new stdClass(); $a->name = "Trial"; $a->ref = null; for($i=1;$i <= 10;$i++){  $b = new stdClass();  $b->name = 'Demo mj '.$i;  $b->ref = null;  if($a->ref === null ){   $a->ref = &$b;  }else{   $current = $a->ref;   wh...

bootstrap-popper not allowing html table

  Objective :       Creating popover with html using bootstrap-popover.js Technology:  Bootstrap version - 4.6.1 Popper - 1.16.1 Jquery - 3.5.1 Challenge:     1. basic syntax for popover <button type= "button" class= "btn btn-lg btn-success" data-toggle= "popover" title= "Popover title" data-content= "And here's some amazing content. It's very engaging. Right?" > Click to toggle popover </button>      $ ( function () {           $ ( '[data-toggle="popover"]' ). popover ();      });    2. Put html to that popover syntax <button type= "button" class= "btn btn-lg btn-success" data-toggle= "popover" title= "Popover title" data-content= "And here's some amazing content. It's very engaging. Right?" > Click to toggle popover </button>      $(function () { $('button[data-toggle="popover"]').popover(...