Example #1
0
        // GET: DefaultRebate/Edit/5
        public ActionResult Edit(int id)
        {
            var vm = Uow.DefaultRebates.GetAll()
                     .Where(d => d.Id == id)
                     .ProjectTo <DefaultRebateModel>()
                     .FirstOrDefault();

            vm.CompanyName    = AttributeProviderSvc.GetCompanyNameFromId(vm.InsuranceProviderId);
            vm.PolicyTypeName = AttributeProviderSvc.GetPolicyTypeNameFromId(vm.PolicyTypeId);

            return(View(vm));
        }
Example #2
0
        public ActionResult Edit(int id, DefaultRebateModel model)
        {
            try
            {
                var entity = AutoMapper.Mapper.Map <DefaultRebate>(model);
                Uow.DefaultRebates.Update(entity);
                Uow.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                var vm = Uow.DefaultRebates.GetAll()
                         .Where(d => d.Id == id)
                         .ProjectTo <DefaultRebateModel>()
                         .FirstOrDefault();

                vm.CompanyName    = AttributeProviderSvc.GetCompanyNameFromId(vm.InsuranceProviderId);
                vm.PolicyTypeName = AttributeProviderSvc.GetPolicyTypeNameFromId(vm.PolicyTypeId);

                return(View(vm));
            }
        }
