Beispiel #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()));
        }
Beispiel #2
0
 public static void ConfigureOpenCloseMonth(int associationId, int year, int month, bool shouldClose = true)
 {
     OpenCloseMonth(associationId, year, month, shouldClose);
     if (shouldClose)
     {
         // add/edit
         ApartmentDebtsManager.CalculateAndAddAll(associationId, year, month);
     }
     else
     {
         //remove
     }
 }
Beispiel #3
0
        public static void RegisterPay(decimal sumOfChecked, decimal totalToPay, int apartmentId, List <string> whatToPay, string documentNr,
                                       string explanations, string partiallyPay, int associationId, DateTime addedDate)
        {
            int?dailyRegId = null;
            var dailyReg   = RegistriesHomeDailyManager.Get(associationId, addedDate);

            if (dailyReg == null)
            {
                dailyRegId = RegistriesHomeDailyManager.Add(new DAL.RegistriesHomeDaily
                {
                    Id_association  = associationId,
                    TransactionDate = addedDate
                });
            }
            else
            {
                dailyRegId = dailyReg.Id;
            }

            if (!dailyRegId.HasValue)
            {
                return;
            }
            //update all RegistriesHomeDaily from that day
            RegistriesHomeDailyManager.RefreshOpenClosePricesFromDate(dailyRegId.Value);

            Add(new Administratoro.DAL.RegistriesHome
            {
                Id_apartment    = apartmentId,
                Income          = totalToPay,
                DocumentNr      = documentNr,
                Outcome         = null,
                Id_RegHomeDaily = dailyRegId,
                CreatedDate     = DateTime.Now,
                Explanations    = explanations,
            });

            var apDebts = GetAllCheckedApDebts(whatToPay);

            // mark ApartmentDebts as payed„
            if (sumOfChecked < totalToPay)
            {
                // advance in avans
                apDebts.Add(new Tuple <int, int, int, decimal, decimal?>(
                                DateTime.Now.Year,
                                DateTime.Now.Month,
                                (int)DebtType.AdvancePay,
                                totalToPay - sumOfChecked,
                                null));
            }
            else if (sumOfChecked > totalToPay)
            {
                // partially pay
                var     items = partiallyPay.Split('!');
                int     year;
                int     month;
                int     type;
                decimal value;
                if (items.Length == 4 && decimal.TryParse(items[3], out value) && int.TryParse(items[0], out year) &&
                    int.TryParse(items[1], out month) && int.TryParse(items[2], out type))
                {
                    apDebts.Add(new Tuple <int, int, int, decimal, decimal?>(year, month, type, value, sumOfChecked - totalToPay));
                }
            }

            ApartmentDebtsManager.Pay(apartmentId, apDebts);
        }