---
# System prepended metadata

title: Database Schema
tags: [Offline Transaction]

---

---
tags: Offline Transaction
---
# Database Schema
```plantuml
package evm-product {
    entity product {
        id : char(36)
        model_id : bigint(20)
        code : text
        __
        category_id_int : bigint(20)
        __
        brand_id : char(36)
        brand_id_int : bigint(20)
        __
        name : varchar(255)
        __dicount__
        discount : decimal(5,2)
        discount_price : decimal(12,2)
        __reseller commission__
        commission_price : decimal(12,2)
        commission_percentage : decimal(5,2)
        __evermos commission__
        evermos_commission_percentage : decimal(5,2)
        evermos_commission_price : decimal(12,2)
        __vendor_commission__
        vendor_commission_percentage : decimal(5,2)
        vendor_commission_price : decimal(12,2)
        __
        active : bool
    }
    entity product_variant {
        id : char(36)
        id_int : bigint(20)
        sku : varchar(20)
        --
        variant_parent_id : char(36)
        variant_parent_id_int : bigint(20)
        __
        name : varchar(255)
        retail_price : decimal(12,2)
        discount_price : (12,2)
        active : bool
        __
        cover_image : text
        --product--
        product_id : char(36)
        model_id: bigint(20)
    }
}

package inv {
    entity product_variant_mapping {
        id : char(36)
        --child--
        product_variant_id : char(36)
        product_variant_id_int : bigint(20)
        --parent--
        product_variant_id_parent : char(36)
        product_variant_id_parent_int : bigint(20)
        --
        stock_location_id_int : bigint(20)
        product_id_int : bigint(20)
        product_id_parent_int : bigint(20)
        
    }
entity product_variant_stock <<P, cyan >> {
  id : char(36)
  --
  product_variant_id : char(36)
  product_variant_id_int : bigint(20)
  
  --
  stock_location_id_int: bigint(20)
  --
  stock_on_hand : int(11)
  stock_reserved : int(11)
  stock_available : int(11)
}
    
}


package evm {
    
entity stock_location <<S, green >> {
  id : bigint(20) <<generated>>
  label : varchar(255)
  --
  brandId: bigInt(20)
  password: text
}

entity brand <<B, orange >> {
  id : bigint(20) <<generated>>
  code : varchar(10)
  --
  name: varchar(100)
  stockLocation: int(11)
}


brand::stockLocation ||--|{ stock_location::id
stock_location::brandId||--||brand::id
}

product_variant_stock::stock_location_id_int||--||stock_location::id
    
package evm_pos #line:pink {
    entity order #line:pink{
        entity_id : char(36)
        order_code : varchar(60)
        __difference_price = total_purchase - total_item_price__
        total_item_price : decimal(12,2)
        difference_price : decimal(12,2)
        total_purchase : decimal(12,2)
        __
        purchased_at : datetime
        status : enum(done, cancel)
        __reason__
        diff_price_reason_id : char(36)
        reason_text : char(255)
        __cashier__
        cashier_type : char(36)
        cashier_ref_id : char(36)
        __metadata__
        created_at : timestamp
        created_by : timestamp
        updated_at : timestamp
        updated_by : timestamp
        deleted_at : timestamp
        deleted_by : timestamp
        
    }
    entity order_detail #line:pink{
        entity_id : char(36)
        order_id : char(36)
        order_code : varchar(60)
        __
        
        __
        product_variant_id : char(36)
        product_variant_id_int : bigint(20)
        sku_code: varchar(20)
        stock_location_id_int : bigint(20)
        sku_name: varchar(255)
        thumbnail: text
        __qty__
        qty: int
        __unit price__
        unit_value : decimal(12,2)
        __subtotal = unit value * qty__
        subtotal : decimal(12,2)
        __metadata__
        created_at : timestamp
        created_by : timestamp
        updated_at : timestamp
        updated_by : timestamp
        deleted_at : timestamp
        deleted_by : timestamp
    }
    order_detail::order_id}|--||order::entity_id
    
    
    entity reason {
        entity_id : char(36)
        reason : char(255)
        is_active : bool
        __metadata__
        created_at : timestamp
        created_by : timestamp
        updated_at : timestamp
        updated_by : timestamp
        deleted_at : timestamp
        deleted_by : timestamp
    }
    order::diff_price_reason_id||--||reason::entity_id
    
    entity order_detail_snapshot {
        entity_id : char(36)
        order_detail_id : char(36)
        __variant__
        id : char(36)
        new_id : char(36)
        product_model_id : bigint(20)
        product_parent_id : bigint(20)
        sku_name : varchar(255)
        sku_slug : varchar(255)
        sku_code : varchar(20)
        quantity : int
        __
        cover_image : text
        __
        normal_price : decimal(12,2)
        discount_price : decimal(12,2)
        reseller_price : decimal(12,2)
        customer_price : decimal(12,2)
        commission_price : decimal(12,2)
        commission_percentage : decimal(5,2)
        vendor_price : decimal(12,2)
        vendor_commission_percentage : decimal(5,2)
        vendor_commission_price : decimal(12,2)
        weight : int
        height : int
        length : int
        width : int
        is_cod : bool
        is_active : bool
        size_id: bigInt(20)
        size_label : varchar(20)
        color_id: bigInt(20)
        color_label : varchar(20)
        __Stock Location__
        stock_location_id : bigint(20)
        stock_location_label : varchar(255)
        stock_location_urban_id : bigint(20)
        stock_location_urban_name : varchar(255)
        stock_location_shipper_area_id : bigint(20)
        stock_location_is_marketplaceable : bool
        stock_location_courier_fee: decimal(12,2)
        stock_location_is_self_courier : bool
        stock_location_address : text
        stock_location_brand_id : bigint(20)
        __product__
        product_id : bigint(20)
        product_discount_price : decimal(12,2)
        __reseller commission__
        product_commission_price : decimal(12,2)
        product_commission_percentage : decimal(5,2)
        __brand__
        product_is_flash_sale : bool
        product_brand_id : bigint(20)
        product_is_po : bool
        __metadata__
        created_at : timestamp
        created_by : timestamp
    }
    
    order_detail::entity_id||--||order_detail_snapshot::order_detail_id
}

```