// ------------------------------------------------ /// <summary> /// Calculate the Commissions for a given /// transaction. /// </summary> /// <param name="transactionID"></param> /// <returns></returns> public static TransactionCommission GetCommission(int transactionID) { TransactionCommission retVal = new TransactionCommission() { TransactionID = transactionID }; // ---------------------------------------------------------- // Find data in the Accounting Tables based on Transaction ID Transaction transaction = new Transaction(transactionID); // ------------------------------------------------ // For now, fake it. But this will come from the DB ProductCommission prodComm = new ProductCommission(transaction.ProductID, transaction.BinID, transaction.TransactionDate); // ----------------------------------- // Perform the Calculation and set the // properties on the return object. retVal.BinID = prodComm.BinID; retVal.TransactionID = transactionID; retVal.ProductID = prodComm.ProductID; retVal.CommissionAmount = (double)transaction.UnitCount * prodComm.CommissionFactor; return retVal; }
public void ProductCommission() { int binID = Convert.ToInt32(TestContext.DataRow["BinID"]); int productID = Convert.ToInt32(TestContext.DataRow["ProductID"]); DateTime transactionDate = Convert.ToDateTime(TestContext.DataRow["TransactionDate"]); ProductCommission prodCom = new ProductCommission(productID, binID, transactionDate); Assert.AreEqual(binID, prodCom.BinID); Assert.AreEqual(productID, prodCom.ProductID); }