Esempio n. 1
0
        private static decimal?GetPriceForHotWather(AssociationExpenses associationExpense, List <InvoiceSubcategories> invoiceSubcategories)
        {
            decimal? result            = null;
            Invoices invoice           = InvoicesManager.GetByAssociationExpenseForExpense(associationExpense, Expense.ApaRece);
            var      coldWAtherExpense = GetAssociationExpense(associationExpense.Id_Estate, (int)Expense.ApaRece, associationExpense.Year, associationExpense.Month);

            if (invoice != null)
            {
                foreach (var invoiceSubcategory in invoiceSubcategories.Where(i => i.Id_subCategType == (int)InvoiceSubcategoryType.PreparatApaCalda))
                {
                    var assCounter = AssociationCountersManager.GetById(invoiceSubcategory.id_assCounter.Value);
                    foreach (var assCounterStairCase in assCounter.AssociationCountersStairCase)
                    {
                        if (invoiceSubcategory.Value.HasValue && invoiceSubcategory.VAT.HasValue)
                        {
                            var coldWatherUnitPrice        = UnitPricesManager.GetPrice(coldWAtherExpense.Id, assCounterStairCase.Id_StairCase);
                            var invoiceSubcategoryForApaCT = InvoiceIndexesManager.GetByInvoiceAndCounterFirst(invoice, assCounter);

                            if (coldWatherUnitPrice.HasValue && invoiceSubcategoryForApaCT != null && invoiceSubcategoryForApaCT.IndexNew.HasValue && invoiceSubcategoryForApaCT.IndexOld.HasValue)
                            {
                                var difference = invoiceSubcategoryForApaCT.IndexNew.Value - invoiceSubcategoryForApaCT.IndexOld.Value;
                                if (difference != 0)
                                {
                                    var newPricePerUnit = coldWatherUnitPrice + (invoiceSubcategory.Value.Value + invoiceSubcategory.VAT.Value) / difference;
                                    UpdatePricePerUnit(associationExpense.Id, newPricePerUnit, assCounterStairCase.Id_StairCase);
                                    result = newPricePerUnit;
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
        public static void AddDefault(int invoiceId, List <AssociationCounters> assCounters)
        {
            List <int> subcategoryTypes;
            var        invoice = InvoicesManager.GetById(invoiceId);

            if (invoice == null)
            {
                return;
            }

            if (invoice.AssociationExpenses.Id_Expense == (int)Expense.ApaRece)
            {
                subcategoryTypes = new List <int> {
                    1, 2, 3, 4
                };
                AddDefault(invoiceId, subcategoryTypes);
            }
            else if (invoice.AssociationExpenses.Id_Expense == (int)Expense.ApaCalda)
            {
                subcategoryTypes = new List <int> {
                    5, 6
                };
                foreach (AssociationCounters assCounter in assCounters)
                {
                    AddDefault(invoiceId, subcategoryTypes, assCounter.Id);
                }
            }
        }
        public static IEnumerable <Invoices> ConfigureSubcategories(IEnumerable <Invoices> invoices, List <AssociationCounters> counters)
        {
            var result = invoices;

            if (invoices.Any())
            {
                foreach (var invoice in invoices)
                {
                    if (invoice.AssociationExpenses.Id_Expense == (int)Expense.ApaRece)
                    {
                        if (invoice.InvoiceSubcategories.Any())
                        {
                            AddDefault(invoice.Id);
                        }
                    }
                    else if (invoice.AssociationExpenses.Id_Expense == (int)Expense.ApaCalda)
                    {
                        if (invoice.InvoiceSubcategories.Count < counters.Count * 2)
                        {
                            AddDefault(invoice.Id, counters);
                        }
                    }
                }

                result = InvoicesManager.GetByAssociationExpenseId(invoices.FirstOrDefault().Id_EstateExpense.Value);
            }

            return(result);
        }
Esempio n. 4
0
        private static IEnumerable <InvoiceIndexes> GetLastMonthIndexes(int invoiceId)
        {
            var result = new List <InvoiceIndexes>();

            var invoice = InvoicesManager.GetPreviousMonthById(invoiceId);

            if (invoice != null)
            {
                result = invoice.InvoiceIndexes.ToList();
            }

            return(result);
        }
Esempio n. 5
0
        private static string StatusOfInvoices(AssociationExpenses associationExpense, string result, string redistributeValue, string percentage)
        {
            if (associationExpense.ExpenseTypes.Id == (int)ExpenseType.PerIndex)
            {
                if (StatusAllInvoicesHaveValue(associationExpense, 1) && StatusHasAddedAllExpenses(percentage) &&
                    StatusHasRedistributedTheValue(associationExpense, redistributeValue))
                {
                    result = "<i class='fa fa-check'></i> 100%";
                }
                else if (!StatusHasAddedAllExpenses(percentage) && !StatusAllInvoicesHaveValue(associationExpense, 1))
                {
                    result = "Adaugă facturile, cheltuielile individuale! 0%";
                }
                else if (!StatusHasAddedAllExpenses(percentage))
                {
                    result = "Cheltuieli neadăugate! 20%";
                }
                else if (!StatusAllInvoicesHaveValue(associationExpense, 1))
                {
                    result = "Facturi neadăugate! 50%";
                }
                else if (!StatusHasRedistributedTheValue(associationExpense, redistributeValue))
                {
                    result = "Redistribuie cheltuiala! 80%";
                }
            }
            else
            {
                int invoicesNr = InvoicesManager.GetInvoicesNr(associationExpense);
                if (StatusAllInvoicesHaveValue(associationExpense, invoicesNr))
                {
                    result = "<i class='fa fa-check'></i> 100%";
                }
                else
                {
                    result = "Facturi neadăugate! 0%";
                }
            }

            return(result);
        }