private void BtnOkClick(object sender, EventArgs e) { RefreshUI(); if (!btnOk.Enabled) { DialogResult = DialogResult.None; return; } using (var context = new DataClassesDataContext()) { var paymentPeriod = new PaymentPeriod { Year = Year, Month = Month }; context.PaymentPeriods.InsertOnSubmit(paymentPeriod); context.SubmitChanges(); } if (MessageBox.Show(this, string.Format("Расчетный период за {0} создан.\r\nВы хотите сформировать начисления?", UIHelper.PeriodToString(Year, Month)), "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { using (var context = new DataClassesDataContext()) { CalcHelper.MakePayments(context, Year, Month); } } }
//Constructor public EmployeeRecordsMapping() { AutoMap(); //Convert payment date time to payment period. Map(s => s.PaymentStartDate).ConvertUsing(x => { string date = x.GetField(PaymentStartDateField); PaymentPeriod.TryParseFromDateRangeString(date, out var paymentPeriod); return(paymentPeriod); } ); //Trim % from inpout record and return percentage. Map(x => x.SuperRate).ConvertUsing(x => { string superRate = x.GetField(SuperRateField); string trimmedValue = superRate.Trim('%'); if (Decimal.TryParse(trimmedValue, out decimal result)) { return(result / 100); } throw new InvalidCastException("Unable to parse Super Rate field - Unrecognized Value : " + superRate); } ); }
public Employee(string firstName, string lastName, decimal annualSalary, decimal superRate, PaymentPeriod paymentStartDate) { FirstName = firstName; LastName = lastName; AnnualSalary = annualSalary; SuperRate = superRate; PaymentStartDate = paymentStartDate; }
private void AddAdditionalNeed(decimal cost, PaymentPeriod period) { _package.Details.Add(new CarePackageDetail { Cost = cost, Type = PackageDetailType.AdditionalNeed, CostPeriod = period, StartDate = _startDate, EndDate = _endDate }); }
public void PeriodTest() { PaymentPlan target = new PaymentPlan(); // TODO: Initialize to an appropriate value PaymentPeriod expected = new PaymentPeriod(); // TODO: Initialize to an appropriate value PaymentPeriod actual; target.Period = expected; actual = target.Period; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
private async Task <int> CreatePaymentPeriod(PaymentPeriodDetailCommand item, PaymentPeriodHeaderCommand message, int c, EntityStatus paymentPeriodPayed) { var entityToSave = new PaymentPeriod(); if (item.TableStatus == Application.DTOs.Requests.Common.ObjectStatus.Added) { entityToSave = new PaymentPeriod(); entityToSave.PaymentPeriodId = c; entityToSave.ConceptId = item.ConceptId; entityToSave.ContractId = item.ContractId; entityToSave.TenantId = item.TenantId; entityToSave.PeriodId = item.PeriodId; entityToSave.PaymentAmount = item.PaymentAmount; entityToSave.DueDate = item.DueDate; entityToSave.RowStatus = true; entityToSave.Creation(message.UserId); if (paymentPeriodPayed != null) { entityToSave.PaymentPeriodStatusId = paymentPeriodPayed.EntityStatusId; entityToSave.PaymentDate = DateTime.Now; } entityToSave.PaymentTypeId = item.PaymentTypeId; entityToSave.Comment = !string.IsNullOrEmpty(item.Comment) ? item.Comment : message.Comment; entityToSave.ReferenceNo = message.ReferenceNo; entityToSave.PaymentDate = DateTime.Now;; entityToSave.Update(message.UserId); _repositoryPayment.Add(entityToSave); return(c); } else { entityToSave = new PaymentPeriod(); entityToSave = await _repositoryPayment.FirstOrDefaultAsync(q => q.PaymentPeriodId == item.PaymentPeriodId); if (entityToSave != null) { entityToSave.PaymentAmount = item.PaymentAmount; if (paymentPeriodPayed != null) { entityToSave.PaymentPeriodStatusId = paymentPeriodPayed.EntityStatusId; entityToSave.PaymentDate = DateTime.Now; } entityToSave.ReferenceNo = message.ReferenceNo; entityToSave.Comment = message.Comment; entityToSave.Update(message.UserId); _repositoryPayment.UpdatePartial(entityToSave, new string[] { "PaymentPeriodId", "PaymentAmount", "PaymentPeriodStatusId", "PaymentDate", "ReferenceNo", "Comment", "UpdatedBy", "UpdatedDate" }); } return(entityToSave.PaymentPeriodId.Value); } }
/// <summary> /// Converts the value of the specified <see cref="PaymentPeriod"/> to its equivalent <see cref="String"/> representation. /// </summary> /// <param name="period">A payment period.</param> /// <returns>The <see cref="String"/> equivalent of the value of <paramref name="period"/>.</returns> public static string ToString(PaymentPeriod period) { switch (period) { case PaymentPeriod.Annual: return("Annual"); case PaymentPeriod.Monthly: return("Monthly"); case PaymentPeriod.Quarterly: return("Quarterly"); case PaymentPeriod.SemiAnnual: return("Semi-Annal"); default: return(string.Empty); } }
public static List <CarePackageDetail> CreateCarePackageDetails(int count, PackageDetailType type, PaymentPeriod costPeriod = PaymentPeriod.Weekly) { return(new Faker <CarePackageDetail>() .RuleFor(r => r.Cost, f => Math.Round(f.Random.Decimal(100m, 1000m), 2)) // Workaround to avoid precision loss in SQLite) /*.RuleFor(d => d.CostPeriod, f => type == PackageDetailType.CoreCost * ? PaymentPeriod.Weekly * : f.PickRandom(PaymentPeriod.Weekly, PaymentPeriod.OneOff))*/ .RuleFor(d => d.CostPeriod, costPeriod) .RuleFor(d => d.StartDate, f => f.Date.Past().Date) .RuleFor(d => d.EndDate, f => f.Date.Future().Date) .RuleFor(d => d.Type, type) .Generate(count)); }
// ReSharper disable once UnusedMember.Global public EmployeeClassMapping() { AutoMap(CultureInfo.InvariantCulture); Map(x => x.SuperRate) .ConvertUsing(r => { var value = r.GetField(SuperRateField); var trimmed = value.Trim(new[] { '%', ' ' }); if (Decimal.TryParse(trimmed, out decimal result)) { return(result / 100); } throw new InvalidOperationException( $"Unable to parse {SuperRateField} - Unrecognised percentage value: {value}"); }); Map(x => x.PaymentStartDate) .ConvertUsing(x => { var dateRange = x.GetField(PaymentStartDateField); PaymentPeriod.TryParseFromDateRangeString(dateRange, out var paymentPeriod); return(paymentPeriod); }); }
public ExcelPackageModel(string elementType) { _costPeriod = PaymentPeriod.Weekly; if (_corePackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Detail; _packageDetailType = PackageDetailType.CoreCost; } else if (_anpPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Detail; _packageDetailType = PackageDetailType.AdditionalNeed; } else if (_careChargeProvisionalNetPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Reclaim; _reclaimSubType = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareChargeProvisional; _reclaimType = ReclaimType.CareCharge; _claimCollector = ClaimCollector.Supplier; } else if (_careChargeProvisionalGrossPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Reclaim; _reclaimSubType = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareChargeProvisional; _reclaimType = ReclaimType.CareCharge; _claimCollector = ClaimCollector.Hackney; } else if (_careCharge13PlusNetPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Reclaim; _reclaimSubType = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareCharge13PlusWeeks; _reclaimType = ReclaimType.CareCharge; _claimCollector = ClaimCollector.Supplier; } else if (_careCharge13PlusGrossPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Reclaim; _reclaimSubType = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.CareCharge13PlusWeeks; _reclaimType = ReclaimType.CareCharge; _claimCollector = ClaimCollector.Hackney; } else if (_anpOneOffPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Detail; _packageDetailType = PackageDetailType.AdditionalNeed; _costPeriod = PaymentPeriod.OneOff; } else if (_fncGrossPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Reclaim; _reclaimSubType = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.FncReclaim; _reclaimType = ReclaimType.Fnc; _claimCollector = ClaimCollector.Hackney; } else if (_fncNetPackageType.Contains(elementType, StringComparer.OrdinalIgnoreCase)) { _excelPackageType = ExcelPackageType.Reclaim; _reclaimSubType = LBH.AdultSocialCare.Data.Constants.Enums.ReclaimSubType.FncPayment; _reclaimType = ReclaimType.Fnc; _claimCollector = ClaimCollector.Supplier; } else { throw new Exception($"Undefined element type: {elementType}"); } }
public void AddPaymentPeriod(PaymentPeriod mPaymentPeriod) { _paymentPeriodRepository.Add(mPaymentPeriod); }
public void UpdatePaymentPeriod(PaymentPeriod mPaymentPeriod) { _paymentPeriodRepository.Update(mPaymentPeriod); }
public async Task <CommandResult> Handle(PaymentPeriodHeaderCommand message) { try { var paymentPeriodPayed = await _repositoryEntityStatus.FirstOrDefaultAsync(q => q.EntityCode == Constants.EntityCode.PaymentPeriod && q.Code == Constants.EntityStatus.PaymentPeriod.Payed); //var entityToSave = new PaymentPeriod(); int c = 0; var index = 0; if (message.PPDetail.Any(q => q.IsSelected.Value)) { var invoicePayed = await _repositoryEntityStatus.FirstOrDefaultAsync(q => q.EntityCode == Constants.EntityCode.Invoice && q.Code == Constants.EntityStatus.Invoice.Payed); List <OrderExpression <Invoice> > orderExpressionList = new List <OrderExpression <Invoice> >(); orderExpressionList.Add(new OrderExpression <Invoice>(OrderType.Desc, p => p.InvoiceNo)); Expression <Func <Invoice, bool> > queryFilter = p => p.RowStatus.Value; var maxInvoice = await _repositoryInvoice.FirstOrDefaultAsync(queryFilter, orderExpressionList.ToArray()); var firstDetail = message.PPDetail.First(); var invoiceEntity = new Invoice(); invoiceEntity.InvoiceId = -1; invoiceEntity.ContractId = firstDetail.ContractId; invoiceEntity.InvoiceDate = DateTime.Now; invoiceEntity.Comment = message.Comment; invoiceEntity.PaymentTypeId = firstDetail.PaymentTypeId; invoiceEntity.PaymentOperationNo = message.ReferenceNo; invoiceEntity.CustomerName = message.TenantFullName; invoiceEntity.InvoiceNo = maxInvoice != null ? (int.Parse(maxInvoice.InvoiceNo) + 1).ToString() : "1"; invoiceEntity.InvoiceStatusId = invoicePayed != null ? (int?)invoicePayed.EntityStatusId : null; //INPAYED invoiceEntity.TotalAmount = message.TotalAmount; invoiceEntity.TotalDeposit = message.TotalDeposit; invoiceEntity.TotalFine = message.TotalFine; invoiceEntity.TotalLateFee = message.TotalLateFee; invoiceEntity.TotalOnAcount = message.TotalOnAcount; invoiceEntity.TotalRent = message.TotalRent; invoiceEntity.TotalService = message.TotalService; invoiceEntity.RowStatus = true; invoiceEntity.CreationDate = DateTime.Now; invoiceEntity.CreatedBy = message.UserId; invoiceEntity.UpdatedDate = DateTime.Now; invoiceEntity.UpdatedBy = message.UserId; var invoiceDetailsEntity = new List <InvoiceDetail>(); foreach (var item in message.PPDetail.Where(q => q.IsSelected.Value)) { --c; var invoiceDetailEntity = new InvoiceDetail(); invoiceDetailEntity.ConceptId = item.ConceptId; invoiceDetailEntity.Qty = 1; invoiceDetailEntity.TotalAmount = item.PaymentAmount; invoiceDetailEntity.UnitPrice = item.PaymentAmount; invoiceDetailEntity.InvoiceDetailId = c; invoiceDetailEntity.InvoiceId = -1; invoiceDetailEntity.TotalAmount = item.PaymentAmount; invoiceDetailEntity.RowStatus = true; invoiceDetailEntity.CreationDate = DateTime.Now; invoiceDetailEntity.CreatedBy = message.UserId; invoiceDetailEntity.UpdatedDate = DateTime.Now; invoiceDetailEntity.UpdatedBy = message.UserId; index = await CreatePaymentPeriod(item, message, c, paymentPeriodPayed); invoiceDetailEntity.PaymentPeriodId = index; invoiceDetailsEntity.Add(invoiceDetailEntity); invoiceEntity.InvoiceDetails = invoiceDetailsEntity; } _repositoryInvoice.Add(invoiceEntity); } foreach (var item in message.PPDetail.Where(q => !q.IsSelected.Value && q.TableStatus == Application.DTOs.Requests.Common.ObjectStatus.Modified)) { --c; index = await CreatePaymentPeriod(item, message, c, null); } await _unitOfWork.CommitAsync(); if (index != 0) { message.PaymentPeriodId = index; } var entityToSave = new PaymentPeriod(); entityToSave.PaymentPeriodId = index; return(entityToSave.ToRegisterdResult().WithId(index)); //return null; // entity.ToRegisterdResult().WithId(entity.ContractId); } catch (Exception ex) { //await SendLogToAmigoTenantTEventLog(message, ex.Message); throw; } }