public void Test_CreateLedgerRecords_That_Adjustment_Period_Is_Joined_To_Last_Year_Period_And_Is_Exported() { //Arrange var accountHistoryPairs = new[] { new PXResult <Account, GLHistory, AH>(_accountDataContext.AssetAccount, new GLHistory() { FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID }, new AH()), new PXResult <Account, GLHistory, AH>(_accountDataContext.AssetAccount, new GLHistory() { FinPeriodID = _finPeriodDataContext.FinPeriod201504.FinPeriodID }, new AH()) }; GAFRepositoryMock.Setup(repo => repo.GetAccountsWithDataToCalcBeginBalancesExcludingYTDNetIncAcc(_branchDataContext.Branch.BranchID, _branchDataContext.Branch.LedgerID, It.IsAny <string>())) .Returns <int?, int?, string>((b, l, finPeriodID) => accountHistoryPairs.Where(pair => ((GLHistory)pair).FinPeriodID == finPeriodID)); GAFRepositoryMock.Setup(repo => repo.FindLastYearNotAdjustmentPeriod(_finPeriodDataContext.FinPeriod201503.FinYear)) .Returns(_finPeriodDataContext.FinPeriod201503); GAFRepositoryMock.Setup(repo => repo.GetAdjustmentFinPeriods(_finPeriodDataContext.FinPeriod201503.FinYear)) .Returns(_finPeriodDataContext.FinPeriod201504.SingleToArray()); var glTrans = new GLTran[] { new GLTran() { AccountID = _accountDataContext.AssetAccount.AccountID, DebitAmt = 5, CreditAmt = 1, TranDesc = "TranDesc1", TranDate = new DateTime(2015, 1, 1), BatchNbr = "BN0001", RefNbr = "REF0001", Module = BatchModule.AP, ReferenceID = VendorDataContext.VendorID, FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID }, new GLTran() { AccountID = _accountDataContext.AssetAccount.AccountID, DebitAmt = 6, CreditAmt = 3, TranDesc = "TranDesc2", TranDate = new DateTime(2015, 1, 2), BatchNbr = "BN0002", RefNbr = "REF0002", Module = BatchModule.AR, ReferenceID = CustomerDataContext.CustomerID, FinPeriodID = _finPeriodDataContext.FinPeriod201504.FinPeriodID } }; GAFRepositoryMock.Setup(repo => repo.GetPostedGLTrans(_branchDataContext.Branch.BranchID, _branchDataContext.Branch.LedgerID, _accountDataContext.AssetAccount.AccountID, It.IsAny <string>())) .Returns <int?, int?, int?, string>((b, l, a, finPeriodID) => glTrans.Where(glTran => glTran.FinPeriodID == finPeriodID)); //Action var ledgerRecords = _glgafLedgerRecordsCreator.CreateLedgerRecords(_gafPeriodDataContext.GAFPeriod); //Assert Approvals.VerifyAll(ledgerRecords, "ledgerRecords", record => record.Dump()); }
public void Test_CreateLedgerRecords_With_Two_Accounts_And_Two_Trans() { //Arrange var accountHistoryData = new [] { new PXResult <Account, GLHistory, AH>(_accountDataContext.AssetAccount, new GLHistory() { PtdCredit = 1, PtdDebit = 3 }, new AH() { FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID, YtdBalance = 6 }), new PXResult <Account, GLHistory, AH>(_accountDataContext.LiablityAccount, new GLHistory() { PtdCredit = 9, PtdDebit = 2 }, new AH() { FinPeriodID = _finPeriodDataContext.FinPeriod201503.FinPeriodID, YtdBalance = 15 }) }; GAFRepositoryMock.Setup(repo => repo.GetAccountsWithDataToCalcBeginBalancesExcludingYTDNetIncAcc(_branchDataContext.Branch.BranchID, _branchDataContext.Branch.LedgerID, _finPeriodDataContext.FinPeriod201503.FinPeriodID)) .Returns(accountHistoryData); var glTrans = new GLTran[] { new GLTran() { AccountID = _accountDataContext.AssetAccount.AccountID, DebitAmt = 5, CreditAmt = 1, TranDesc = "TranDesc1", TranDate = new DateTime(2015, 1, 1), BatchNbr = "BN0001", RefNbr = "REF0001", Module = BatchModule.AP, ReferenceID = VendorDataContext.VendorID }, new GLTran() { AccountID = _accountDataContext.AssetAccount.AccountID, DebitAmt = 6, CreditAmt = 3, TranDesc = "TranDesc2", TranDate = new DateTime(2015, 1, 2), BatchNbr = "BN0002", RefNbr = "REF0002", Module = BatchModule.AR, ReferenceID = CustomerDataContext.CustomerID }, new GLTran() { AccountID = _accountDataContext.LiablityAccount.AccountID, DebitAmt = 9, CreditAmt = 15, TranDesc = "TranDesc3", TranDate = new DateTime(2015, 1, 3), BatchNbr = "BN0003", RefNbr = "REF0003", Module = BatchModule.SO, ReferenceID = CustomerDataContext.CustomerID }, new GLTran() { AccountID = _accountDataContext.LiablityAccount.AccountID, DebitAmt = 20, CreditAmt = 7, TranDesc = "TranDesc4", TranDate = new DateTime(2015, 1, 4), BatchNbr = "BN0004", RefNbr = "REF0004", Module = BatchModule.PO, ReferenceID = VendorDataContext.VendorID } }; GAFRepositoryMock.Setup(repo => repo.GetPostedGLTrans(_branchDataContext.Branch.BranchID, _branchDataContext.Branch.LedgerID, It.IsAny <int?>(), _finPeriodDataContext.FinPeriod201503.FinPeriodID)) .Returns <int?, int?, int?, string>((b, l, accountID, fp) => glTrans.Where(glTran => glTran.AccountID == accountID)); //Action var ledgerRecords = _glgafLedgerRecordsCreator.CreateLedgerRecords(_gafPeriodDataContext.GAFPeriod); //Assert Approvals.VerifyAll(ledgerRecords, "ledgerRecords", record => record.Dump()); }