Ejemplo n.º 1
0
    def test_totalRetailForAllBySKU2(self):
        # note the nature of a salesAddBehavior totals retail of SKU by default
        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_2016-01-16_to_2016-01-22.csv")

        assert sold['602'].retail == 0  # calculated manually
        assert sold['6477'].retail == -3588  # calculated manually
 def test_stockException(self):
     # can define custom exception at a later stage if desired
     inv = StoreInventory()
     inv.addProductsCSV("./csvs/emptyStock.csv")
     sales = SalesProductList()
     sales.addProductsCSV("./csvs/stock-sales_TEST.csv")
     with pytest.raises(Exception):
         inv.addSales(sales)
Ejemplo n.º 3
0
    def test_totalSalesBySKU2(self):

        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_2016-01-16_to_2016-01-22.csv")

        assert sold['602'].totalCost == 0
        assert sold['602'].count == -12

        assert sold['6477'].totalCost == -1140
        assert sold['602'].count == -12
    def test_readAndSum(self):

        sold=SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_TEST.csv")
        
        eA = Product()
        eA.setAddStyle(SalesAddBehavior())
        eA=eA.addStyle.addItem(eA, -4, 5, 10) #calculated manually

        assert sold['602'].totalCost == eA.totalCost
        assert sold['602'].count == eA.count
        assert sold['602'].retail == eA.retail
Ejemplo n.º 5
0
    def test_totalSalesBySKU(self):

        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_TEST.csv")

        eA = Product()
        eA.setAddStyle(behavior_accumulate_retail())
        eA = eA.addStyle.addItem(eA, -6, 5, 10)  # calculated manually

        assert sold['602'].totalCost == eA.totalCost
        assert sold['602'].count == eA.count
        assert sold['602'].retail == eA.retail

        assert sold['602'].totalCost == -30
        assert sold['602'].count == -6
        assert sold['602'].retail == -60
    def test_weightedUnitPrice(self):

        inv = StoreInventory()
        # to calculate the accumulative  retail available, set addBehavior to
        # salesAddBehaviour (this behavior may be renamed to
        # accumulativeRetailBehaviour)
        inv.setAddStyle(behavior_accumulate_retail())
        inv.addProductsCSV("./csvs/trendTest/ifix-stock_trendTest.csv")

        orders = OrdersList()
        orders.addProductsCSV("./csvs/trendTest/stock-purchases_trendTest.csv")

        sales = SalesProductList()
        sales.addProductsCSV("./csvs/trendTest/stock-sales_trendTest.csv")

        inv.addOrders(orders)
        wUnitCost = inv.getWeightedUnitCost("6691")

        # rounding is required at the last moment so errors do not accumulate

        assert round(wUnitCost, 2) == 89.61
        assert round(sales["6691"].count * wUnitCost, 2) == -358.43
        inv.addSales(sales)
        assert round(inv["6691"].count * wUnitCost, 2) == 806.47
Ejemplo n.º 7
0
    def test_totalRetailForAllBySKU(self):
        # note the nature of a salesAddBehavior totals retail of SKU by default
        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_TEST.csv")

        assert sold['602'].retail == -60  # calculated manually
Ejemplo n.º 8
0
    def test_allGoodsSold2(self):

        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_2016-01-16_to_2016-01-22.csv")
        # note cost to the company is negative ie: a profit was made
        assert sold.costAll() == -128717.46  # calculated manually
Ejemplo n.º 9
0
    def test_allGoodsSold(self):

        sold = SalesProductList()
        sold.addProductsCSV("./csvs/stock-sales_TEST.csv")
        # note cost to the company is negative ie: a profit was made
        assert sold.costAll() == -55  # calculated manually
Ejemplo n.º 10
0
Created on 24 Jan 2016

@author: Craig
'''
from product import Product
from salesProductList import SalesProductList
from storeInventory import StoreInventory
from ordersList import OrdersList


if __name__ == '__main__':
    inv=StoreInventory()
    inv.addProductsCSV("./csvs/ifix-stock_2016-01-22.csv")
 
 
    sales=SalesProductList()
    sales.addProductsCSV("./csvs/stock-sales_TEST.csv")
    print sales["602"].totalCost
    print sales["602"].retail
    print sales["602"].count
     
    orders=OrdersList()
    orders.addProductsCSV("./csvs/stock-purchases_TESTsmall.csv")
     
 
    inv.addOrders(orders)
    inv.addSales(sales)
#     
    
    #--Stock--
    #total quantity of SKU item in stock