Пример #1
0
        public static void UpdateFonds(int apartamentId, DebtType debtType, decimal amount)
        {
            var result = GetContext().Apartments.FirstOrDefault(b => b.Id == apartamentId);

            if (result != null)
            {
                if (debtType == DebtType.RulmentFond)
                {
                    if (result.FondRulment == null)
                    {
                        result.FondRulment = 0m;
                    }
                    result.FondRulment = result.FondRulment + amount;
                }
                else if (debtType == DebtType.Repairfond)
                {
                    if (result.FondReparatii == null)
                    {
                        result.FondReparatii = 0m;
                    }
                    result.FondReparatii = result.FondReparatii + amount;
                }

                GetContext().Entry(result).CurrentValues.SetValues(result);

                GetContext().SaveChanges();
            }
        }
Пример #2
0
        public OperationResult Create(DebtType debtType, long referenceUserId, decimal amount, string description)
        {
            try
            {
                using (YomContainer container = GetYomContainer())
                {
                    Item item = container.Items.Add(new Item
                    {
                        Type = (short)debtType,
                        UserId = UserService.UserGetCurrent().Id,
                        OweItem = new OweItem
                        {
                            Amount = amount,
                            ReferenceUser = referenceUserId,
                            Description = description,
                        }
                    });

                    container.SaveChanges();
                }

                return OperationResult.Success;
            }
            catch (Exception e)
            {
                return OperationResult.Error(e.Message);
            }
        }
Пример #3
0
        public async Task CreateDebtAsync(Debt debt, DebtType debtType)
        {
            var classInstallments = new InstallmentsContext();

            if (debtType == DebtType.Card)
            {
                debt.Date = CardRules.CardDateRule(debt.Card.ClosureDate, debt.Card.DueDate, debt).Date;
            }

            // TODO ver forma de fazer isso melhor

            if (debt.DebtInstallmentType == DebtInstallmentType.Simple)
            {
                classInstallments.SetStrategy(new CreateSimpleInstallments());
            }
            else if (debt.DebtInstallmentType == DebtInstallmentType.Fixed)
            {
                classInstallments.SetStrategy(new CreateFixedInstallments());
            }
            else if (debt.DebtInstallmentType == DebtInstallmentType.Installment)
            {
                classInstallments.SetStrategy(new CreateInstallments());
            }

            var installments = classInstallments.CreateInstallments(debt);

            debt.Installments = installments;
            debt.Id           = Guid.NewGuid();
            debt.CreatedAt    = DateTime.Now;
            debt.DebtType     = debtType;

            await _debtRepository.AddAsync(debt);
        }
Пример #4
0
 private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxType.SelectedIndex != (int)debtType)
     {
         debtType = (DebtType)comboBoxType.SelectedIndex;
         OnDebtPropertiesChanged();
     }
 }
Пример #5
0
 /// <summary>
 /// Получить список строк задолженностей.
 /// </summary>
 /// <param name="type">Тип задолженности</param>
 /// <param name="month">Месяц</param>
 /// <param name="year">Год</param>
 /// <returns>Список строк задолженностей</returns>
 public static IList <DebtRow> GetDebtRows(DebtType type, int month, int year)
 {
     CheckInitialization();
     return(session.CreateCriteria(typeof(DebtRow)).
            Add(Expression.Eq("DebtType", type)).
            Add(Expression.Eq("Month", month)).
            Add(Expression.Eq("Year", year)).
            List <DebtRow>());
 }
Пример #6
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()));
        }
Пример #7
0
 /// <summary>
 /// Получить список строк задолженностей.
 /// </summary>
 /// <param name="type">Тип задолженности</param>
 /// <param name="month">Месяц</param>
 /// <param name="year">Год</param>
 /// <param name="budget">Бюджет</param>
 /// <returns>Список строк задолженностей</returns>
 public static IList <DebtRow> GetDebtRows(DebtType type, int month, int year, string budgetName)
 {
     CheckInitialization();
     return(session.CreateQuery("from DebtRow r where DebtType = ? and Month = ? and Year = ? and r.Subject.BudgetName = ?").
            SetInt32(0, (Int32)type).
            SetInt32(1, month).
            SetInt32(2, year).
            SetString(3, budgetName).
            List <DebtRow>());
 }
Пример #8
0
        public Report1ParamForm(DebtType type, int month, int year)
        {
            InitializeComponent();
            DebtProperties.DebtType = type;
            DebtProperties.Month    = month;
            DebtProperties.Year     = year;

            comboBoxBudgetName.Items.Add("<Все бюджеты>");
            comboBoxBudgetName.Items.AddRange(DebtDAO.GetBudgets());
            comboBoxBudgetName.SelectedIndex = 0;
        }
Пример #9
0
        private HouseholdDebtTracker.DAL.Models.DebtType MapToDALDebtType(DebtType type)
        {
            switch (type)
            {
            case DebtType.Loan:
                return(HouseholdDebtTracker.DAL.Models.DebtType.Loan);

            default:
                return(HouseholdDebtTracker.DAL.Models.DebtType.Repayment);
            }
        }
Пример #10
0
        /// <summary>
        /// Создает экземпляр контрола для редактирования свойств строк задолженности.
        /// </summary>
        public DebtPropertiesControl()
            : base()
        {
            InitializeComponent();

            debtType = DebtType.Кредиторская;
            month    = DateTime.Today.Month;
            year     = DateTime.Today.Year;
            comboBoxType.SelectedIndex  = 0;
            comboBoxMonth.SelectedIndex = 0;
            numericUpDownYear.Value     = year;
        }
