コード例 #1
0
ファイル: AccountsService.cs プロジェクト: gumiz/finLiteMvc
		public void RewriteAccountsWithLastYear(int clientId, int year)
		{
			var accounts = new List<AccountDao>();
			var oldAccounts = dbContext.Accounts.Where(x => x.ClientId.Equals(clientId) && x.Year.Equals(year-1));
			foreach (var a in oldAccounts)
				accounts.Add(new AccountDao {ClientId = a.ClientId, Year = a.Year+1, Name = a.Name, Description = a.Description});
			foreach (var a in accounts)
				dbContext.Accounts.AddOrUpdate(a);
			dbContext.SaveChanges();
		}
コード例 #2
0
ファイル: OpeningsService.cs プロジェクト: gumiz/finLiteMvc
		public IEnumerable<Opening> GetOpeningsWithoutDoubles(int clientId, int year)
		{
			var openings = _dbContext.Openings.Where(c => c.ClientId.Equals(clientId) && c.Year.Equals(year)).ToList();
			var openingsWithoutDoubles = new List<OpeningDao>();
			foreach (var opening in openings)
			{
				var openingsLike = openings.Where(c => c.CleanName.StartsWith(opening.CleanName));
				if (openingsLike.Count() == 1) openingsWithoutDoubles.Add(opening);
			}
			var result = Converter.ConvertList<OpeningDao, Opening>(openingsWithoutDoubles);
			return result;
		}
コード例 #3
0
ファイル: Program.cs プロジェクト: kianoushkarbasi/wcfrestful
        /// <summary>
        /// List all files inside a folder
        /// </summary>
        /// <param name="path">a path that files need to be parsed</param>
        /// <returns>a list of files need to be parsed</returns>
        private static List<string> listAllFiles(string path)
        {
            List<string> files = new List<string>();
            if (Directory.Exists(path))
            {

                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
                var filesInFolder = dir.GetFiles();
                foreach (System.IO.FileInfo f in filesInFolder)
                {
                    files.Add(f.Name);
                }
            }
            return files;
        }
コード例 #4
0
ファイル: BalanceService.cs プロジェクト: gumiz/finLiteMvc
		private void GetRowsWithValues()
		{
			_result = new List<BalanceReportValues>();

			_documents = _dbContext.Documents.Where(c => c.ClientId.Equals(_clientId) && c.Year.Equals(_year)).ToList();
			AddOpeningsToDocuments(_documents, _year);

			_documentsOld = _dbContext.Documents.Where(c => c.ClientId.Equals(_clientId) && c.Year.Equals(_year - 1)).ToList();
			AddOpeningsToDocuments(_documentsOld, _year - 1);

			_formulas = GetAllItems(_clientId);
			foreach (var formula in _formulas)
			{
				double sum = 0;
				double sumOld = 0;
				if (formula.Formula != null)
				{
					var accounts = UndressFormula(formula.Formula);
					foreach (var decAcc in accounts)
					{
						if (decAcc.Side == null) continue;
						sum += _documents.Where(c => decAcc.Side.Invoke(c).StartsWith(decAcc.Name)).Sum(c => c.Price) * decAcc.Multiplier;
						sumOld += _documentsOld.Where(c => decAcc.Side.Invoke(c).StartsWith(decAcc.Name)).Sum(c => c.Price) *
						          decAcc.Multiplier;
					}
				}
				_result.Add(new BalanceReportValues
				{
					RowId = formula.RowId,
					IsBold = formula.IsBold,
					Number = formula.Number,
					Type = formula.Type,
					Description = formula.Description,
					Balance1 = sumOld,
					Balance2 = sum
				});
			}
		}
コード例 #5
0
ファイル: BalanceService.cs プロジェクト: gumiz/finLiteMvc
		private IList<DecodedAccount> UndressFormula(string formula)
		{
			var result = new List<DecodedAccount>();
			formula = formula.Replace(" ", "");
			var items = formula.ToUpper().Split(',');
			foreach (var item in items)
			{
				var accFormula = item;
				Func<DocumentDao, string> side = null;
				var acc = accFormula;
				var multiplier = 1;
				if (accFormula.Contains("WN") || accFormula.Contains("MA"))
				{
					if (accFormula.StartsWith("-"))
					{
						accFormula = accFormula.Substring(1, accFormula.Length - 1);
						multiplier = -1;
					}
					acc = accFormula.Substring(0, accFormula.Length - 2);
					var s = accFormula.Substring(accFormula.Length - 2, 2);
					if (s.Equals("WN"))
						side = x => x.AccountDt;
					else
						side = x => x.AccountCt;
				}
				result.Add(new DecodedAccount { Name = acc, Side = side, Multiplier = multiplier });
			}
			return result;
		}
コード例 #6
0
ファイル: BalanceService.cs プロジェクト: gumiz/finLiteMvc
		private void AddOpeningsToDocuments(List<DocumentDao> documents, int year)
		{
			var openingsWithoutDoubles = _factory.GetOpeningsService().GetOpeningsWithoutDoubles(_clientId, year);
			foreach (var opening in openingsWithoutDoubles)
			{
				documents.Add(new DocumentDao {AccountDt = opening.Name, AccountCt = "", Price = opening.Dt});
				documents.Add(new DocumentDao {AccountCt = opening.Name, AccountDt = "", Price = opening.Ct});
			}
		}