vw_GrossProfit View

<< Click to Display Table of Contents >>

Navigation:  iVend Database Database > Views >

vw_GrossProfit View

Navigation: iVend Database Database > Views >

hm_btn_navigate_prevhm_btn_navigate_tophm_btn_navigate_next

iVend 6.6 Database Help

vw_GrossProfit View

Collapse All Expand All

iVend Database Database : vw_GrossProfit View

Properties

Creation Date

4/13/2015 12:00 PM

Is Schema Bound

dbimages_boolean-false

Encrypted

dbimages_boolean-false

Ansi Nulls

dbimages_boolean-true

Columns

 

Column Name

Description

Datatype

Length

Allow Nulls

Default

Formula

 

TransactionKey

 

BigInt

8

 

 

 

 

TransactionId

 

VarWChar

50

 

 

 

 

BusinessDate

 

DBTimeStamp

4

 

 

 

 

ProductKey

 

BigInt

8

 

 

 

 

Id

 

VarWChar

50

 

 

 

 

ProductName

 

VarWChar

100

 

 

 

 

ProductGroupId

 

VarWChar

20

 

 

 

 

ProductGroupDescription

 

VarWChar

100

dbimages_tick

 

 

 

WarehouseKey

 

BigInt

8

 

 

 

 

WarehouseID

 

VarWChar

20

 

 

 

 

WarehouseName

 

VarWChar

100

dbimages_tick

 

 

 

Type

 

Integer

4

 

 

 

 

StoreId

 

VarWChar

20

 

 

 

 

StoreName

 

VarWChar

100

dbimages_tick

 

 

 

CustomerId

 

VarWChar

20

 

 

 

 

CustomerName

 

VarWChar

100

 

 

 

 

LastName

 

VarWChar

40

dbimages_tick

 

 

 

CustomerGroupId

 

VarWChar

20

 

 

 

 

CustomerGroupName

 

VarWChar

100

dbimages_tick

 

 

 

SubsidiaryKey

 

BigInt

8

dbimages_tick

 

 

 

Subsidiary

 

VarWChar

20

dbimages_tick

 

 

 

SubsidiaryDesc

 

VarWChar

100

dbimages_tick

 

 

 

Quantity

 

Numeric

9 (20,5)

 

 

 

 

Price

 

Numeric

9 (20,5)

 

 

 

 

PriceEC

 

Numeric

9 (38,7)

dbimages_tick

 

 

 

BasePrice

 

Numeric

9 (20,5)

 

 

 

 

OriginalPrice

 

Numeric

9 (20,5)

 

 

 

 

Tax

 

Numeric

9 (20,5)

 

 

 

 

TaxEC

 

Numeric

9 (38,7)

dbimages_tick

 

 

 

TotalPostSaleDiscount

 

Numeric

9 (20,5)

 

 

 

 

TotalPostSaleDiscountEC

 

Numeric

9 (38,7)

dbimages_tick

 

 

 

CultureInfo

 

VarWChar

40

dbimages_tick

 

 

 

BaseCultureInfo

 

VarWChar

20

dbimages_tick

 

 

 

ExchangeRate

 

Numeric

9 (20,5)

dbimages_tick

 

 

 

CostingMethod

 

Integer

4

 

 

 

 

Rate

 

Numeric

9 (20,5)

 

 

 

Objects that vw_GrossProfit depends on

 

Database Object

Object Type

Description

Dep Level

CusCustomer table

CusCustomer

Table

Defines the customer details that interact with the enterprise.

1

CusCustomerGroup table

CusCustomerGroup

Table

Defines the groups in which the customers can be catagorised.

1

InvProduct table

InvProduct

Table

Stores the product related details.

1

InvProductCost table

InvProductCost

Table

Store the historical cost of the product.

1

InvProductGroup table

InvProductGroup

Table

Defined the various groups under which the products can be categorised.

1

InvWarehouse table

InvWarehouse

Table

Defines a list of all warehouses defined in the system.

1

PmtCurrency table

PmtCurrency

Table

Define a list of all currecies defined in the system.

1

RtlStore table

RtlStore

Table

Contains the details of Stores defined in the system.

1

RtlSubsidiary table

RtlSubsidiary

Table

Defines all the Subsidiaries defined in the application

1

TrxTransaction table

TrxTransaction

Table

The main table which defined the primary details concerned with every type of transaction.

1

TrxTransactionSaleItem table

TrxTransactionSaleItem

Table

Stores sale/refund/delivery items attached to a transaction

1

View Definition

CREATE View [dbo].[vw_GrossProfit]

as

SELECT A.TransactionKey, A.TransactionId, A.BusinessDate, B.ProductKey, C.Id, C.Description AS ProductName, H.Id AS ProductGroupId, H.Description AS ProductGroupDescription,

G.WarehouseKey, G.Id AS WarehouseID, G.Description AS WarehouseName, B.Type, D.Id AS StoreId, D.Description AS StoreName, E.Id As CustomerId, E.FirstName AS CustomerName,

E.LastName, F.Id AS CustomerGroupId, F.Description AS CustomerGroupName, Sub.SubsidiaryKey, Sub.Id Subsidiary, Sub.Description SubsidiaryDesc, B.Quantity , B.Price, B.PriceEC,

B.BasePrice, B.OriginalPrice, B.Tax, B.TaxEC, B.TotalPostSaleDiscount, B.TotalPostSaleDiscountEC,

(CASE WHEN (G.SubsidiaryKey IS NULL OR G.SubsidiaryKey=0) THEN (Select CultureInfo From PmtCurrency Where IsBaseCurrency=1) ELSE SUB.CultureInfo END) AS CultureInfo,

(Select CultureInfo From PmtCurrency Where IsBaseCurrency=1) AS BaseCultureInfo, A.ExchangeRate,

ISNULL(C.CostingMethod,0) AS CostingMethod,

CASE WHEN C.CostingMethod = 2 THEN

ISNULL((

    SELECT TOP 1 Cost FROM InvProductCost

    WHERE InvProductCost.ProductKey = B.ProductKey

    AND InvProductCost.WarehouseKey IN (G.WarehouseKey,0)

AND ISNULL(InvProductCost.SubsidiaryKey,0) = ISNULL(Sub.SubsidiaryKey,0)

    AND IsDeleted = 0

    AND Convert(VARCHAR,EffectiveDate,112) <= A.BusinessDate

    ORDER BY EffectiveDate DESC

),0)

WHEN C.CostingMethod = 1 THEN

ISNULL((

   B.AverageCost

),0) ELSE 0 END AS Rate

FROM TrxTransaction A

INNER JOIN TrxTransactionSaleItem B ON A.TransactionKey = B.TransactionKey

INNER JOIN InvProduct C ON B.ProductKey = C.ProductKey

INNER JOIN InvProductGroup H ON C.ProductGroupKey = H.ProductGroupKey

INNER JOIN RtlStore D ON A.StoreKey = D.StoreKey

INNER JOIN CusCustomer E ON A.CustomerKey = E.CustomerKey

INNER JOIN CusCustomerGroup F ON E.CustomerGroupKey = F.CustomerGroupKey

INNER JOIN InvWarehouse G ON D.WarehouseKey = G.WarehouseKey

LEFT OUTER JOIN RtlSubsidiary Sub ON G.SubsidiaryKey = Sub.SubsidiaryKey

WHERE

A.IsSuspended = 0 AND A.IsVoided = 0 AND  B.TYPE != 4 --THIS IS DELIVERY AGAINST SALE

AND B.Quantity > 0

See Also

Related Objects

iVend Database Database

 

 


© 2019 All Rights Reserved.

Send comments on this topic.