535 lines
28 KiB
C#
535 lines
28 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.Application;
|
|
using _0_Framework.InfraStructure;
|
|
using Company.Domain.PaymentToEmployeeAgg;
|
|
using CompanyManagment.App.Contracts.PaymentToEmployee;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CompanyManagment.EFCore.Repository
|
|
{
|
|
public class PaymentToEmployeeRepository : RepositoryBase<long, PaymentToEmployee>, IPaymentToEmployeeRepository
|
|
{
|
|
private readonly CompanyContext _context;
|
|
public PaymentToEmployeeRepository(CompanyContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public PaymentToEmployeeViewModel GetByYearAndMonth(string year, string month)
|
|
{
|
|
var res = _context.PaymentToEmployees.Include(x => x.PaymentToEmployeeItemList)
|
|
.FirstOrDefault(x => x.Year == year && x.Month == month);
|
|
|
|
if (res == null)
|
|
{
|
|
return new PaymentToEmployeeViewModel();
|
|
}
|
|
else
|
|
{
|
|
return new PaymentToEmployeeViewModel()
|
|
{
|
|
Id = res.id,
|
|
WorkshopId = res.WorkshopId,
|
|
EmployeeId = res.EmployeeId,
|
|
Year = res.Year,
|
|
Month = res.Month,
|
|
PaymentToEmployeeItemList = res.PaymentToEmployeeItemList.Select(x => new PaymentToEmployeeItemViewModel()
|
|
{
|
|
WorkshopId = x.WorkshopId,
|
|
EmployeeId = x.EmployeeId,
|
|
PaymentToEmployeeId = x.PaymentToEmployeeId,
|
|
PaymentFa = x.Payment.ToMoney(),
|
|
PayDateFa = x.PayDate.ToFarsi(),
|
|
PaymentMetod = x.PaymentMetod,
|
|
SourceBankName = x.SourceBankName,
|
|
SourceBankAccountNumber = x.SourceBankAccountNumber,
|
|
DestinationBankName = x.DestinationBankName,
|
|
DestinationBankAccountNumber = x.DestinationBankAccountNumber,
|
|
BankCheckNumber = x.BankCheckNumber,
|
|
CashDescription = x.CashDescription,
|
|
PaymentTitle = x.PaymentTitle,
|
|
|
|
}).ToList(),
|
|
};
|
|
}
|
|
}
|
|
|
|
public PaymentToEmployeeViewModel GetDetail(long id)
|
|
{
|
|
var res = _context.PaymentToEmployees.Include(x => x.PaymentToEmployeeItemList)
|
|
.FirstOrDefault(x => x.id == id);
|
|
|
|
if (res == null)
|
|
{
|
|
return new PaymentToEmployeeViewModel();
|
|
}
|
|
else
|
|
{
|
|
return new PaymentToEmployeeViewModel()
|
|
{
|
|
Id = res.id,
|
|
WorkshopId = res.WorkshopId,
|
|
EmployeeId = res.EmployeeId,
|
|
Year = res.Year,
|
|
Month = res.Month,
|
|
PaymentToEmployeeItemList = res.PaymentToEmployeeItemList.Select(x => new PaymentToEmployeeItemViewModel()
|
|
{
|
|
WorkshopId = x.WorkshopId,
|
|
EmployeeId = x.EmployeeId,
|
|
PaymentToEmployeeId = x.PaymentToEmployeeId,
|
|
PaymentFa = x.Payment.ToMoney(),
|
|
PayDateFa = x.PayDate.ToFarsi(),
|
|
PaymentMetod = x.PaymentMetod,
|
|
SourceBankName = x.SourceBankName,
|
|
SourceBankAccountNumber = x.SourceBankAccountNumber,
|
|
DestinationBankName = x.DestinationBankName,
|
|
DestinationBankAccountNumber = x.DestinationBankAccountNumber,
|
|
BankCheckNumber = x.BankCheckNumber,
|
|
CashDescription = x.CashDescription,
|
|
PaymentTitle = x.PaymentTitle,
|
|
|
|
}).ToList(),
|
|
};
|
|
}
|
|
}
|
|
|
|
public PaymentToEmployeeViewModel GetByYearAndMonthAndWorkshopAndEmployee(string year, string month, long workshopId, long employeeId)
|
|
{
|
|
var res = _context.PaymentToEmployees.Include(x => x.PaymentToEmployeeItemList)
|
|
.FirstOrDefault(x => x.Year == year && x.Month == month && x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
|
|
|
if (res == null)
|
|
{
|
|
return new PaymentToEmployeeViewModel();
|
|
}
|
|
else
|
|
{
|
|
return new PaymentToEmployeeViewModel()
|
|
{
|
|
Id = res.id,
|
|
WorkshopId = res.WorkshopId,
|
|
EmployeeId = res.EmployeeId,
|
|
Year = res.Year,
|
|
Month = res.Month,
|
|
PaymentToEmployeeItemList = res.PaymentToEmployeeItemList.Select(x => new PaymentToEmployeeItemViewModel()
|
|
{
|
|
WorkshopId = x.WorkshopId,
|
|
EmployeeId = x.EmployeeId,
|
|
PaymentToEmployeeId = x.PaymentToEmployeeId,
|
|
PaymentFa = x.Payment.ToMoney(),
|
|
PayDateFa = x.PayDate.ToFarsi(),
|
|
PaymentMetod = x.PaymentMetod,
|
|
SourceBankName = x.SourceBankName,
|
|
SourceBankAccountNumber = x.SourceBankAccountNumber,
|
|
DestinationBankName = x.DestinationBankName,
|
|
DestinationBankAccountNumber = x.DestinationBankAccountNumber,
|
|
BankCheckNumber = x.BankCheckNumber,
|
|
CashDescription = x.CashDescription,
|
|
PaymentTitle = x.PaymentTitle,
|
|
|
|
}).ToList(),
|
|
};
|
|
}
|
|
}
|
|
|
|
public void Create(long WorkshopId, long EmployeeId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public List<PaymentToEmployeeViewModel> searchClient(PaymentToEmployeeSearchModel searchModel)
|
|
{
|
|
var query = _context.PaymentToEmployees.Include(x => x.PaymentToEmployeeItemList)
|
|
.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
var result = query.Select(x => new PaymentToEmployeeViewModel()
|
|
{
|
|
Id = x.id,
|
|
EmployeeId = x.EmployeeId,
|
|
WorkshopId = x.WorkshopId,
|
|
Month = x.Month.GetMonthByNumber(),
|
|
MonthInt = Convert.ToInt32(x.Month),
|
|
Year = x.Year,
|
|
YearInt = Convert.ToInt32(x.Year),
|
|
CheckoutId = 0,
|
|
CheckoutTotalPayment = "",
|
|
CheckoutTotalPaymentDouble = 0,
|
|
PaymentToEmployeeItemList = x.PaymentToEmployeeItemList.Select(item => new PaymentToEmployeeItemViewModel
|
|
{
|
|
Id = item.id,
|
|
EmployeeId = item.EmployeeId,
|
|
WorkshopId = item.WorkshopId,
|
|
PayDateFa = item.PayDate.ToFarsi(),
|
|
PayDate = item.PayDate,
|
|
PaymentFa = item.Payment.ToMoney(),
|
|
PaymentToEmployeeId = item.PaymentToEmployeeId,
|
|
PaymentMetod = item.PaymentMetod,
|
|
SourceBankName = item.SourceBankName,
|
|
SourceBankAccountNumber = item.SourceBankAccountNumber,
|
|
DestinationBankName = item.DestinationBankName,
|
|
DestinationBankAccountNumber = item.DestinationBankAccountNumber,
|
|
BankCheckNumber = item.BankCheckNumber,
|
|
CashDescription = item.CashDescription,
|
|
PaymentTitle = item.PaymentTitle,
|
|
}).OrderBy(item => item.PayDate).ToList(),
|
|
PaymentToEmployeeTotalPayment = (x.PaymentToEmployeeItemList.Sum(sum => sum.Payment)).ToMoney(),
|
|
PaymentToEmployeeTotalPaymentDouble = x.PaymentToEmployeeItemList.Sum(sum => sum.Payment)
|
|
});
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Year))
|
|
result = result.Where(x => x.YearInt == Convert.ToInt32(searchModel.Year));
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
|
result = result.Where(x => x.MonthInt == Convert.ToInt32(searchModel.Month));
|
|
|
|
var paymentToEmployeeList = result.ToList();
|
|
|
|
|
|
// اطلاعات پرداخت مربوط به تصفیه حساب
|
|
var checkoutsList = _context.CheckoutSet.Select(x => new PaymentToEmployeeViewModel()
|
|
{
|
|
EmployeeId = x.EmployeeId,
|
|
WorkshopId = x.WorkshopId,
|
|
Month = x.Month,
|
|
MonthInt = x.Month.ToMonthByStringValue(),
|
|
Year = x.Year,
|
|
YearInt = Convert.ToInt32(x.Year),
|
|
CheckoutId = x.id,
|
|
CheckoutTotalPaymentDouble = x.TotalPayment,
|
|
CheckoutTotalPayment = x.TotalPayment.ToMoney(),
|
|
}).Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Year))
|
|
checkoutsList = checkoutsList.Where(x => x.Year == searchModel.Year);
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
|
checkoutsList = checkoutsList.Where(x => x.Month == searchModel.Month.ToFarsiMonthByNumber());
|
|
|
|
var checkouts = checkoutsList.ToList();
|
|
|
|
// گرفتن اطلاعات تصفیه حساب با چک کردن پیمینت تو ایمپلویی
|
|
var final = new List<PaymentToEmployeeViewModel>();
|
|
|
|
foreach (var checkout in checkouts)
|
|
{
|
|
var paymentToEmployee = paymentToEmployeeList.FirstOrDefault(x => x.MonthInt == checkout.MonthInt && x.YearInt == checkout.YearInt);
|
|
var PaymentToEmployeeTotalPaymentDouble = paymentToEmployee != null ? paymentToEmployee.PaymentToEmployeeTotalPaymentDouble : 0;
|
|
|
|
var computeCheckout = "0";
|
|
var computePaymentToEmployee = "0";
|
|
|
|
if (checkout.CheckoutTotalPaymentDouble > PaymentToEmployeeTotalPaymentDouble)
|
|
{
|
|
computeCheckout = (checkout.CheckoutTotalPaymentDouble - PaymentToEmployeeTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
if (PaymentToEmployeeTotalPaymentDouble > checkout.CheckoutTotalPaymentDouble)
|
|
{
|
|
computePaymentToEmployee = (PaymentToEmployeeTotalPaymentDouble - checkout.CheckoutTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
|
|
var DataCheckout = new PaymentToEmployeeViewModel()
|
|
{
|
|
EmployeeId = checkout.EmployeeId,
|
|
WorkshopId = checkout.WorkshopId,
|
|
Month = checkout.MonthInt.ToFarsiMonthByIntNumber(),
|
|
MonthInt = checkout.MonthInt,
|
|
Year = Convert.ToString(checkout.YearInt),
|
|
YearInt = checkout.YearInt,
|
|
CheckoutId = checkout.CheckoutId,
|
|
CheckoutTotalPayment = checkout.CheckoutTotalPayment,
|
|
CheckoutTotalPaymentDouble = checkout.CheckoutTotalPaymentDouble,
|
|
PaymentToEmployeeItemList = paymentToEmployee == null ? new List<PaymentToEmployeeItemViewModel>() : paymentToEmployee.PaymentToEmployeeItemList.Select(paymentToEmployeeItem => new PaymentToEmployeeItemViewModel
|
|
{
|
|
Id = paymentToEmployeeItem.Id,
|
|
EmployeeId = paymentToEmployeeItem.EmployeeId,
|
|
WorkshopId = paymentToEmployeeItem.WorkshopId,
|
|
PayDateFa = paymentToEmployeeItem.PayDate.ToFarsi(),
|
|
PayDate = paymentToEmployeeItem.PayDate,
|
|
PaymentFa = paymentToEmployeeItem.PaymentFa,
|
|
PaymentToEmployeeId = paymentToEmployeeItem.PaymentToEmployeeId,
|
|
PaymentMetod = paymentToEmployeeItem.PaymentMetod,
|
|
SourceBankName = paymentToEmployeeItem.SourceBankName,
|
|
SourceBankAccountNumber = paymentToEmployeeItem.SourceBankAccountNumber,
|
|
DestinationBankName = paymentToEmployeeItem.DestinationBankName,
|
|
DestinationBankAccountNumber = paymentToEmployeeItem.DestinationBankAccountNumber,
|
|
BankCheckNumber = paymentToEmployeeItem.BankCheckNumber,
|
|
CashDescription = paymentToEmployeeItem.CashDescription,
|
|
PaymentTitle = paymentToEmployeeItem.PaymentTitle
|
|
}).OrderBy(paymentToEmployeeItem => paymentToEmployeeItem.PayDate).ToList(),
|
|
|
|
PaymentToEmployeeTotalPayment = paymentToEmployee == null ? "0" : paymentToEmployee.PaymentToEmployeeTotalPayment,
|
|
PaymentToEmployeeTotalPaymentDouble = paymentToEmployee == null ? 0 : paymentToEmployee.PaymentToEmployeeTotalPaymentDouble,
|
|
|
|
ComputeCheckoutTotalPayment = computeCheckout,
|
|
ComputePaymentToEmployeeTotalPayment = computePaymentToEmployee
|
|
};
|
|
final.Add(DataCheckout);
|
|
}
|
|
|
|
//حلقه فور پیمینت تو ایمپلویی
|
|
foreach (var item in paymentToEmployeeList)
|
|
{
|
|
//اطلاعات تصفیه حساب
|
|
var isExistInFinal = final.Any(x => x.YearInt == item.YearInt && x.MonthInt == item.MonthInt);
|
|
|
|
var computeCheckout = "0";
|
|
var computePaymentToEmployee = "0";
|
|
if (item.CheckoutTotalPaymentDouble > item.PaymentToEmployeeTotalPaymentDouble)
|
|
{
|
|
computeCheckout = (item.CheckoutTotalPaymentDouble - item.PaymentToEmployeeTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
if (item.PaymentToEmployeeTotalPaymentDouble > item.CheckoutTotalPaymentDouble)
|
|
{
|
|
computePaymentToEmployee = (item.PaymentToEmployeeTotalPaymentDouble - item.CheckoutTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
|
|
if (!isExistInFinal)
|
|
{
|
|
var Data = new PaymentToEmployeeViewModel()
|
|
{
|
|
Id = item.Id,
|
|
EmployeeId = item.EmployeeId,
|
|
WorkshopId = item.WorkshopId,
|
|
Month = item.Month,
|
|
MonthInt = item.MonthInt,
|
|
Year = item.Year,
|
|
YearInt = item.YearInt,
|
|
PaymentToEmployeeItemList = item.PaymentToEmployeeItemList.Select(paymentToEmployeeItem => new PaymentToEmployeeItemViewModel
|
|
{
|
|
Id = paymentToEmployeeItem.Id,
|
|
EmployeeId = paymentToEmployeeItem.EmployeeId,
|
|
WorkshopId = paymentToEmployeeItem.WorkshopId,
|
|
PayDateFa = paymentToEmployeeItem.PayDate.ToFarsi(),
|
|
PayDate = paymentToEmployeeItem.PayDate,
|
|
PaymentFa = paymentToEmployeeItem.PaymentFa,
|
|
PaymentToEmployeeId = paymentToEmployeeItem.PaymentToEmployeeId,
|
|
PaymentMetod = paymentToEmployeeItem.PaymentMetod,
|
|
SourceBankName = paymentToEmployeeItem.SourceBankName,
|
|
SourceBankAccountNumber = paymentToEmployeeItem.SourceBankAccountNumber,
|
|
DestinationBankName = paymentToEmployeeItem.DestinationBankName,
|
|
DestinationBankAccountNumber = paymentToEmployeeItem.DestinationBankAccountNumber,
|
|
BankCheckNumber = paymentToEmployeeItem.BankCheckNumber,
|
|
CashDescription = paymentToEmployeeItem.CashDescription,
|
|
PaymentTitle = paymentToEmployeeItem.PaymentTitle
|
|
}).OrderBy(paymentToEmployeeItem => paymentToEmployeeItem.PayDate).ToList(),
|
|
|
|
PaymentToEmployeeTotalPayment = item.PaymentToEmployeeTotalPayment,
|
|
PaymentToEmployeeTotalPaymentDouble = item.PaymentToEmployeeTotalPaymentDouble,
|
|
|
|
ComputeCheckoutTotalPayment = computeCheckout,
|
|
ComputePaymentToEmployeeTotalPayment = computePaymentToEmployee
|
|
};
|
|
|
|
final.Add(Data);
|
|
}
|
|
}
|
|
|
|
return final.OrderByDescending(x => x.YearInt).ThenByDescending(x => x.MonthInt).ToList();
|
|
}
|
|
|
|
public void RemovePaymentItem(long id)
|
|
{
|
|
var paymentToEmployeeItems = _context.PaymentToEmployeeItems.FirstOrDefault(x => x.id == id);
|
|
if (paymentToEmployeeItems != null)
|
|
{
|
|
_context.RemoveRange(paymentToEmployeeItems);
|
|
_context.SaveChanges();
|
|
}
|
|
}
|
|
|
|
|
|
public List<PaymentToEmployeePrintViewModel> PrintAll(PaymentToEmployeeSearchModel searchModel)
|
|
{
|
|
var query = _context.PaymentToEmployees.Include(x => x.PaymentToEmployeeItemList)
|
|
.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
var result = query.Select(x => new PaymentToEmployeePrintViewModel()
|
|
{
|
|
Id = x.id,
|
|
EmployeeId = x.EmployeeId,
|
|
WorkshopId = x.WorkshopId,
|
|
Month = x.Month.GetMonthByNumber(),
|
|
MonthInt = Convert.ToInt32(x.Month),
|
|
Year = x.Year,
|
|
YearInt = Convert.ToInt32(x.Year),
|
|
CheckoutId = 0,
|
|
CheckoutTotalPayment = "",
|
|
CheckoutTotalPaymentDouble = 0,
|
|
PaymentToEmployeeItemList = x.PaymentToEmployeeItemList.Select(item => new PaymentToEmployeeItemViewModel
|
|
{
|
|
Id = item.id,
|
|
EmployeeId = item.EmployeeId,
|
|
WorkshopId = item.WorkshopId,
|
|
PayDateFa = item.PayDate.ToFarsi(),
|
|
PayDate = item.PayDate,
|
|
PaymentFa = item.Payment.ToMoney(),
|
|
PaymentToEmployeeId = item.PaymentToEmployeeId,
|
|
PaymentMetod = item.PaymentMetod,
|
|
SourceBankName = item.SourceBankName,
|
|
SourceBankAccountNumber = item.SourceBankAccountNumber,
|
|
DestinationBankName = item.DestinationBankName,
|
|
DestinationBankAccountNumber = item.DestinationBankAccountNumber,
|
|
BankCheckNumber = item.BankCheckNumber,
|
|
CashDescription = item.CashDescription,
|
|
PaymentTitle = item.PaymentTitle,
|
|
}).OrderBy(item => item.PayDate).ToList(),
|
|
PaymentToEmployeeTotalPayment = (x.PaymentToEmployeeItemList.Sum(sum => sum.Payment)).ToMoney(),
|
|
PaymentToEmployeeTotalPaymentDouble = x.PaymentToEmployeeItemList.Sum(sum => sum.Payment)
|
|
});
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Year))
|
|
result = result.Where(x => x.YearInt == Convert.ToInt32(searchModel.Year));
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
|
result = result.Where(x => x.MonthInt == Convert.ToInt32(searchModel.Month));
|
|
|
|
var paymentToEmployeeList = result.ToList();
|
|
|
|
|
|
// اطلاعات پرداخت مربوط به تصفیه حساب
|
|
var checkoutsList = _context.CheckoutSet.Select(x => new PaymentToEmployeePrintViewModel()
|
|
{
|
|
EmployeeId = x.EmployeeId,
|
|
WorkshopId = x.WorkshopId,
|
|
Month = x.Month,
|
|
MonthInt = x.Month.ToMonthByStringValue(),
|
|
Year = x.Year,
|
|
YearInt = Convert.ToInt32(x.Year),
|
|
CheckoutId = x.id,
|
|
CheckoutTotalPaymentDouble = x.TotalPayment,
|
|
CheckoutTotalPayment = x.TotalPayment.ToMoney(),
|
|
}).Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Year))
|
|
checkoutsList = checkoutsList.Where(x => x.Year == searchModel.Year);
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.Month))
|
|
checkoutsList = checkoutsList.Where(x => x.Month == searchModel.Month.ToFarsiMonthByNumber());
|
|
|
|
var checkouts = checkoutsList.ToList();
|
|
|
|
// گرفتن اطلاعات تصفیه حساب با چک کردن پیمینت تو ایمپلویی
|
|
var final = new List<PaymentToEmployeePrintViewModel>();
|
|
|
|
foreach (var checkout in checkouts)
|
|
{
|
|
var paymentToEmployee = paymentToEmployeeList.FirstOrDefault(x => x.MonthInt == checkout.MonthInt && x.YearInt == checkout.YearInt);
|
|
var PaymentToEmployeeTotalPaymentDouble = paymentToEmployee != null ? paymentToEmployee.PaymentToEmployeeTotalPaymentDouble : 0;
|
|
|
|
var computeCheckout = "0";
|
|
var computePaymentToEmployee = "0";
|
|
|
|
if (checkout.CheckoutTotalPaymentDouble > PaymentToEmployeeTotalPaymentDouble)
|
|
{
|
|
computeCheckout = (checkout.CheckoutTotalPaymentDouble - PaymentToEmployeeTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
if (PaymentToEmployeeTotalPaymentDouble > checkout.CheckoutTotalPaymentDouble)
|
|
{
|
|
computePaymentToEmployee = (PaymentToEmployeeTotalPaymentDouble - checkout.CheckoutTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
|
|
var DataCheckout = new PaymentToEmployeePrintViewModel()
|
|
{
|
|
EmployeeId = checkout.EmployeeId,
|
|
WorkshopId = checkout.WorkshopId,
|
|
Month = checkout.MonthInt.ToFarsiMonthByIntNumber(),
|
|
MonthInt = checkout.MonthInt,
|
|
Year = Convert.ToString(checkout.YearInt),
|
|
YearInt = checkout.YearInt,
|
|
CheckoutId = checkout.CheckoutId,
|
|
CheckoutTotalPayment = checkout.CheckoutTotalPayment,
|
|
CheckoutTotalPaymentDouble = checkout.CheckoutTotalPaymentDouble,
|
|
PaymentToEmployeeItemList = paymentToEmployee == null ? new List<PaymentToEmployeeItemViewModel>() : paymentToEmployee.PaymentToEmployeeItemList.Select(paymentToEmployeeItem => new PaymentToEmployeeItemViewModel
|
|
{
|
|
Id = paymentToEmployeeItem.Id,
|
|
EmployeeId = paymentToEmployeeItem.EmployeeId,
|
|
WorkshopId = paymentToEmployeeItem.WorkshopId,
|
|
PayDateFa = paymentToEmployeeItem.PayDate.ToFarsi(),
|
|
PayDate = paymentToEmployeeItem.PayDate,
|
|
PaymentFa = paymentToEmployeeItem.PaymentFa,
|
|
PaymentToEmployeeId = paymentToEmployeeItem.PaymentToEmployeeId,
|
|
PaymentMetod = paymentToEmployeeItem.PaymentMetod,
|
|
SourceBankName = paymentToEmployeeItem.SourceBankName,
|
|
SourceBankAccountNumber = paymentToEmployeeItem.SourceBankAccountNumber,
|
|
DestinationBankName = paymentToEmployeeItem.DestinationBankName,
|
|
DestinationBankAccountNumber = paymentToEmployeeItem.DestinationBankAccountNumber,
|
|
BankCheckNumber = paymentToEmployeeItem.BankCheckNumber,
|
|
CashDescription = paymentToEmployeeItem.CashDescription,
|
|
PaymentTitle = paymentToEmployeeItem.PaymentTitle
|
|
}).OrderBy(paymentToEmployeeItem => paymentToEmployeeItem.PayDate).ToList(),
|
|
|
|
PaymentToEmployeeTotalPayment = paymentToEmployee == null ? "0" : paymentToEmployee.PaymentToEmployeeTotalPayment,
|
|
PaymentToEmployeeTotalPaymentDouble = paymentToEmployee == null ? 0 : paymentToEmployee.PaymentToEmployeeTotalPaymentDouble,
|
|
|
|
ComputeCheckoutTotalPayment = computeCheckout,
|
|
ComputePaymentToEmployeeTotalPayment = computePaymentToEmployee
|
|
};
|
|
final.Add(DataCheckout);
|
|
}
|
|
|
|
//حلقه فور پیمینت تو ایمپلویی
|
|
foreach (var item in paymentToEmployeeList)
|
|
{
|
|
//اطلاعات تصفیه حساب
|
|
var isExistInFinal = final.Any(x => x.YearInt == item.YearInt && x.MonthInt == item.MonthInt);
|
|
|
|
var computeCheckout = "0";
|
|
var computePaymentToEmployee = "0";
|
|
if (item.CheckoutTotalPaymentDouble > item.PaymentToEmployeeTotalPaymentDouble)
|
|
{
|
|
computeCheckout = (item.CheckoutTotalPaymentDouble - item.PaymentToEmployeeTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
if (item.PaymentToEmployeeTotalPaymentDouble > item.CheckoutTotalPaymentDouble)
|
|
{
|
|
computePaymentToEmployee = (item.PaymentToEmployeeTotalPaymentDouble - item.CheckoutTotalPaymentDouble).ToMoneyNullable();
|
|
}
|
|
|
|
if (!isExistInFinal)
|
|
{
|
|
var Data = new PaymentToEmployeePrintViewModel()
|
|
{
|
|
Id = item.Id,
|
|
EmployeeId = item.EmployeeId,
|
|
WorkshopId = item.WorkshopId,
|
|
Month = item.Month,
|
|
MonthInt = item.MonthInt,
|
|
Year = item.Year,
|
|
YearInt = item.YearInt,
|
|
PaymentToEmployeeItemList = item.PaymentToEmployeeItemList.Select(paymentToEmployeeItem => new PaymentToEmployeeItemViewModel
|
|
{
|
|
Id = paymentToEmployeeItem.Id,
|
|
EmployeeId = paymentToEmployeeItem.EmployeeId,
|
|
WorkshopId = paymentToEmployeeItem.WorkshopId,
|
|
PayDateFa = paymentToEmployeeItem.PayDate.ToFarsi(),
|
|
PayDate = paymentToEmployeeItem.PayDate,
|
|
PaymentFa = paymentToEmployeeItem.PaymentFa,
|
|
PaymentToEmployeeId = paymentToEmployeeItem.PaymentToEmployeeId,
|
|
PaymentMetod = paymentToEmployeeItem.PaymentMetod,
|
|
SourceBankName = paymentToEmployeeItem.SourceBankName,
|
|
SourceBankAccountNumber = paymentToEmployeeItem.SourceBankAccountNumber,
|
|
DestinationBankName = paymentToEmployeeItem.DestinationBankName,
|
|
DestinationBankAccountNumber = paymentToEmployeeItem.DestinationBankAccountNumber,
|
|
BankCheckNumber = paymentToEmployeeItem.BankCheckNumber,
|
|
CashDescription = paymentToEmployeeItem.CashDescription,
|
|
PaymentTitle = paymentToEmployeeItem.PaymentTitle
|
|
}).OrderBy(paymentToEmployeeItem => paymentToEmployeeItem.PayDate).ToList(),
|
|
|
|
PaymentToEmployeeTotalPayment = item.PaymentToEmployeeTotalPayment,
|
|
PaymentToEmployeeTotalPaymentDouble = item.PaymentToEmployeeTotalPaymentDouble,
|
|
|
|
ComputeCheckoutTotalPayment = computeCheckout,
|
|
ComputePaymentToEmployeeTotalPayment = computePaymentToEmployee
|
|
};
|
|
|
|
final.Add(Data);
|
|
}
|
|
}
|
|
|
|
return final.OrderByDescending(x => x.YearInt).ThenByDescending(x => x.MonthInt).ToList();
|
|
}
|
|
|
|
}
|
|
}
|