first commit
This commit is contained in:
118
Complex.Application/Services/Charge/ChargeCycleService.cs
Normal file
118
Complex.Application/Services/Charge/ChargeCycleService.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
// در بیسیک وجود دارد
|
||||
|
||||
|
||||
//using AutoMapper;
|
||||
//using Complex.Application.Utility;
|
||||
//using Complex.Common.Dto;
|
||||
//using Complex.Domain.Commons;
|
||||
//using Complex.Domain.Entities;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel.DataAnnotations;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace Complex.Application.Services.Charge
|
||||
//{
|
||||
// public class ChargeCycleService
|
||||
// {
|
||||
// /*
|
||||
// * ثبت آیتم مدیریت شارژ
|
||||
// * لیست ایتم های مدیریت شارژ
|
||||
// * ویرایش
|
||||
// */
|
||||
// private readonly IComplexDBContext _complexDBContext;
|
||||
// private readonly IMapper _mapper;
|
||||
|
||||
// public ChargeCycleService(IComplexDBContext complexDBContext, IMapper mapper)
|
||||
// {
|
||||
// _complexDBContext = complexDBContext;
|
||||
// _mapper = mapper;
|
||||
// }
|
||||
// public ResultDto<Guid> InsertManageCharge(ChargeCycleDto chargeCycleDto)
|
||||
// {
|
||||
// var CCharge = new ChargeCycle
|
||||
// {
|
||||
// Amount = chargeCycleDto.Amount,
|
||||
// ComplexId = chargeCycleDto.ComplexId,
|
||||
// EncouragementAmount = chargeCycleDto.EncouragementAmount,
|
||||
// EncouragementDay = chargeCycleDto.EncouragementDay,
|
||||
// EndDate = chargeCycleDto.EndDate,
|
||||
// InsertTime = DateTime.Now,
|
||||
// StartDate = chargeCycleDto.StartDate,
|
||||
// Title = chargeCycleDto.Title,
|
||||
// };
|
||||
// if (chargeCycleDto.UnitIds != null)
|
||||
// {
|
||||
// CCharge.UnitChargeTypes = new List<UnitChargeType>();
|
||||
// chargeCycleDto.UnitIds.ForEach(g => CCharge.UnitChargeTypes.Add(new UnitChargeType
|
||||
// {
|
||||
// ComplexId = chargeCycleDto.ComplexId,
|
||||
// ChargeTypeId = null,
|
||||
// UnitId = g
|
||||
// }));
|
||||
// }
|
||||
// _complexDBContext.ChargeCycles.Add(CCharge);
|
||||
// _complexDBContext.SaveChanges();
|
||||
// return new ResultDto<Guid>
|
||||
// {
|
||||
// IsSuccess = true,
|
||||
// Data = CCharge.Id
|
||||
// };
|
||||
// }
|
||||
// public ResultDto<List<ChargeCycleDto>> ChargeCyclsList(Guid ComplexId, DateTime? StartDate = null, DateTime? EndDate = null)
|
||||
// {
|
||||
// var ChargeCycleQuery = _complexDBContext.ChargeCycles.Include(c => c.UnitChargeTypes).ThenInclude(uc => uc.Unit).Where(c => c.ComplexId == ComplexId).AsQueryable();
|
||||
// if (StartDate != null)
|
||||
// ChargeCycleQuery = ChargeCycleQuery.Where(c => c.StartDate >= StartDate);
|
||||
|
||||
// if (EndDate != null)
|
||||
// ChargeCycleQuery = ChargeCycleQuery.Where(c => c.EndDate <= EndDate);
|
||||
|
||||
// var ChargeCycleList = ChargeCycleQuery.ToList().Select(c => new ChargeCycleDto
|
||||
// {
|
||||
// ComplexId = c.ComplexId,
|
||||
// Amount = c.Amount,
|
||||
// EncouragementAmount = c.EncouragementAmount,
|
||||
// EncouragementDay = c.EncouragementDay,
|
||||
// EndDate = c.EndDate,
|
||||
// StartDate = c.StartDate,
|
||||
// Id = c.Id,
|
||||
// Title = c.Title,
|
||||
// UnitIds = c.UnitChargeTypes?.Select(u => u.UnitId).ToList(),
|
||||
// UnitNames = c.UnitChargeTypes?.Select(u => u.Unit.UnitId + "#" + u.Unit.UnitName).ToList(),
|
||||
// }).ToList();
|
||||
// return new ResultDto<List<ChargeCycleDto>>
|
||||
// {
|
||||
// IsSuccess = true,
|
||||
// RowCount= ChargeCycleList.Count,
|
||||
// Data= ChargeCycleList
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// public class ChargeCycleDto
|
||||
// {
|
||||
// public Guid Id { get; set; }
|
||||
// public Guid ComplexId { set; get; }
|
||||
// public virtual ComplexEntity Complex { set; get; }
|
||||
// public string Title { set; get; }
|
||||
// public DateTime StartDate { set; get; }
|
||||
// public DateTime EndDate { set; get; }
|
||||
// public long Amount { set; get; } = 0;
|
||||
// /// <summary>
|
||||
// /// روز از ماه برای تشویقی
|
||||
// /// </summary>
|
||||
// public int EncouragementDay { set; get; } = 0;
|
||||
// /// <summary>
|
||||
// /// مبلغ اجاره با احتساب تشویقی
|
||||
// /// </summary>
|
||||
// public long EncouragementAmount { set; get; } = 0;
|
||||
// /// <summary>
|
||||
// /// اگر برای واحدهای خاصی بود
|
||||
// /// </summary>
|
||||
// public virtual List<Guid>? UnitIds { set; get; }
|
||||
// public virtual List<string>? UnitNames { set; get; }
|
||||
// }
|
||||
//}
|
||||
119
Complex.Application/Services/Charge/ChargeService.cs
Normal file
119
Complex.Application/Services/Charge/ChargeService.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
//using AutoMapper;
|
||||
//using Complex.Application.Services.Transaction;
|
||||
//using Complex.Application.Utility;
|
||||
//using Complex.Common.Dto;
|
||||
//using Complex.Domain.Entities;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel.DataAnnotations;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace Complex.Application.Services.Charge
|
||||
//{
|
||||
// public class CostService
|
||||
// {
|
||||
// private readonly IComplexDBContext _complexDBContext;
|
||||
// private readonly IMapper _mapper;
|
||||
|
||||
// public CostService(IComplexDBContext complexDBContext, IMapper mapper)
|
||||
// {
|
||||
// _complexDBContext = complexDBContext;
|
||||
// _mapper = mapper;
|
||||
// }
|
||||
// public ResultDto DefineUnitCharge(Guid unitId, Guid costCycleId)
|
||||
// {
|
||||
// var cycle = _complexDBContext.CostCycles.Where(c => c.Id == costCycleId).FirstOrDefault();
|
||||
// var currentDate = DateTime.Now;
|
||||
// ///ایتم هایی که برای بعد از این تاریخ هست باید حذف شوند و مجدد محاسبه شوند
|
||||
// ///اما ایتم هایی که هم تاریخ مدیریت شارژ و هم تاریخ امروز به بعد
|
||||
// ///البته در مدیریت شارژ تعریفی نباید اجازه داد تاریخ شروع از آن روز به قبل باشد
|
||||
// var itemsForDelete = _complexDBContext.UnitCosts.Where(t =>
|
||||
// t.CostCycleId == costCycleId &&
|
||||
// t.UnitId == unitId && t.Date >= currentDate && !t.TransactionId.HasValue);
|
||||
// //اگر شارژ باشد فقط یک بار در ماه هست اما غیر از ان به هر هزینه تعریفی میتواند
|
||||
// //که در ماه میتواند چندین هزینه تعریف کند
|
||||
// //اگر برای شارژ باشد
|
||||
// //if (!cycle.IncomeCostTitleId.HasValue)
|
||||
// // deleteCharges = deleteCharges.Where(t => t.ChargeCycleId == ChargeCycleId);
|
||||
// //else
|
||||
// //deleteCharges = deleteCharges.Where(t => t.ChargeCycleId == cycle.Id);
|
||||
// _complexDBContext.UnitCosts.RemoveRange(itemsForDelete);
|
||||
// //همه ماهانه هست و روز خاصی نگرفتیم برای اصل و پرداخت نشده ها حذف شده
|
||||
// //پس روز اخر ملاک هست
|
||||
// while (currentDate < cycle.EndDate)
|
||||
// {
|
||||
// var newUC = new UnitCost
|
||||
// {
|
||||
// CostCycleId = costCycleId,
|
||||
// UnitId = unitId,
|
||||
// Date = currentDate,
|
||||
// TransactionId = null
|
||||
// };
|
||||
// currentDate.AddMonths(1);
|
||||
// _complexDBContext.UnitCosts.Add(newUC);
|
||||
// }
|
||||
// _complexDBContext.SaveChanges();
|
||||
// return new ResultDto
|
||||
// {
|
||||
// Message = "ثبت با موفقیت انجام شد",
|
||||
// IsSuccess = true,
|
||||
// };
|
||||
// }
|
||||
// public /*ResultDto<List<long>>*/ void CalculateUnitCharge(Guid unitId, int? IncomeCostTitleId)
|
||||
// {
|
||||
// var currentDate = DateTime.Now;
|
||||
// var unitCharges = _complexDBContext.UnitCosts.Where(uc => uc.UnitId == unitId && !uc.TransactionId.HasValue
|
||||
// && uc.CostCycle.IncomeCostTitleId == IncomeCostTitleId);
|
||||
// }
|
||||
// //public /*ResultDto<List<long>>*/ void CalculateUnitCharge(Guid complexId, Guid unitId)
|
||||
// //{
|
||||
// // var CurrentMonth = PersianDate.CurrentPersianMonth;
|
||||
// // var CurrentYear = PersianDate.CurrentPersianYear;
|
||||
// // var currentMonthDate = PersianDate.ConvertToMiladi(CurrentYear + "/" + CurrentMonth.ToString().PadLeft(2, '0') + "/01");
|
||||
// // var manageChargList = _complexDBContext.ChargeCycles.Include(m => m.UnitChargeTypes)
|
||||
// // .Where(m => m.ComplexId == complexId
|
||||
// // && m.StartDate <= currentMonthDate
|
||||
// // && m.EndDate >= currentMonthDate).Select(m => m).ToList();
|
||||
// // ///بدست اوردن ماه هایی که شارژ نداده است
|
||||
// // var startChargeDate = _complexDBContext.ChargeCycles
|
||||
// // .Where(m => m.ComplexId == complexId)
|
||||
// // .Min(m => m.StartDate);
|
||||
// // //for(var d=startChargeDate;d<=yearMonth;d.AddDays(1))
|
||||
// // //{
|
||||
|
||||
// // //}
|
||||
// // var startPersianDate = PersianDate.GetPDate(startChargeDate);
|
||||
// // var endPersianDate = PersianDate.GetPDate(DateTime.Now);
|
||||
|
||||
// // var paymentDatelist =
|
||||
// // for (int y = startPersianDate.Year; y <= endPersianDate.Year; y++)
|
||||
// // {
|
||||
// // for (int m = startPersianDate.Month; m <= endPersianDate.Month; m++)
|
||||
// // {
|
||||
|
||||
// // }
|
||||
// // }
|
||||
// //}
|
||||
// }
|
||||
// public class ChargeDto
|
||||
// {
|
||||
// public int TransactionTitleId { get; } = 1;
|
||||
// public string TransactionTitle { get; } = "شارژ";
|
||||
// [MaxLength(10)]
|
||||
// public string TransactionDate { set; get; }
|
||||
// public long Amount { set; get; } = 0;
|
||||
// public string? Description { set; get; }
|
||||
// public int? ChargeTypeId { set; get; } = 1;
|
||||
// public string ChargeType { set; get; } = "شارژ ماهیانه";
|
||||
// public Guid? UnitId { set; get; }
|
||||
// public string UnitTitle { set; get; }
|
||||
// /// <summary>
|
||||
// ///شماره فیش. اگر با فیش چیزی واریز شده است
|
||||
// /// </summary>
|
||||
// public string? FishId { set; get; }
|
||||
// }
|
||||
|
||||
//}
|
||||
Reference in New Issue
Block a user