Пример #11
0
        public void SetDebtProperties(DebtType type, int month, int year)
        {
            debtType = type;
            comboBoxType.SelectedIndex = (int)debtType;

            this.month = month;
            comboBoxMonth.SelectedIndex = month - 1;

            this.year = year;
            numericUpDownYear.Value = year;

            OnDebtPropertiesChanged();
        }
Пример #12
0
        public DebtCopyForm(DebtType fromDebtType, int fromMonth, int fromYear)
        {
            InitializeComponent();

            DebtPropertiesFrom.DebtType = fromDebtType;
            DebtPropertiesFrom.Month    = fromMonth;
            DebtPropertiesFrom.Year     = fromYear;

            DebtPropertiesTo.DebtType = fromDebtType;
            var date = new DateTime(fromYear, fromMonth, 1).AddMonths(1);

            DebtPropertiesTo.Month = date.Month;
            DebtPropertiesTo.Year  = date.Year;
        }
Пример #13
0
        public void ShowReport(DebtType type, int month, int year)
        {
            var reportParam = new Report1ParamForm(type, month, year);

            if (reportParam.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            type  = reportParam.DebtProperties.DebtType;
            month = reportParam.DebtProperties.Month;
            year  = reportParam.DebtProperties.Year;

            string reportCaption = string.Format("Отчет по {0} задолженности за {1} месяц {2} года", (type == DebtType.Кредиторская ? "кредиторской" : "дебиторской"), DebtUtil.GetMonthName(month).ToLower(), year);
            string reportName    = (reportParam.GroupBySubjects ? reportName = "CI.Debt.Reports.Report1.rdlc" : "CI.Debt.Reports.Report2.rdlc");

            var reportForm = new ReportForm();

            reportForm.Text = reportCaption;
            reportForm.reportViewer.LocalReport.ReportEmbeddedResource = reportName;
            reportForm.reportViewer.LocalReport.DisplayName            = reportCaption;
            reportForm.reportViewer.LocalReport.SetParameters(new[] { new ReportParameter("pCaption", reportCaption) });

            reportForm.Show();


            IList <DebtRow> rows = null;

            if (reportParam.GroupBySubjects && 0 < reportParam.comboBoxBudgetName.SelectedIndex)
            {
                rows = DebtDAO.GetDebtRows(type, month, year, (string)reportParam.comboBoxBudgetName.SelectedItem);
            }
            else
            {
                rows = DebtDAO.GetDebtRows(type, month, year);
            }
            var reportRows = new List <Report1Row>();

            foreach (var row in rows)
            {
                reportRows.Add(new Report1Row(row));
            }

            reportForm.reportViewer.LocalReport.DataSources.Add(new ReportDataSource("Report1Row", reportRows));
            reportForm.reportViewer.RefreshReport();

            reportForm.reportViewer.SetDisplayMode(DisplayMode.PrintLayout);
            reportForm.reportViewer.ZoomMode    = ZoomMode.Percent;
            reportForm.reportViewer.ZoomPercent = 100;
        }
 public AmortizationEntry( string debtName,  
                       DebtType debtType,
                             DateTime date, 
                             double startBalance,  
                             double interest, 
                             double minPrincipal,  
                             double addPrincipal, 
                             double endBalance)
 {
     DebtName = debtName;
       DebtType = debtType;
       Date = date;
       StartBalance = startBalance;
       MinimumInterest = interest;
       MinimumPrincipal = minPrincipal;
       AdditionalPrincipal = addPrincipal;
       TotalPayment = interest + minPrincipal + addPrincipal;
       EndBalance = endBalance;
 }
Пример #15
0
        /// <summary>
        /// Копировать строки из одной задолженности в другую.
        /// </summary>
        /// <param name="fromDebtType">Тип задолженности откуда копировать.</param>
        /// <param name="fromMonth">Месяц задолженности откуда копировать.</param>
        /// <param name="fromYear">Год задолженности откуда копировать.</param>
        /// <param name="toDebtType">Тип задолженности куда копировать.</param>
        /// <param name="toMonth">Месяц задолженности куда копировать.</param>
        /// <param name="toYear">Год задолженности куда копировать.</param>
        public static void CopyDebtRows(
            DebtType fromDebtType, int fromMonth, int fromYear,
            DebtType toDebtType, int toMonth, int toYear)
        {
            CheckInitialization();
            var fromRows = GetDebtRows(fromDebtType, fromMonth, fromYear);

            using (var tx = session.BeginTransaction()) {
                foreach (var fromRow in fromRows)
                {
                    var row = (DebtRow)fromRow.Clone();
                    row.DebtType = toDebtType;
                    row.Month    = toMonth;
                    row.Year     = toYear;

                    session.Save(row);
                }
                tx.Commit();
            }
        }
Пример #16
0
 internal static IEnumerable <ApartmentsDebt> GetAllUnpaiedOfType(Apartments apartment, int year, int month,
                                                                  DebtType debtType)
 {
     return(GetContext(true).ApartmentsDebt.Where(ad => ad.Id_debtType == (int)debtType &&
                                                  ad.Id_Apartament == apartment.Id && ad.Year <= year && ad.Month <= month && !ad.IsPayed));
 }
Пример #17
0
 internal static IEnumerable <ApartmentsDebt> GetAllPaidOfType(int apartmentId, DebtType debtType)
 {
     return(GetContext(true).ApartmentsDebt.Where(ad => ad.Id_debtType == (int)debtType &&
                                                  ad.Id_Apartament == apartmentId && ad.IsPayed));
 }
Пример #18
0
 public static ApartmentsDebt Get(int apartmentId, int year, int month, DebtType debtType)
 {
     return(GetContext(true).ApartmentsDebt.FirstOrDefault(a => a.Id_Apartament == apartmentId &&
                                                           a.Year == year && a.Month == month &&
                                                           a.Id_debtType == (int)debtType));
 }