120 lines
5.6 KiB
C#
120 lines
5.6 KiB
C#
//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; }
|
||
// }
|
||
|
||
//}
|