Пример #1
0
        public static byte[] GenerateFondsReport(int apartmentId, DebtType debtType)
        {
            var     stringFormatH1 = "<h1>{0}</h1>";
            var     stringFormatH2 = "<h2>{0}</h2>";
            var     nrCrt          = 0;
            decimal rulajIncome    = 0;
            decimal rulajOutcome   = 0;
            var     sb             = new StringBuilder();

            var apartament = ApartmentsManager.GetById(apartmentId);

            if (apartament == null)
            {
                return(ConverterHelper.ConvertHtMLtoBytes(sb.ToString()));
            }

            var debts = ApartmentDebtsManager.GetAllPaidOfType(apartmentId, debtType);

            if (debtType == DebtType.RulmentFond && apartament.FondRulment.HasValue)
            {
                sb.Append(string.Format(stringFormatH1, "Fisa fond de rulment "));
                sb.Append(string.Format(stringFormatH2, "Suma disponibila in fondul de rulment: " + apartament.FondRulment));
            }
            else if (debtType == DebtType.Repairfond && apartament.FondReparatii.HasValue)
            {
                sb.Append(string.Format(stringFormatH1, "Fisa fond de reparații "));
                sb.Append(string.Format(stringFormatH2, "Suma disponibila in fondul de reparatii: " + apartament.FondReparatii));
            }

            sb.Append("<br><br>");
            sb.Append("<table border='1'>");
            sb.Append("<tr>");
            sb.Append("<td>Nr Crt</td><td>Data</td><td>Explicații</td><td>Încasat</td><td>Restituit</td><td>Sold contabil</td><td>Sold restant</td>");
            sb.Append("</tr>");

            foreach (var debt in debts)
            {
                nrCrt++;
                var income      = (debt.Value.HasValue) ? debt.Value.Value.ToString() : string.Empty;
                var createdDate = (debt.created.HasValue) ? debt.created.Value.ToShortDateString() : string.Empty;

                sb.Append("<tr>");
                sb.Append("<td>" + nrCrt + "</td>");
                sb.Append("<td>" + createdDate + "</td>");
                sb.Append("<td>" + debt.Year + " " + debt.Month + "</td>");
                sb.Append("<td>" + income + "</td>");
                sb.Append("<td>" + "- </td>");
                sb.Append("<td>" + "</td>");
                sb.Append("<td>" + "</td>");
                sb.Append("</tr>");
            }

            sb.Append("</table>");
            sb.Append("<br><br>");

            return(ConverterHelper.ConvertHtMLtoBytes(sb.ToString()));
        }
Пример #2
0
        internal static void CalculateAndAddAll(int associationId, int year, int month)
        {
            var apartments = ApartmentsManager.GetByAssociationId(associationId);
            var debtTypes  = GetAllTypes();

            foreach (var apartment in apartments)
            {
                foreach (var debtType in debtTypes)
                {
                    decimal?value = GetValue(apartment, year, month, debtType);
                    Add(apartment.Id, debtType.Id, year, month, value);
                }
            }
        }
Пример #3
0
        public static void ConfigurePerIndex(Associations association, int year, int month)
        {
            IEnumerable <Expenses> allExpenses = ExpensesManager.GetAllExpenses();
            var associationExpenses            = GetByMonthAndYearNotDisabled(association.Id, year, month);

            foreach (Expenses expense in allExpenses)
            {
                var associationExpense = associationExpenses.FirstOrDefault(ea => ea.Id_Expense == expense.Id);
                if (associationExpense != null)
                {
                    var apartments = ApartmentsManager.GetAllThatAreRegisteredWithSpecificCounters(association.Id, associationExpense.Id);
                    ApartmentExpensesManager.ConfigurePerIndex(associationExpense, apartments);
                }
            }
        }
Пример #4
0
        public static void Pay(int apartmentId, List <Tuple <int, int, int, decimal, decimal?> > debtsList)
        {
            foreach (var tuple in debtsList)
            {
                if (tuple.Item3 == (int)DebtType.AdvancePay)
                {
                    Add(apartmentId, tuple.Item3, tuple.Item1, tuple.Item2, tuple.Item4);
                }

                if (tuple.Item3 == (int)DebtType.Repairfond || tuple.Item3 == (int)DebtType.RulmentFond)
                {
                    ApartmentsManager.UpdateFonds(apartmentId, (DebtType)tuple.Item3, tuple.Item4);
                }

                var apDebt = Get(apartmentId, tuple.Item1, tuple.Item2, (DebtType)tuple.Item3);
                if (apDebt == null)
                {
                    continue;
                }

                if (tuple.Item5.HasValue)
                {
                    apDebt.IsPayed        = false;
                    apDebt.RemainingToPay = tuple.Item5.Value;
                    GetContext().Entry(apDebt).CurrentValues.SetValues(apDebt);

                    GetContext().SaveChanges();
                }
                else if (apDebt.Value == tuple.Item4)
                {
                    apDebt.IsPayed = true;
                    GetContext().Entry(apDebt).CurrentValues.SetValues(apDebt);

                    GetContext().SaveChanges();
                }
            }
        }