receipt_long

SalesInvoiceView

Unified AI-ready Sales Invoice Business View with standardized financial, product and logistics calculations.
sales invoice ai semantic layer logistics ready
Purpose

This view provides enriched invoice-level and product-level data for reporting, AI analysis, logistics planning, financial calculation and customer insights.

Measurement Units
  • Pweight → grams (g)
  • PVol → cubic millimeters (mm³)
  • ProdQtyAll → base unit (piece)
  • QtyPackage → units per package/carton
Business Rules
  • Package Quantity = ProdQtyAll / QtyPackage (if QtyPackage > 0)
  • Weight is per unit in grams
  • Volume is calculated as: Height × Width × Length (mm³)
Relationships

This view acts as a core transactional semantic layer for sales and operational analytics. It connects customer, product, financial, and logistics domains through consistent business keys. Relationships are categorized into transactional, operational, and analytical layers to avoid circular dependency.

Related View Join Keys Relationship Type Description
CustAssignToSellerView SellerID, CustID Operational Maps customer ownership to sales representatives for territory and coverage validation.
CustomerPotentialAnalyticsView CustID Analytical Enables comparison of customer behavioral score with actual transactional performance.
CustomerVisitLogsView CustID, SellerID Operational Links executed visits with sales outcomes to measure engagement effectiveness.
SellerVisitPathCustomersView CustID, SellerID Operational Compares planned visits with actual sales execution coverage.
DeliveryOperationAnalyticsView OrderID = SalesDocID Operational Connects sales transactions with logistics execution and delivery performance.
InventoryView ProdID, BranchID Operational Provides stock context for sold products and supports replenishment planning.
OrderCollectionAnalyticsView OrderID Analytical Analyzes payment behavior, receivable aging, and collection efficiency.
OrderFinancialSummaryView OrderID Transactional Core financial aggregation layer including revenue, discounts, tax, and outstanding balance.
OrderReturnSummaryView OrderID, ProdID, CustID Transactional Handles product-level return analysis and reverse logistics impact on orders.
SalesInvoiceView (Current) OrderID, CustID, SellerID, MPID, ProdID, BranchID, SCID Transactional (Fact) Primary fact table representing invoice line-level sales transactions across all dimensions.
Primary Join Strategy (Clean Semantic Model)
  • OrderID → Core transaction backbone across financial, delivery, return, and collection systems
  • CustID → Customer intelligence, segmentation, and behavioral analysis
  • SellerID → Sales force performance and territory management
  • MPID → Logistics execution and delivery performance tracking
  • ProdID → Product profitability, returns, and inventory consumption
  • BranchID / SCID → Organizational and channel segmentation
Fields
Field Type Description
BranchIDintBranch identifier
BranchNamestringBranch name
SCIDintSales channel ID
SCNamestringSales channel name
OrderIDintInvoice / Order ID
StatusCodeintOrder status (1 Order, 2 Distribution, 3 Invoiced, 4 Canceled)
StatusTitlestringStatus description
OrderDatestringOrder date
TahvilDatestringDelivery date
CustIDintCustomer ID
CustTitlestringCustomer name
LatdecimalCustomer latitude
LngdecimalCustomer longitude
CityNamestringCity
AreaNamestringArea
SellerIDintSalesperson ID
VisitorNamestringSalesperson name
MPID Delivery Agent ID int Identifier of the delivery or distribution agent responsible for handling the order after assignment to logistics.
MPName Delivery Agent Name string Name of the delivery or distribution representative responsible for order delivery.
ProdIDintProduct ID
ProdNamestringProduct name
ProdGroupintProduct group ID
GrpDescstringProduct group name
BrandIDintBrand ID
BrandNamestringBrand name
ProdQtyAlldecimalQuantity in base unit (piece)
QtyPackageintUnits per package/carton
PweightdecimalWeight per unit (grams)
PVoldecimalVolume per unit (mm³)
IsPromobitPromotion flag
SumPricedecimalGross line price
SUMProdDiscountdecimalTotal product discount
NetPricedecimalNet price after discount
TaxPricedecimalTax amount
FinalPricedecimalTotal final price
warning
Date Format Note

All date fields in this view are stored as STRING in format YYYY/MM/DD. They are not SQL DateTime types and must be parsed before date operations.

Usage
  • AI sales analysis
  • Invoice reporting
  • Logistics planning
  • Customer behavior analysis
  • Revenue forecasting