public TempLedger PostToTempLedger(int ItemID, int UnitID, int ManufacturerID, int AccountID, decimal UnitCost, decimal Margin, decimal SellingPrice,ChangeType changeType)
 {
     TempLedger Ledger = GetTempLedger(ItemID, UnitID, ManufacturerID, AccountID);
     Ledger.UnitCost = UnitCost;
     Ledger.Margin = Margin;
     Ledger.SellingPrice = SellingPrice;
     Ledger.ChangeType = changeType.Id;
     Ledger.IsConfirmed = false;
     return Ledger;
 }
 public void Record(string identifier, int itemID, int unitID, int ManufacturerID, int AccountID, decimal UnitCost, decimal Margin, decimal SellingPrice, int UserID, ChangeType changeType)
 {
     JournalEntry = new HCMIS.Concrete.Models.JournalLite()
                       {
                           Identifier = identifier,
                           Description = changeType.Description,
                           Margin = Margin,
                           UnitCost = UnitCost,
                           SellingPrice = SellingPrice,
                           UserID = UserID,
                           Ledger = LedgerService.PostToTempLedger(itemID, unitID, ManufacturerID, AccountID, UnitCost, Margin, SellingPrice,changeType)
                       };
        repository.JournalLites.Insert(JournalEntry);
 }
        public static void SavePriceChange(IEnumerable<CostElement> costElements, int userId,ChangeType changeType,string identifier = "")
        {
            var journalService = new JournalService();
            journalService.StartRecordingSession();

            foreach (var costElement in costElements)
            {
                journalService.Record(identifier, costElement.ItemID, costElement.ItemUnitID,
                                      costElement.ManufacturerID, costElement.MovingAverageID,
                                      Convert.ToDecimal(costElement.AverageCost),
                                      Convert.ToDecimal(costElement.Margin),
                                      Convert.ToDecimal(costElement.SellingPrice), userId, changeType);
            }

            journalService.CommitRecordingSession();
        }
        public void Confirm(string identifier, int itemId, int unitId, int manufacturerId, int accountId, decimal unitCost, decimal margin, decimal sellingPrice, int userId, ChangeType changeType)
        {
            TempLedger ledger = LedgerService.GetTempLedger(itemId, unitId, manufacturerId, accountId);
               if (ValidationService.ValidateLedger(ledger, unitCost, margin, sellingPrice))
               {

               JournalEntry = new HCMIS.Concrete.Models.JournalLite()
                              {
                                  Identifier = identifier,
                                  Description = changeType.Description,
                                  Margin = margin,
                                  UnitCost = unitCost,
                                  SellingPrice = sellingPrice,
                                  UserID = userId,
                                  Ledger = ledger
                              };
               repository.JournalLites.Insert(JournalEntry);
               LedgerService.PostToLedger(ledger);

               }
        }
 public void SavePrice(int userID, string identifier, IJournalService journalService, ChangeType changeType)
 {
     journalService.Record(identifier, ItemID, ItemUnitID, ManufacturerID, MovingAverageID, Convert.ToDecimal(AverageCost), Convert.ToDecimal(Margin), Convert.ToDecimal(SellingPrice), userID, changeType);
 }