Example #3
0
        private ReportIndexModel CompTypeYearReport(ReportIndexModel vm)
        {
            vm.CompanyName    = AttributeProviderSvc.GetCompanyNameFromId(vm.InsuranceProviderId);
            vm.PolicyTypeName = AttributeProviderSvc.GetPolicyTypeNameFromId(vm.PolicyTypeId);
            vm.ReportSums     = new ReportSumsModel {
            };

            var list       = new List <ReportGroupedViewModel>();
            var monthQuery = Uow.Invoices.GetAll()
                             .Include(i => i.Particulars.Select(p => p.ParticularType))
                             .Include(i => i.Policy.Client)
                             .Include(i => i.Policy.Agent)
                             .Where(i => i.Policy.InsuranceProviderId == vm.InsuranceProviderId &&
                                    i.Policy.PolicyTypeId == vm.PolicyTypeId &&
                                    i.Status.Name.ToUpper() == "PAID" &&
                                    (i.PaidDate).Year == vm.Year)
                             .ToList()
                             .GroupBy(i => (i.PaidDate).Month);

            foreach (var invoiceGroup in monthQuery)
            {
                var reportList  = new List <ReportViewModel>();
                var invoiceList = invoiceGroup.ToList();
                foreach (var invoice in invoiceList)
                {
                    var reportRow = AutoMapper.Mapper.Map <ReportViewModel>(invoice);

                    if (reportRow.IsOrganization)
                    {
                        reportRow.ClientName = reportRow.OrganizationName;
                    }

                    reportRow.PremiumComponents = new PremiumComponents
                    {
                        Total = invoice.Particulars
                                .Where(p => p.ParticularType.Name == "Premium")
                                .FirstOrDefault()
                                .ParticularAmount
                    };
                    reportRow.TaxComponents = new TaxComponents
                    {
                        Total = invoice.Particulars
                                .Where(p => p.ParticularType.Name != "Premium")
                                .Select(p => p.ParticularAmount)
                                .Sum()
                    };
                    var dstItem = invoice.Particulars
                                  .Where(p => p.ParticularType.Name == "Documentary Stamp Tax (DST)")
                                  .FirstOrDefault();
                    if (dstItem != null)
                    {
                        reportRow.TaxComponents.Dst = dstItem.ParticularAmount;
                    }
                    var vatItem = invoice.Particulars
                                  .Where(p => p.ParticularType.Name == "Value-Added Tax (VAT)")
                                  .FirstOrDefault();
                    if (vatItem != null)
                    {
                        reportRow.TaxComponents.Vat = vatItem.ParticularAmount;
                    }
                    var lgtItem = invoice.Particulars
                                  .Where(p => p.ParticularType.Name == "Local Government Tax (LGT)")
                                  .FirstOrDefault();
                    if (lgtItem != null)
                    {
                        reportRow.TaxComponents.Lgt = lgtItem.ParticularAmount;
                    }
                    var axItem = invoice.Particulars
                                 .Where(p => p.ParticularType.Name == "AX")
                                 .FirstOrDefault();
                    if (axItem != null)
                    {
                        reportRow.TaxComponents.Ax = axItem.ParticularAmount;
                    }
                    var rcharItem = invoice.Particulars
                                    .Where(p => p.ParticularType.Name == "R CHAR")
                                    .FirstOrDefault();
                    if (rcharItem != null)
                    {
                        reportRow.TaxComponents.Rchar = rcharItem.ParticularAmount;
                    }
                    var notarialFeeItem = invoice.Particulars
                                          .Where(p => p.ParticularType.Name == "Notarial Fee")
                                          .FirstOrDefault();
                    if (notarialFeeItem != null)
                    {
                        reportRow.TaxComponents.NotarialFee = notarialFeeItem.ParticularAmount;
                    }
                    var otherFeesItem = invoice.Particulars
                                        .Where(p => p.ParticularType.Name == "Other Fees")
                                        .FirstOrDefault();
                    if (otherFeesItem != null)
                    {
                        reportRow.TaxComponents.OtherFees = otherFeesItem.ParticularAmount;
                    }
                    var fstItem = invoice.Particulars
                                  .Where(p => p.ParticularType.Name == "Fire Service Tax (FST)")
                                  .FirstOrDefault();
                    if (fstItem != null)
                    {
                        reportRow.TaxComponents.Fst = fstItem.ParticularAmount;
                    }
                    var premiumTaxItem = invoice.Particulars
                                         .Where(p => p.ParticularType.Name == "Premium Tax")
                                         .FirstOrDefault();
                    if (premiumTaxItem != null)
                    {
                        reportRow.TaxComponents.PremiumTax = premiumTaxItem.ParticularAmount;
                    }
                    var municipalTaxItem = invoice.Particulars
                                           .Where(p => p.ParticularType.Name == "Municipal Tax")
                                           .FirstOrDefault();
                    if (municipalTaxItem != null)
                    {
                        reportRow.TaxComponents.MunicipalTax = municipalTaxItem.ParticularAmount;
                    }

                    reportRow.SubAgentComponents = new SubAgentComponents
                    {
                        RebateAmount = invoice.Policy.Premium * (decimal)invoice.Rebate
                    };
                    reportRow.PaymentComponents = new PaymentComponents
                    {
                        AmountPaid            = invoice.AmountPaid,
                        PaidDate              = invoice.PaidDate,
                        OfficialReceiptNumber = invoice.ORNumber
                    };
                    if (invoice.HasEWT)
                    {
                        reportRow.PaymentComponents.PrepaidTaxEwt = (invoice.AmountPaid * 0.02M);
                        reportRow.PaymentComponents.Difference    = reportRow.PaymentComponents.PrepaidTaxEwt;
                    }
                    reportRow.CommissionComponents = new CommissionComponents
                    {
                        TotalCommission = invoice.Policy.Commission
                    };

                    reportList.Add(reportRow);

                    //For bottom-row totals
                    vm.ReportSums.SumPremiumOdExcess           += reportRow.PremiumComponents.OdExcess;
                    vm.ReportSums.SumPremiumComplTpl           += reportRow.PremiumComponents.ComplTpl;
                    vm.ReportSums.SumPremiumCgl                += reportRow.PremiumComponents.Cgl;
                    vm.ReportSums.SumPremiumPersonalAccident   += reportRow.PremiumComponents.PersonalAccident;
                    vm.ReportSums.SumPremiumAog                += reportRow.PremiumComponents.Aog;
                    vm.ReportSums.SumPremiumContractorsAllRisk += reportRow.PremiumComponents.ContractorsAllRisk;
                    vm.ReportSums.SumPremiumFire               += reportRow.PremiumComponents.Fire;
                    vm.ReportSums.SumPremiumAlliedPeril        += reportRow.PremiumComponents.AlliedPeril;
                    vm.ReportSums.SumPremiumBurgMoneySec       += reportRow.PremiumComponents.BurgMoneySec;
                    vm.ReportSums.SumPremiumPlateGlass         += reportRow.PremiumComponents.PlateGlass;
                    vm.ReportSums.SumPremiumRsmd               += reportRow.PremiumComponents.Rsmd;
                    vm.ReportSums.SumPremiumTotal              += reportRow.PremiumComponents.Total;
                    vm.ReportSums.SumTaxDst          += reportRow.TaxComponents.Dst;
                    vm.ReportSums.SumTaxVat          += reportRow.TaxComponents.Vat;
                    vm.ReportSums.SumTaxLgt          += reportRow.TaxComponents.Lgt;
                    vm.ReportSums.SumTaxAx           += reportRow.TaxComponents.Ax;
                    vm.ReportSums.SumTaxRchar        += reportRow.TaxComponents.Rchar;
                    vm.ReportSums.SumTaxNotarialFee  += reportRow.TaxComponents.NotarialFee;
                    vm.ReportSums.SumTaxOtherFees    += reportRow.TaxComponents.OtherFees;
                    vm.ReportSums.SumTaxFst          += reportRow.TaxComponents.Fst;
                    vm.ReportSums.SumTaxPremiumTax   += reportRow.TaxComponents.PremiumTax;
                    vm.ReportSums.SumTaxMunicipalTax += reportRow.TaxComponents.MunicipalTax;
                    vm.ReportSums.SumTaxTotal        += reportRow.TaxComponents.Total;
                    vm.ReportSums.SumGrandTotal      += reportRow.GrandTotal;
                    vm.ReportSums.SumAgentRebate     += reportRow.SubAgentComponents.RebateAmount;
                }

                list.Add(new ReportGroupedViewModel
                {
                    Month      = invoiceGroup.Key,
                    ReportList = reportList.OrderBy(i => i.PaidDate).ToList()
                });
            }
            vm.InvoiceByMonthList = list;

            return(vm);
        }