Compare commits

..

61 Commits

Author SHA1 Message Date
f238b5af6b Enhance financial invoice handling by adding InvoiceNumber property and increasing DescriptionOption max length; implement SetPendingWorkflow method 2025-11-17 20:51:21 +03:30
ed746cb60a Refactor invoice handling to use TransactionId and add InvoiceNumber property 2025-11-17 17:06:31 +03:30
6d3526fb30 Refactor FinancialInvoiceItem constructor for improved readability 2025-11-15 19:16:47 +03:30
ba2b402c04 Add Financial Invoice Management System
Refactored `FinancialInvoice` to include new properties (`Description`, `PublicId`, `IsActive`) and methods for managing items and statuses. Introduced `FinancialInvoiceItem` for invoice itemization. Updated `PaymentTransaction` to reference `FinancialInvoice`.

Enhanced repository and application layers with CRUD operations, advanced search functionality, and integration with contracts. Updated `CompanyContext` with `DbSet<FinancialInvoices>` and `DbSet<FinancialInvoiceItem>`.

Created new database tables for `FinancialInvoices` and `FinancialInvoiceItem`, and updated relationships with `PaymentTransactions`. Added DTOs for invoice creation, editing, and searching. Registered `IFinancialInvoiceRepository` for dependency injection.
2025-11-13 12:49:30 +03:30
f3470de8b6 Merge branch 'master' into Feature/FinancialInvoice/Init 2025-11-12 21:02:30 +03:30
783fffa0c2 Add Sepehr Payment Gateway integration
- Added `DigitalReceipt` and `Rrn` columns to `PaymentTransactions` table for enhanced payment tracking.
- Introduced `SepehrPaymentGateway` class for API integration, including methods for creating, verifying, and processing payments.
- Updated `PaymentTransaction` class to include `Gateway`, `Rrn`, and `DigitalReceipt` properties.
- Refactored payment workflows in `GeneralController`, `Index.cshtml.cs`, and `FinancialController` to use Sepehr gateway.
- Added new classes (`TokenReq`, `SepehrGatewayPayResponse`, etc.) for handling Sepehr-specific requests and responses.
- Configured Sepehr gateway in `Program.cs` using the `Parbad` library.
- Updated `appsettings.json` and `appsettings.Development.json` to include `SepehrGateWayTerminalId`.
- Added `Parbad.AspNetCore` and `Parbad.Storage.Cache` packages to the project.
- Improved error handling for payment creation and verification processes.
2025-11-12 21:01:54 +03:30
16c29bc2d0 Add SepehrPaymentGateway and enhance payment tracking
Introduced the SepehrPaymentGateway to replace the previous
payment gateway, AqayePardakht. Added `Rrn` and `DigitalReceipt`
columns to the `PaymentTransactions` table for improved payment
tracking and verification. Updated the Entity Framework model
and mappings to reflect these changes.

Refactored payment transaction logic to support the new gateway,
including creating, verifying, and handling payments. Added new
request/response models for Sepehr gateway integration. Enhanced
error handling and financial statement creation upon successful
payment verification. Removed legacy code and updated dependency
injection for the Parbad library.
2025-11-12 20:59:37 +03:30
SamSys
57ef47473b changes 2025-11-12 16:24:06 +03:30
syntax24
e00c93b23d change launch setting 2025-11-12 15:05:36 +03:30
8bd248c6a7 Integrate Sepehr payment gateway with Parbad
Added Parbad libraries and configured Sepehr gateway in `Program.cs`
and `appsettings.json`. Implemented payment request and verification
logic in `Index.cshtml.cs` and `GeneralController`. Updated
`ServiceHost.csproj` with required dependencies. Refactored roll call
logic and removed unused URLs in `launchSettings.json`. Enhanced
services with memory cache storage and added `Bogus` for data
generation.
2025-11-12 15:00:12 +03:30
7f9531f07b Integrate Sepehr payment gateway via Parbad library
Added `Parbad.Gateway.Sepehr` package to enable Sepehr payment gateway integration. Updated `Index.cshtml.cs` to handle online payment requests using `IOnlinePayment`. Configured Sepehr gateway in `Program.cs` with terminal ID from `appsettings.Development.json`. Enabled Swagger for development builds.
2025-11-12 12:01:44 +03:30
4a8f76c473 Refactor FinancialInvoice class to simplify properties
Removed `SmsCode`, `FinancialStatementId`, and `FinancialStatement` properties, along with their associated methods (`SetFinancialStatement` and `SetNewSmsCode`).

Added a new `InvoiceId` property of type `Guid` to serve as a unique identifier for invoices. Updated the constructor to initialize `InvoiceId` and removed the `SmsCode` initialization logic.

These changes streamline the `FinancialInvoice` class and improve its alignment with application requirements.
2025-11-12 10:20:22 +03:30
3e5520d8a0 merge from master 2025-11-11 19:57:05 +03:30
SamSys
861b214b0c test sepehr gatway completed 2025-11-11 17:34:40 +03:30
SamSys
690f574240 fix conflict 2025-11-11 16:12:35 +03:30
SamSys
05abc67cdd add gatewaypayment test 2025-11-11 16:11:04 +03:30
3282825719 Merge branch 'Feature/roll-call/camera-api' 2025-11-10 09:52:29 +03:30
cd1cf93ad1 Merge remote-tracking branch 'origin/master' 2025-11-08 18:25:46 +03:30
adef1fc15a feat: update workshop_name assignment in Index.cshtml.cs to use the directory name instead of the full path 2025-11-08 15:29:58 +03:30
597f54c062 feat: update workshop_id assignment in Index.cshtml.cs to use dynamic workshop name from directory path 2025-11-08 15:04:49 +03:30
c0ead0a917 feat: refactor CreateDadmehrWorkshopFaceEmbedding method to handle subdirectories and improve image processing logic 2025-11-08 12:37:23 +03:30
59284ffd29 feat: enhance CameraController with refined roll call enter/exit endpoints and HTTP client integration 2025-11-08 12:17:34 +03:30
5c7dd76e3f feat: add roll call functionality to CameraController with enter and exit endpoints 2025-11-07 15:04:24 +03:30
dff6bc2541 feat: add SMS settings configuration and refactor SMS sending methods for institution creation verification 2025-11-06 12:37:06 +03:30
22b67b344a feat: update WorkshopEmbedding method and enhance EmployeeFaceEmbedding model with additional properties 2025-11-06 10:02:11 +03:30
SamSys
d8b432ca1e Admin Report ---> bug fixed 2025-11-05 19:17:24 +03:30
f4853b6f39 feat: add EmployeeFaceEmbedding integration to CameraController and application logic 2025-11-05 17:56:37 +03:30
6ab418c4ab feat: implement EmployeeFaceEmbedding model and application logic for managing embeddings 2025-11-05 14:50:44 +03:30
SamSys
74dca1d2d2 Merge branch 'master' of https://github.com/samsyntax24/OriginalGozareshgir 2025-11-04 17:38:29 +03:30
SamSys
a9b4eb6195 some change report admin 2025-11-04 17:37:22 +03:30
SamSys
2125e15fb9 Admin Repoert --> add EmployeeOptionsCheck to report 2025-11-04 17:27:55 +03:30
b7f7d3b223 feat: add HasLeft property to employee settings and update related logic in group settings 2025-11-04 12:15:11 +03:30
752c7c72ab feat: add EmployeeFaceEmbedding model and related metadata classes 2025-11-03 20:06:28 +03:30
18c27d7a9a fix dates js error 2025-11-02 11:05:27 +03:30
73da938bc9 feat: add authentication check to WorkshopEmbedding endpoint 2025-11-02 10:36:29 +03:30
SamSys
c080e11fe0 Merge branch 'master' of https://github.com/samsyntax24/OriginalGozareshgir 2025-11-01 13:23:04 +03:30
SamSys
0eb9ecc373 client checkou warning message FrontEnd 2025-11-01 13:21:41 +03:30
470651cb76 feat: add method to remove roll call employee statuses and update handling of left work dates 2025-10-29 18:43:23 +03:30
2a9d9574e3 feat: filter employers in institution contract repository to exclude specific contracting party 2025-10-29 12:06:17 +03:30
SamSys
7b1542d5c6 Merge branch 'InsuranceEmployeeShareoCheckout' 2025-10-29 11:11:52 +03:30
SamSys
981fd2d4ee Merge branch 'master' of https://github.com/samsyntax24/OriginalGozareshgir 2025-10-29 11:10:15 +03:30
SamSys
7f3f785e39 InsuranceEmployeeShare comput on checkout completed 2025-10-28 19:10:31 +03:30
ca1ef420af feat: add exception for Amir's pizza workshop to adjust roll call date handling 2025-10-28 17:31:43 +03:30
d7baf358cc Merge branch 'Feature/InstitutionContract/print-api' 2025-10-28 14:58:03 +03:30
SamSys
676c8d2fa6 add CheckoutWarningMessage 2025-10-28 14:56:54 +03:30
SamSys
632ab3631b added UseWebSockets 2025-10-28 13:16:56 +03:30
c7bace728e feat: integrate workshop repository for roll call workflows 2025-10-28 12:31:08 +03:30
08574b5bb5 fix: update application URL in launchSettings for local development 2025-10-28 09:34:13 +03:30
288e3a8988 feat: add workshop embedding endpoint to retrieve embeddings.json 2025-10-28 09:33:09 +03:30
8134216a4a feat: update roll call links to use dynamic domain 2025-10-27 16:46:09 +03:30
SamSys
3d013cfa60 compute insuranceEmployeeShare on checkout 2025-10-27 16:41:02 +03:30
30bfc96cbe Merge branch 'Feature/roll-call/admin-report-api' 2025-10-27 16:29:37 +03:30
5d55118c3c feat: add endpoint to retrieve distinct workshops for roll call reporting 2025-10-27 13:25:20 +03:30
280db87408 Merge branch 'Feature/InstitutionContract/print-api' 2025-10-26 14:00:18 +03:30
c5a1e5c274 feat: implement RollCallController and enhance workshop roll call reporting functionality 2025-10-26 11:23:51 +03:30
4c6de6a76f refactor: improve sorting logic in Fine, Loan, and Reward repositories 2025-10-25 17:25:08 +03:30
25c7b67eb5 feat: extend SMS service to include contracting party and institution contract IDs in verification link and code methods 2025-10-25 14:18:04 +03:30
19b390b17d refactor: update employee sorting logic by color for improved clarity 2025-10-25 12:08:27 +03:30
026d8da74a feat: implement camera login functionality and related API endpoints 2025-10-25 08:53:51 +03:30
MahanCh
31defcde7e add financialInvoice Module 2025-07-15 13:32:41 +03:30
MahanCh
a4dbb016d2 add financial invoice 2025-07-14 14:32:58 +03:30
114 changed files with 509529 additions and 1442 deletions

View File

@@ -0,0 +1,15 @@
namespace _0_Framework.Application.Enums;
public enum TypeOfCheckoutWarning
{
/// <summary>
/// هشدار های متفرقه
/// </summary>
OthersWarning,
/// <summary>
/// هشدار سهم بیمه کارگر
/// </summary>
InsuranceEmployeeShare,
}

View File

@@ -39,7 +39,7 @@ public class AqayePardakhtPaymentGateway:IPaymentGateway
amount = command.Amount,
callback = command.CallBackUrl,
card_number = command.CardNumber,
invoice_id = command.InvoiceId,
invoice_id = command.TransactionId,
mobile = command.Mobile,
email = command.Email??"",
description = command.Description,
@@ -73,7 +73,7 @@ public class AqayePardakhtPaymentGateway:IPaymentGateway
amount = command.Amount,
callback = command.CallBackUrl,
card_number = command.Amount,
invoice_id = command.InvoiceId,
invoice_id = command.TransactionId,
mobile = command.Mobile,
email = command.Email,
description = command.Email,

View File

@@ -29,9 +29,11 @@ public class PaymentGatewayResponse
public int? ErrorCode { get; set; }
[JsonPropertyName("transid")]
public string TransactionId { get; set; }
public string Token { get; set; }
public bool IsSuccess => Status == "success";
public bool IsSuccess { get; set; }
public string Message { get; set; }
}
public class WalletAmountResponse
@@ -47,16 +49,19 @@ public class WalletAmountResponse
public class CreatePaymentGatewayRequest
{
public double Amount { get; set; }
public string TransactionId { get; set; }
public string CallBackUrl { get; set; }
public string InvoiceId { get; set; }
public string CardNumber { get; set; }
public string Mobile { get; set; }
public string Email { get; set; }
public string Description { get; set; }
public long FinancialInvoiceId { get; set; }
public IDictionary<string, object> ExtraData { get; set; }
}
public class VerifyPaymentGateWayRequest
{
public string TransactionId { get; set; }
public string DigitalReceipt { get; set; }
public string TransactionId { get; set; }
public double Amount { get; set; }
}

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace _0_Framework.Application.PaymentGateway;
public class SepehrPaymentGateway:IPaymentGateway
{
private readonly HttpClient _httpClient;
private const long TerminalId = 99213700;
public SepehrPaymentGateway(IHttpClientFactory httpClient)
{
_httpClient = httpClient.CreateClient();
_httpClient.BaseAddress = new Uri("https://sepehr.shaparak.ir/Rest/V1/PeymentApi/");
}
public async Task<PaymentGatewayResponse> Create(CreatePaymentGatewayRequest command, CancellationToken cancellationToken = default)
{
command.ExtraData ??= new Dictionary<string, object>();
command.ExtraData.Add("financialInvoiceId", command.FinancialInvoiceId);
var extraData = JsonConvert.SerializeObject(command.ExtraData);
var res = await _httpClient.PostAsJsonAsync("GetToken", new
{
TerminalID = TerminalId,
Amount = command.Amount,
InvoiceID = command.TransactionId,
callbackURL = command.CallBackUrl,
payload = extraData
}, cancellationToken: cancellationToken);
// خواندن محتوای پاسخ
var content = await res.Content.ReadAsStringAsync(cancellationToken);
// تبدیل پاسخ JSON به آبجکت دات‌نت
var json = System.Text.Json.JsonDocument.Parse(content);
// گرفتن مقدار AccessToken
var accessToken = json.RootElement.GetProperty("Accesstoken").ToString();
var status = json.RootElement.GetProperty("Status").ToString();
return new PaymentGatewayResponse
{
Status = status,
IsSuccess = status == "0",
Token = accessToken
};
}
public string GetStartPayUrl(string token)=>
$"https://sepehr.shaparak.ir/Payment/Pay?token={token}&terminalId={TerminalId}";
public async Task<PaymentGatewayResponse> Verify(VerifyPaymentGateWayRequest command, CancellationToken cancellationToken = default)
{
var res = await _httpClient.PostAsJsonAsync("Advice", new
{
digitalreceipt = command.DigitalReceipt,
Tid = TerminalId,
}, cancellationToken: cancellationToken);
// خواندن محتوای پاسخ
var content = await res.Content.ReadAsStringAsync(cancellationToken);
// تبدیل پاسخ JSON به آبجکت دات‌نت
var json = System.Text.Json.JsonDocument.Parse(content);
var message = json.RootElement.GetProperty("Message").GetString();
var status = json.RootElement.GetProperty("Status").GetString();
return new PaymentGatewayResponse
{
Status = status,
IsSuccess = status.ToLower() == "ok",
Message = message
};
}
public Task<PaymentGatewayResponse> CreateSandBox(CreatePaymentGatewayRequest command, CancellationToken cancellationToken = default)
{
throw new System.NotImplementedException();
}
public string GetStartPaySandBoxUrl(string transactionId)
{
throw new System.NotImplementedException();
}
public Task<WalletAmountResponse> GetWalletAmount(CancellationToken cancellationToken)
{
throw new System.NotImplementedException();
}
}

View File

@@ -27,9 +27,10 @@ public interface ISmsService
Task<double> GetCreditAmount();
public Task<bool> SendInstitutionVerificationLink(string number,string fullName, Guid institutionId);
public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId);
public Task<bool> SendInstitutionVerificationCode(string number, string code);
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
long contractingPartyId, long institutionContractId);
#endregion

View File

@@ -66,4 +66,11 @@ public interface IAccountApplication
public bool CheckExistClientAccount(string userName);
List<AccountViewModel> GetAdminAccountsNew();
void CameraLogin(CameraLoginRequest request);
}
public class CameraLoginRequest
{
public string UserName { get; set; }
public string Password { get; set; }
}

View File

@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using Company.Domain.WorkshopAgg;
using System.Security.Claims;
using _0_Framework.Exceptions;
using AccountManagement.Domain.PositionAgg;
using AccountManagement.Domain.SubAccountAgg;
using AccountManagement.Domain.SubAccountPermissionSubtitle1Agg;
@@ -803,4 +804,29 @@ public class AccountApplication : IAccountApplication
{
return _accountRepository.GetAdminAccountsNew();
}
public void CameraLogin(CameraLoginRequest request)
{
var cameraAccount = _cameraAccountRepository.GetBy(request.UserName);
if (cameraAccount == null)
{
throw new BadRequestException(ApplicationMessages.WrongUserPass);
}
(bool Verified, bool NeedUpgrade) result = _passwordHasher.Check(cameraAccount.Password, request.Password);
if (!result.Verified)
throw new BadRequestException(ApplicationMessages.WrongUserPass);
var mobile = string.IsNullOrWhiteSpace(cameraAccount.Mobile) ? " " : cameraAccount.Mobile;
var authViewModel = new CameraAuthViewModel(cameraAccount.id, cameraAccount.WorkshopId,
cameraAccount.Username, mobile, cameraAccount.WorkshopName, cameraAccount.AccountId,
cameraAccount.IsActiveSting);
if (cameraAccount.IsActiveSting != "true")
throw new BadRequestException(ApplicationMessages.WrongUserPass);
_authHelper.CameraSignIn(authViewModel);
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.AccessControl;
using _0_Framework.Application;
using _0_Framework.Domain;
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
@@ -12,25 +13,25 @@ namespace Company.Domain.CheckoutAgg;
public class Checkout : EntityBase
{
private Checkout()
{
}
public Checkout()
{
}
public Checkout(string employeeFullName, string fathersName, string nationalCode, string dateOfBirth,
long employeeId, string workshopName, long workshopId, string contractNo, DateTime contractStart,
DateTime contractEnd, string month, string year, long contractId, long workingHoursId,
DateTime contractEnd, string month, string year, long contractId, long workingHoursId,
double monthlySalary, double baseYearsPay, double consumableItems, double housingAllowance,
double overtimePay, double nightworkPay, double fridayPay, double missionPay, double shiftPay,
double familyAllowance, double bonusesPay, double yearsPay, double leavePay,
double insuranceDeduction, double taxDeducation, double installmentDeduction,
double salaryAidDeduction, double absenceDeduction, string sumOfWorkingDays
, string archiveCode, string personnelCode,
, string archiveCode, string personnelCode,
string totalClaims, string totalDeductions, double totalPayment, string signature, double marriedAllowance, bool leaveCheckout,
double creditLeaves, double absencePeriod, double averageHoursPerDay, bool hasRollCall, string overTimeWorkvalue,
string overNightWorkValue, string fridayWorkValue, string rotatingShifValue, string absenceValue,
string totalDayOfLeaveCompute, string totalDayOfYearsCompute, string totalDayOfBunosesCompute,
ICollection<CheckoutLoanInstallment> loanInstallments,
ICollection<CheckoutSalaryAid> salaryAids,CheckoutRollCall checkoutRollCall,TimeSpan employeeMandatoryHours)
ICollection<CheckoutSalaryAid> salaryAids, CheckoutRollCall checkoutRollCall, TimeSpan employeeMandatoryHours, bool hasInsuranceShareTheSameAsList)
{
EmployeeFullName = employeeFullName;
FathersName = fathersName;
@@ -91,6 +92,7 @@ public class Checkout : EntityBase
SalaryAids = salaryAids;
CheckoutRollCall = checkoutRollCall;
EmployeeMandatoryHours = employeeMandatoryHours;
HasInsuranceShareTheSameAsList = hasInsuranceShareTheSameAsList;
}
@@ -99,7 +101,7 @@ public class Checkout : EntityBase
public string Signature { get; private set; }
public string FathersName { get; private set; }
public string NationalCode { get; private set; }
public string DateOfBirth { get; private set; }
public string DateOfBirth { get; private set; }
public long EmployeeId { get; private set; }
public string WorkshopName { get; private set; }
@@ -135,7 +137,7 @@ public class Checkout : EntityBase
public double SalaryAidDeduction { get; private set; }
public double AbsenceDeduction { get; private set; }
public string SumOfWorkingDays { get; private set; }
public string ArchiveCode { get; private set; }
public string PersonnelCode { get; private set; }
@@ -157,58 +159,70 @@ public class Checkout : EntityBase
//میانگین ساعت کار در یک روز
public double AverageHoursPerDay { get; private set; }
public bool HasRollCall { get; private set; }
/// <summary>
/// مقدار اضافه کار
/// </summary>
/// <summary>
/// مقدار اضافه کار
/// </summary>
public string OverTimeWorkValue { get; private set; }
/// <summary>
/// مقدار شبکاری
/// </summary>
/// <summary>
/// مقدار شبکاری
/// </summary>
public string OverNightWorkValue { get; private set; }
/// <summary>
/// مقدار جمعه کاری
/// </summary>
public string FridayWorkValue { get; private set; }
/// <summary>
/// درصد نوبت کاری
/// </summary>
public string RotatingShiftValue { get; private set; }
/// <summary>
/// <summary>
/// مقدار جمعه کاری
/// </summary>
public string FridayWorkValue { get; private set; }
/// <summary>
/// درصد نوبت کاری
/// </summary>
public string RotatingShiftValue { get; private set; }
/// <summary>
/// مقدار غیبت
/// </summary>
public string AbsenceValue { get; private set; }
public string AbsenceValue { get; private set; }
/// <summary>
/// تعداد روزهای محاسبه شده برای مزد مرخصی
/// </summary>
public string TotalDayOfLeaveCompute { get; private set; }
/// <summary>
/// تعداد روزهای محاسبه شده برای سنوات
/// </summary>
public string TotalDayOfYearsCompute { get; private set; }
/// <summary>
/// تعداد روزهای محاسبه شده برای عیدی و پاداش
/// </summary>
public string TotalDayOfBunosesCompute { get; private set; }
/// <summary>
/// تعداد روزهای محاسبه شده برای مزد مرخصی
/// </summary>
public string TotalDayOfLeaveCompute { get; private set; }
/// <summary>
/// تعداد روزهای محاسبه شده برای سنوات
/// </summary>
public string TotalDayOfYearsCompute { get; private set; }
/// <summary>
/// تعداد روزهای محاسبه شده برای عیدی و پاداش
/// </summary>
public string TotalDayOfBunosesCompute { get; private set; }
/// <summary>
/// دارای تداخل مبلغ است. این در زمانی اتفاق می افتد که فیش مبلغ آن تغییر کرده ولی به دلیل مسائل قانونی امکان صدور دوباره آن وجود ندارد
/// </summary>
public bool HasAmountConflict { get; private set; }
/// <summary>
/// دارای تداخل مبلغ است. این در زمانی اتفاق می افتد که فیش مبلغ آن تغییر کرده ولی به دلیل مسائل قانونی امکان صدور دوباره آن وجود ندارد
/// </summary>
public bool HasAmountConflict { get; private set; }
/// <summary>
/// ساعت موظفی پرسنل در ماه
/// </summary>
/// <summary>
/// ساعت موظفی پرسنل در ماه
/// </summary>
public TimeSpan EmployeeMandatoryHours { get; set; }
#region valueObjects
public ICollection<CheckoutLoanInstallment> LoanInstallments { get; set; } = [];
public ICollection<CheckoutSalaryAid> SalaryAids { get; set; } = [];
/// <summary>
/// آیا حق بیمه مشابه لیست بیمه حساب شده؟
/// </summary>
public bool HasInsuranceShareTheSameAsList { get; private set; }
/// <summary>
/// آیا فیش نیاز به بروزرسانی دارد
/// </summary>
public bool IsUpdateNeeded { get; private set; }
public List<CheckoutWarningMessage> CheckoutWarningMessageList { get; set; }
#region valueObjects
public ICollection<CheckoutLoanInstallment> LoanInstallments { get; set; } = [];
public ICollection<CheckoutSalaryAid> SalaryAids { get; set; } = [];
public CheckoutRollCall CheckoutRollCall { get; private set; }
#endregion
@@ -277,7 +291,7 @@ public class Checkout : EntityBase
var year = contarctStart.ToFarsiYear();
var sumYear = year.Substring(Math.Max(0, year.Length - 2));
ContractNo = archiveCode + "/" + personnelCode + "/" + sumYear + "/" + month;
}
public void Active()
@@ -312,7 +326,7 @@ public class Checkout : EntityBase
}
public void SetSalaryAid(ICollection<CheckoutSalaryAid> salaryAids,double salaryAidAmount)
public void SetSalaryAid(ICollection<CheckoutSalaryAid> salaryAids, double salaryAidAmount)
{
SalaryAids = salaryAids;
SalaryAidDeduction = salaryAidAmount;
@@ -330,30 +344,45 @@ public class Checkout : EntityBase
public void SetAmountConflict(bool hasAmountConflict)
{
HasAmountConflict = hasAmountConflict;
HasAmountConflict = hasAmountConflict;
}
public void SetEmployeeMandatoryHours(TimeSpan employeeMandatoryHours)
{
EmployeeMandatoryHours = employeeMandatoryHours;
}
public void SetInsuranceShare()
{
HasInsuranceShareTheSameAsList = true;
}
/// <summary>
/// نیاز به آپدیت
/// </summary>
public void SetUpdateNeeded()
{
IsUpdateNeeded = true;
}
}
public class CheckoutRollCall
{
private CheckoutRollCall(){}
public CheckoutRollCall(TimeSpan totalMandatoryTimeSpan, TimeSpan totalPresentTimeSpan, TimeSpan totalBreakTimeSpan,
TimeSpan totalWorkingTimeSpan, TimeSpan totalPaidLeaveTmeSpan, TimeSpan totalSickLeaveTimeSpan,
ICollection<CheckoutRollCallDay> rollCallDaysCollection)
{
TotalMandatoryTimeSpan = totalMandatoryTimeSpan;
TotalPresentTimeSpan = totalPresentTimeSpan;
TotalBreakTimeSpan = totalBreakTimeSpan;
TotalWorkingTimeSpan = totalWorkingTimeSpan;
TotalPaidLeaveTmeSpan = totalPaidLeaveTmeSpan;
TotalSickLeaveTimeSpan = totalSickLeaveTimeSpan;
RollCallDaysCollection = rollCallDaysCollection;
}
private CheckoutRollCall() { }
public CheckoutRollCall(TimeSpan totalMandatoryTimeSpan, TimeSpan totalPresentTimeSpan, TimeSpan totalBreakTimeSpan,
TimeSpan totalWorkingTimeSpan, TimeSpan totalPaidLeaveTmeSpan, TimeSpan totalSickLeaveTimeSpan,
ICollection<CheckoutRollCallDay> rollCallDaysCollection)
{
TotalMandatoryTimeSpan = totalMandatoryTimeSpan;
TotalPresentTimeSpan = totalPresentTimeSpan;
TotalBreakTimeSpan = totalBreakTimeSpan;
TotalWorkingTimeSpan = totalWorkingTimeSpan;
TotalPaidLeaveTmeSpan = totalPaidLeaveTmeSpan;
TotalSickLeaveTimeSpan = totalSickLeaveTimeSpan;
RollCallDaysCollection = rollCallDaysCollection;
}
/// <summary>
@@ -394,27 +423,27 @@ public class CheckoutRollCall
public class CheckoutRollCallDay
{
private CheckoutRollCallDay(){}
public CheckoutRollCallDay(DateTime date, string firstStartDate, string firstEndDate,
string secondStartDate, string secondEndDate, TimeSpan breakTimeSpan,
bool isSliced, TimeSpan workingTimeSpan, bool isAbsent, bool isFriday,
bool isHoliday, string leaveType)
{
Date = date;
FirstStartDate = firstStartDate;
FirstEndDate = firstEndDate;
SecondStartDate = secondStartDate;
SecondEndDate = secondEndDate;
BreakTimeSpan = breakTimeSpan;
IsSliced = isSliced;
WorkingTimeSpan = workingTimeSpan;
IsAbsent = isAbsent;
IsFriday = isFriday;
IsHoliday = isHoliday;
LeaveType = leaveType;
}
private CheckoutRollCallDay() { }
public CheckoutRollCallDay(DateTime date, string firstStartDate, string firstEndDate,
string secondStartDate, string secondEndDate, TimeSpan breakTimeSpan,
bool isSliced, TimeSpan workingTimeSpan, bool isAbsent, bool isFriday,
bool isHoliday, string leaveType)
{
Date = date;
FirstStartDate = firstStartDate;
FirstEndDate = firstEndDate;
SecondStartDate = secondStartDate;
SecondEndDate = secondEndDate;
BreakTimeSpan = breakTimeSpan;
IsSliced = isSliced;
WorkingTimeSpan = workingTimeSpan;
IsAbsent = isAbsent;
IsFriday = isFriday;
IsHoliday = isHoliday;
LeaveType = leaveType;
}
public long Id { get; set; }
public long Id { get; set; }
/// <summary>
/// تاریخ
@@ -458,12 +487,12 @@ public class CheckoutRollCallDay
/// <summary>
/// آیا غیبت است
/// </summary>
public bool IsAbsent { get; private set; }
public bool IsAbsent { get; private set; }
/// <summary>
/// آیا جمعه است
/// </summary>
public bool IsFriday { get; private set; }
public bool IsFriday { get; private set; }
/// <summary>
/// آیا تعطیل رسمی است
@@ -475,6 +504,6 @@ public class CheckoutRollCallDay
/// </summary>
public string LeaveType { get; private set; }
public long CheckoutId { get; set; }
public long CheckoutId { get; set; }
}

View File

@@ -0,0 +1,32 @@
using _0_Framework.Application.Enums;
using _0_Framework.Domain;
namespace Company.Domain.CheckoutAgg;
public class CheckoutWarningMessage : EntityBaseWithoutCreationDate
{
public CheckoutWarningMessage(string warningMessage, long checkoutId, TypeOfCheckoutWarning typeOfCheckoutWarning)
{
WarningMessage = warningMessage;
CheckoutId = checkoutId;
TypeOfCheckoutWarning = typeOfCheckoutWarning;
}
/// <summary>
/// پیام هشدار
/// </summary>
public string WarningMessage { get; private set; }
/// <summary>
/// آی دی فیش حقوقی
/// </summary>
public long CheckoutId { get; private set; }
/// <summary>
/// نوع هشدار فیش حقوقی
/// </summary>
public TypeOfCheckoutWarning TypeOfCheckoutWarning { get; private set; }
public Checkout Checkout { get; set; }
}

View File

@@ -0,0 +1,189 @@
using System;
using System.Collections.Generic;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace Company.Domain.EmployeeFaceEmbeddingAgg;
public class EmployeeFaceEmbedding
{
public EmployeeFaceEmbedding()
{
EmbeddingHistory = new List<EmbeddingHistoryItem>();
MetadataHistory = new List<MetadataHistoryItem>();
}
public EmployeeFaceEmbedding(string employeeFullName, long employeeId, long workshopId,
List<double> embeddings, EmployeeFaceEmbeddingMetadata metadata)
{
Id = Guid.NewGuid().ToString();
EmployeeFullName = employeeFullName;
EmployeeId = employeeId;
WorkshopId = workshopId;
Embeddings = embeddings;
Metadata = metadata;
EmbeddingHistory = new List<EmbeddingHistoryItem>();
MetadataHistory = new List<MetadataHistoryItem>();
CreatedAt = DateTime.UtcNow;
UpdatedAt = DateTime.UtcNow;
}
[BsonId]
[BsonRepresentation(BsonType.String)]
public string Id { get; set; }
[BsonElement("employeeFullName")]
public string EmployeeFullName { get; set; }
[BsonElement("employeeId")]
public long EmployeeId { get; set; }
[BsonElement("workshopId")]
public long WorkshopId { get; set; }
[BsonElement("embeddings")]
public List<double> Embeddings { get; set; }
[BsonElement("metadata")]
public EmployeeFaceEmbeddingMetadata Metadata { get; set; }
[BsonElement("embeddingHistory")]
public List<EmbeddingHistoryItem> EmbeddingHistory { get; set; }
[BsonElement("metadataHistory")]
public List<MetadataHistoryItem> MetadataHistory { get; set; }
[BsonElement("createdAt")]
public DateTime CreatedAt { get; set; }
[BsonElement("updatedAt")]
public DateTime UpdatedAt { get; set; }
public void UpdateEmbedding(List<double> newEmbedding, double confidence, double refinementPercentage)
{
if (Embeddings != null)
{
EmbeddingHistory.Add(new EmbeddingHistoryItem
{
Embedding = new List<double>(Embeddings),
Timestamp = DateTime.UtcNow,
Confidence = confidence,
RefinementPercentage = refinementPercentage
});
}
Embeddings = newEmbedding;
UpdatedAt = DateTime.UtcNow;
}
public void UpdateMetadata(EmployeeFaceEmbeddingMetadata newMetadata, double confidence, double refinementPercentage)
{
if (Metadata != null)
{
MetadataHistory.Add(new MetadataHistoryItem
{
Metadata = Metadata,
Timestamp = DateTime.UtcNow,
Confidence = confidence,
RefinementPercentage = refinementPercentage
});
}
Metadata = newMetadata;
UpdatedAt = DateTime.UtcNow;
}
public void UpdateEmployeeInfo(string employeeFullName, long workshopId)
{
EmployeeFullName = employeeFullName;
WorkshopId = workshopId;
UpdatedAt = DateTime.UtcNow;
}
}
public class EmployeeFaceEmbeddingMetadata
{
[BsonElement("avg_eye_distance_normalized")]
public double AvgEyeDistanceNormalized { get; set; }
[BsonElement("avg_eye_to_face_ratio")]
public double AvgEyeToFaceRatio { get; set; }
[BsonElement("avg_face_aspect_ratio")]
public double AvgFaceAspectRatio { get; set; }
[BsonElement("avg_detection_confidence")]
public double AvgDetectionConfidence { get; set; }
[BsonElement("avg_keypoints_normalized")]
public EmployeeFaceEmbeddingKeypoints AvgKeypointsNormalized { get; set; }
[BsonElement("per_image_metadata")]
public List<ImageMetadata> PerImageMetadata { get; set; }
}
public class EmployeeFaceEmbeddingKeypoints
{
[BsonElement("left_eye")]
public double[] LeftEye { get; set; }
[BsonElement("right_eye")]
public double[] RightEye { get; set; }
[BsonElement("nose")]
public double[] Nose { get; set; }
[BsonElement("mouth_left")]
public double[] MouthLeft { get; set; }
[BsonElement("mouth_right")]
public double[] MouthRight { get; set; }
}
public class ImageMetadata
{
[BsonElement("face_aspect_ratio")]
public double FaceAspectRatio { get; set; }
[BsonElement("eye_distance_normalized")]
public double EyeDistanceNormalized { get; set; }
[BsonElement("eye_to_face_ratio")]
public double EyeToFaceRatio { get; set; }
[BsonElement("detection_confidence")]
public double DetectionConfidence { get; set; }
[BsonElement("keypoints_normalized")]
public EmployeeFaceEmbeddingKeypoints KeypointsNormalized { get; set; }
}
public class EmbeddingHistoryItem
{
[BsonElement("embedding")]
public List<double> Embedding { get; set; }
[BsonElement("timestamp")]
public DateTime Timestamp { get; set; }
[BsonElement("confidence")]
public double Confidence { get; set; }
[BsonElement("refinementPercentage")]
public double RefinementPercentage { get; set; }
}
public class MetadataHistoryItem
{
[BsonElement("metadata")]
public EmployeeFaceEmbeddingMetadata Metadata { get; set; }
[BsonElement("timestamp")]
public DateTime Timestamp { get; set; }
[BsonElement("confidence")]
public double Confidence { get; set; }
[BsonElement("refinementPercentage")]
public double RefinementPercentage { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Company.Domain.EmployeeFaceEmbeddingAgg;
public interface IEmployeeFaceEmbeddingRepository
{
Task CreateAsync(EmployeeFaceEmbedding employeeFaceEmbedding);
Task UpdateAsync(EmployeeFaceEmbedding employeeFaceEmbedding);
Task<EmployeeFaceEmbedding> GetByIdAsync(string id);
Task<EmployeeFaceEmbedding> GetByEmployeeIdAsync(long employeeId);
Task<List<EmployeeFaceEmbedding>> GetByWorkshopIdAsync(long workshopId);
Task<List<EmployeeFaceEmbedding>> GetByWorkshopIdsAsync(List<long> workshopIds);
Task DeleteAsync(string id);
}

View File

@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using _0_Framework.Domain;
using Company.Domain.PaymentTransactionAgg;
using CompanyManagment.App.Contracts.FinancialInvoice;
namespace Company.Domain.FinancialInvoiceAgg;
public class FinancialInvoice : EntityBase
{
public string InvoiceNumber { get; private set; }
public string Description { get; set; }
public FinancialInvoiceStatus Status { get; private set; }
public DateTime? PaidAt { get; private set; }
public double Amount { get; private set; }
public Guid PublicId { get; private set; }
public bool IsActive { get; set; }
public List<PaymentTransaction> PaymentTransactions { get; private set; }
public long ContractingPartyId { get; private set; }
public List<FinancialInvoiceItem> Items { get; private set; }
public FinancialInvoice(double amount, long contractingPartyId, string description)
{
InvoiceNumber = GenerateInvoiceNumber();
Status = FinancialInvoiceStatus.Unpaid;
Amount = amount;
PublicId = Guid.NewGuid();
ContractingPartyId = contractingPartyId;
Description = description;
IsActive = true;
Items = [];
PaymentTransactions = [];
}
public void AddItem(FinancialInvoiceItem item)
{
Items ??= [];
Items.Add(item);
}
public void SetItems(List<FinancialInvoiceItem> items)
{
Items = items;
}
public void SetPaid(DateTime paidAt)
{
Status = FinancialInvoiceStatus.Paid;
PaidAt = paidAt;
}
public void SetUnpaid()
{
Status = FinancialInvoiceStatus.Unpaid;
PaidAt = null;
}
public void SetCancelled()
{
Status = FinancialInvoiceStatus.Cancelled;
PaidAt = null;
}
public void SetRefunded()
{
Status = FinancialInvoiceStatus.Refunded;
PaidAt = null;
}
public void DeActivate()
{
IsActive = false;
}
public void SetInvoiceNumber(string invoiceNumber)
{
InvoiceNumber = invoiceNumber;
}
private string GenerateInvoiceNumber()
{
var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
var random = new Random().Next(1000, 9999);
return $"GZ_{timestamp}{random}";
}
}
public class FinancialInvoiceItem : EntityBase
{
public string Description { get; private set; }
public double Amount { get; private set; }
public FinancialInvoiceItemType Type { get; set; }
public long EntityId { get; set; }
public FinancialInvoice FinancialInvoice { get; set; }
public long FinancialInvoiceId { get; set; }
public FinancialInvoiceItem(string description, double amount,
long financialInvoiceId, FinancialInvoiceItemType type, long entityId)
{
Description = description;
Amount = amount;
FinancialInvoiceId = financialInvoiceId;
Type = type;
EntityId = entityId;
}
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.FinancialInvoice;
namespace Company.Domain.FinancialInvoiceAgg;
public interface IFinancialInvoiceRepository : IRepository<long, FinancialInvoice>
{
EditFinancialInvoice GetDetails(long id);
List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel);
Task<FinancialInvoice> GetUnPaidByEntityId(long entityId, FinancialInvoiceItemType financialInvoiceItemType);
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _0_Framework.Domain;
using Company.Domain.FinancialInvoiceAgg;
using Company.Domain.FinancialTransactionAgg;
namespace Company.Domain.FinancialStatmentAgg;

View File

@@ -22,6 +22,8 @@ public interface IFinancialStatmentRepository : IRepository<long, FinancialStatm
Task<OperationResult<ClientFinancialStatementViewModel>> GetDetailsByPublicId(string publicId);
Task<GetFinancialStatementBalanceAmount> GetBalanceAmount(long id);
Task<double> GetClientDebtAmount(long accountId);
Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel);
Task<double> GetClientDebtAmountByContractingPartyId(long contractingPartyId);
Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel);
Task<FinancialStatment> GetByContractingPartyId(long contractingPartyId);
}

View File

@@ -51,6 +51,14 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
List<EmployeeInsurancListDataViewModel> GetEmployeeInsuranceDataAmonthAgo(DateTime currentMonthStartDate, long workshopId);
#endregion
/// <summary>
/// دریافت اطلاعات بیمه کارکنان برای استفاده در فیش حقوقی
/// </summary>
/// <param name="startDate"></param>
/// <param name="workshopId"></param>
/// <returns></returns>
List<EmployeeInsurancListDataViewModel> EmployeeInsuranceDataBy(DateTime startDate, long workshopId);
/// <summary>
/// بدست آوردن اطلاعات محاسباتی ماه پرسنل برای ویرایش
/// </summary>

View File

@@ -1,5 +1,6 @@
using System;
using _0_Framework.Domain;
using Company.Domain.FinancialInvoiceAgg;
using CompanyManagment.App.Contracts.PaymentTransaction;
namespace Company.Domain.PaymentTransactionAgg;
@@ -9,22 +10,25 @@ namespace Company.Domain.PaymentTransactionAgg;
/// </summary>
public class PaymentTransaction:EntityBase
{
/// <summary>
/// سازنده کلاس PaymentTransaction با دریافت اطلاعات تراکنش.
/// </summary>
/// <param name="contractingPartyId">شناسه طرف قرارداد</param>
/// <param name="amount">مبلغ تراکنش</param>
/// <param name="contractingPartyName"></param>
/// <param name="callBackUrl"></param>
public PaymentTransaction(long contractingPartyId,
/// <summary>
/// سازنده کلاس PaymentTransaction با دریافت اطلاعات تراکنش.
/// </summary>
/// <param name="contractingPartyId">شناسه طرف قرارداد</param>
/// <param name="amount">مبلغ تراکنش</param>
/// <param name="contractingPartyName"></param>
/// <param name="callBackUrl"></param>
/// <param name="gateway"></param>
public PaymentTransaction(long contractingPartyId,
double amount,
string contractingPartyName,string callBackUrl)
string contractingPartyName,string callBackUrl,
PaymentTransactionGateWay gateway)
{
ContractingPartyId = contractingPartyId;
Status = PaymentTransactionStatus.Pending;
Amount = amount;
ContractingPartyName = contractingPartyName;
CallBackUrl = callBackUrl;
Gateway = gateway;
}
/// <summary>
@@ -68,13 +72,23 @@ public class PaymentTransaction:EntityBase
public string TransactionId { get; private set; }
public string CallBackUrl { get; private set; }
public PaymentTransactionGateWay Gateway { get; private set; }
public string Rrn { get; private set; }
public string DigitalReceipt { get; private set; }
public void SetPaid(string cardNumber,string bankName)
public FinancialInvoice FinancialInvoice { get; set; }
public long? FinancialInvoiceId { get; set; }
public void SetPaid(string cardNumber,string bankName,string rrn,string digitalReceipt)
{
Status = PaymentTransactionStatus.Success;
TransactionDate = DateTime.Now;
CardNumber = cardNumber;
BankName = bankName;
Rrn = rrn;
DigitalReceipt = digitalReceipt;
}
public void SetFailed()
{
@@ -85,4 +99,5 @@ public class PaymentTransaction:EntityBase
{
TransactionId = transactionId;
}
}
}

View File

@@ -11,21 +11,23 @@ namespace Company.Domain.ReportAgg
{
Task<AllReport> GetAllActiveWorkshopsNew(string year, string month);
AllReport GetAllActiveWorkshops(string year, string month);
WorkshopResult GetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList);
WorkshopResult GetWorkshopContractSignDone(string year, string month, long accountId, List<long> workshopList);
WorkshopResult GetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList);
WorkshopResult GetWorkshopCheckoutSignDone(string year, string month, long accountId, List<long> workshopList);
List<EmployeeNotDone> GetEmployeeContract(string year, string month, long workshopId);
List<EmployeeNotDone> GetEmployeeContractSign(string year, string month, long workshopId);
List<EmployeeNotDone> GetEmployeeCheckout(string year, string month, long workshopId);
List<EmployeeNotDone> GetEmployeeCheckoutSign(string year, string month, long workshopId);
PrintAllContractCheckout GetPrintAllContractDone(string year, string month, long accountId,
Task<WorkshopResult> GetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList);
Task<WorkshopResult> GetWorkshopContractSignDone(string year, string month, long accountId,
List<long> workshopList);
PrintAllContractCheckout GetPrintAllContractSignDone(string year, string month, long accountId,
Task<WorkshopResult> GetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList);
Task<WorkshopResult> GetWorkshopCheckoutSignDone(string year, string month, long accountId,
List<long> workshopList);
PrintAllContractCheckout GetPrintAllCheckoutDone(string year, string month, long accountId,
Task<List<EmployeeNotDone>> GetEmployeeContract(string year, string month, long workshopId);
Task<List<EmployeeNotDone>> GetEmployeeContractSign(string year, string month, long workshopId);
Task<List<EmployeeNotDone>> GetEmployeeCheckout(string year, string month, long workshopId);
Task<List<EmployeeNotDone>> GetEmployeeCheckoutSign(string year, string month, long workshopId);
Task<PrintAllContractCheckout> GetPrintAllContractDone(string year, string month, long accountId,
List<long> workshopList);
PrintAllContractCheckout GetPrintAllCheckoutSignDone(string year, string month, long accountId,
Task<PrintAllContractCheckout> GetPrintAllContractSignDone(string year, string month, long accountId,
List<long> workshopList);
Task<PrintAllContractCheckout> GetPrintAllCheckoutDone(string year, string month, long accountId,
List<long> workshopList);
Task<PrintAllContractCheckout> GetPrintAllCheckoutSignDone(string year, string month, long accountId,
List<long> workshopList);

View File

@@ -26,5 +26,6 @@ namespace Company.Domain.RollCallEmployeeStatusAgg
List<RollCallEmployeeStatusViewModel> GetActiveByWorkshopIdInDate(long workshopId, DateTime startDateGr, DateTime endDateGr);
List<RollCallEmployeeStatusViewModel> GetByWorkshopIdInDates(long workshopId, DateTime start, DateTime end);
bool IsActiveInPeriod(long employeeId, long workshopId, DateTime startDate, DateTime endDate);
}
void RemoveRange(IEnumerable<RollCallEmployeeStatus> rollCallEmployeeStatusList);
}
}

View File

@@ -5,7 +5,8 @@ namespace Company.Domain.SmsResultAgg;
public class SmsResult: EntityBase
{
public SmsResult(int messageId, string status,string typeOfSms, string contractingPartyName,string mobile, long contractingPatyId, long institutionContractId)
public SmsResult(int messageId, string status,string typeOfSms,
string contractingPartyName,string mobile, long contractingPatyId, long institutionContractId)
{
MessageId = messageId;
Status = status;

View File

@@ -0,0 +1,60 @@
using Company.Domain.EmployeeFaceEmbeddingAgg;
using MongoDB.Driver;
namespace CompanyManagement.Infrastructure.Mongo.EmployeeFaceEmbeddingRepo;
public class EmployeeFaceEmbeddingRepository : IEmployeeFaceEmbeddingRepository
{
private readonly IMongoCollection<EmployeeFaceEmbedding> _employeeFaceEmbeddings;
public EmployeeFaceEmbeddingRepository(IMongoDatabase database)
{
_employeeFaceEmbeddings = database.GetCollection<EmployeeFaceEmbedding>("EmployeeFaces");
}
public async Task CreateAsync(EmployeeFaceEmbedding employeeFaceEmbedding)
{
await _employeeFaceEmbeddings.InsertOneAsync(employeeFaceEmbedding);
}
public async Task UpdateAsync(EmployeeFaceEmbedding employeeFaceEmbedding)
{
await _employeeFaceEmbeddings.ReplaceOneAsync(
x => x.Id == employeeFaceEmbedding.Id,
employeeFaceEmbedding);
}
public async Task<EmployeeFaceEmbedding> GetByIdAsync(string id)
{
return await _employeeFaceEmbeddings
.Find(x => x.Id == id)
.FirstOrDefaultAsync();
}
public async Task<EmployeeFaceEmbedding> GetByEmployeeIdAsync(long employeeId)
{
return await _employeeFaceEmbeddings
.Find(x => x.EmployeeId == employeeId)
.FirstOrDefaultAsync();
}
public async Task<List<EmployeeFaceEmbedding>> GetByWorkshopIdAsync(long workshopId)
{
return await _employeeFaceEmbeddings
.Find(x => x.WorkshopId == workshopId)
.ToListAsync();
}
public async Task<List<EmployeeFaceEmbedding>> GetByWorkshopIdsAsync(List<long> workshopIds)
{
return await _employeeFaceEmbeddings
.Find(x => workshopIds.First()==x.WorkshopId)
.ToListAsync();
}
public async Task DeleteAsync(string id)
{
await _employeeFaceEmbeddings.DeleteOneAsync(x => x.Id == id);
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using _0_Framework.Application.Enums;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.Loan;
using CompanyManagment.App.Contracts.RollCall;
@@ -133,6 +134,15 @@ public class CheckoutViewModel
/// </summary>
public string TotalPaidLeave { get; set; }
/// <summary>
/// آیا فیش نیاز به بروزرسانی دارد
/// </summary>
public bool IsUpdateNeeded { get; set; }
/// <summary>
/// لیست پیام های هشدار فیش حقوقی
/// </summary>
public List<CheckoutWarningMessageModel> CheckoutWarningMessageList { get; set; }
public bool HasSignCheckout { get; set; }

View File

@@ -0,0 +1,25 @@
using _0_Framework.Application.Enums;
namespace CompanyManagment.App.Contracts.Checkout;
/// <summary>
/// مدل هشدار فیش حقوقی
/// </summary>
public class CheckoutWarningMessageModel
{
/// <summary>
/// پیام هشدار
/// </summary>
public string WarningMessage { get; set; }
/// <summary>
/// آی دی فیش حقوقی
/// </summary>
public long CheckoutId { get; set; }
/// <summary>
/// نوع هشدار فیش حقوقی
/// </summary>
public TypeOfCheckoutWarning TypeOfCheckoutWarning { get; set; }
}

View File

@@ -25,4 +25,5 @@ public class CustomizeWorkshopEmployeeSettingsViewModel
public int LeavePermittedDays { get; set; }
public ICollection<CustomizeRotatingShiftsViewModel> CustomizeRotatingShiftsViewModels { get; set; }
public List<DayOfWeek> WeeklyOffDays { get; set; }
public bool HasLeft { get; set; }
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
public class EmployeeFaceEmbeddingDto
{
public string Id { get; set; }
public string EmployeeFullName { get; set; }
public long EmployeeId { get; set; }
public long WorkshopId { get; set; }
public List<double> Embeddings { get; set; }
public EmployeeFaceEmbeddingMetadataDto Metadata { get; set; }
}

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
public class EmployeeFaceEmbeddingMetadataDto
{
public double AvgEyeDistanceNormalized { get; set; }
public double AvgEyeToFaceRatio { get; set; }
public double AvgFaceAspectRatio { get; set; }
public double AvgDetectionConfidence { get; set; }
public EmployeeFaceEmbeddingKeypointsDto AvgKeypointsNormalized { get; set; }
public List<ImageMetadataDto> PerImageMetadata { get; set; }
}
public class EmployeeFaceEmbeddingKeypointsDto
{
public double[] LeftEye { get; set; }
public double[] RightEye { get; set; }
public double[] Nose { get; set; }
public double[] MouthLeft { get; set; }
public double[] MouthRight { get; set; }
}
public class ImageMetadataDto
{
public double FaceAspectRatio { get; set; }
public double EyeDistanceNormalized { get; set; }
public double EyeToFaceRatio { get; set; }
public double DetectionConfidence { get; set; }
public EmployeeFaceEmbeddingKeypointsDto KeypointsNormalized { get; set; }
}
public class EmbeddingHistoryItemDto
{
public List<double> Embedding { get; set; }
public DateTime Timestamp { get; set; }
public double Confidence { get; set; }
public double RefinementPercentage { get; set; }
}
public class MetadataHistoryItemDto
{
public EmployeeFaceEmbeddingMetadataDto Metadata { get; set; }
public DateTime Timestamp { get; set; }
public double Confidence { get; set; }
public double RefinementPercentage { get; set; }
}

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
/// <summary>
/// سرویس مدیریت Embedding چهره کارکنان
/// این سرویس فقط برای دریافت و ارسال داده است و هیچ command-driven نیست
/// </summary>
public interface IEmployeeFaceEmbeddingApplication
{
/// <summary>
/// دریافت embedding بر اساس شناسه
/// </summary>
Task<EmployeeFaceEmbeddingDto> GetByIdAsync(string id);
/// <summary>
/// دریافت embedding بر اساس شناسه کارمند
/// </summary>
Task<EmployeeFaceEmbeddingDto> GetByEmployeeIdAsync(long employeeId);
/// <summary>
/// دریافت لیست embeddings بر اساس شناسه کارگاه
/// </summary>
Task<List<EmployeeFaceEmbeddingDto>> GetByWorkshopIdAsync(long workshopId);
/// <summary>
/// دریافت لیست embeddings بر اساس لیست شناسه کارگاه‌ها
/// </summary>
Task<List<EmployeeFaceEmbeddingDto>> GetByWorkshopIdsAsync(List<long> workshopIds);
/// <summary>
/// ذخیره یا به‌روزرسانی embedding
/// اگر Id وجود داشته باشد، به‌روزرسانی می‌شود، در غیر این صورت ایجاد می‌شود
/// </summary>
Task<string> SaveAsync(EmployeeFaceEmbeddingDto dto);
/// <summary>
/// حذف embedding
/// </summary>
Task DeleteAsync(string id);
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public class CreateFinancialInvoice
{
public double Amount { get; set; }
public long ContractingPartyId { get; set; }
public string Description { get; set; }
public List<CreateFinancialInvoiceItem>? Items { get; set; }
}
public class CreateFinancialInvoiceItem
{
public string Description { get; set; }
public double Amount { get; set; }
public FinancialInvoiceItemType Type { get; set; }
public long EntityId { get; set; }
}

View File

@@ -0,0 +1,23 @@
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public class EditFinancialInvoice
{
public long Id { get; set; }
public string InvoiceNumber { get; set; }
public string Description { get; set; }
public double Amount { get; set; }
public FinancialInvoiceStatus Status { get; set; }
public List<EditFinancialInvoiceItem>? Items { get; set; }
}
public class EditFinancialInvoiceItem
{
public long Id { get; set; }
public string Description { get; set; }
public double Amount { get; set; }
public FinancialInvoiceItemType Type { get; set; }
public long EntityId { get; set; }
}

View File

@@ -0,0 +1,25 @@
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public enum FinancialInvoiceItemType
{
/// <summary>
/// قسط قرارداد خرید از موسسه
/// </summary>
BuyInstitutionContractInstallment,
/// <summary>
/// خرید قرارداد از موسسه
/// </summary>
BuyInstitutionContract,
/// <summary>
///قسط ارتقا قرارداد موسسه
/// </summary>
AmendmentInstitutionContractInstallment,
/// <summary>
/// ارتقا قرارداد موسسه
/// </summary>
AmendmentInstitutionContract,
/// <summary>
/// بدهی قبلی
/// </summary>
PreviousDebt,
}

View File

@@ -0,0 +1,12 @@
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public class FinancialInvoiceSearchModel
{
public string? Description { get; set; }
public FinancialInvoiceStatus? Status { get; set; }
public long? ContractingPartyId { get; set; }
public string? FromDate { get; set; }
public string? ToDate { get; set; }
public double? MinAmount { get; set; }
public double? MaxAmount { get; set; }
}

View File

@@ -0,0 +1,21 @@
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public enum FinancialInvoiceStatus
{
/// <summary>
/// پرداخت نشده
/// </summary>
Unpaid = 0,
/// <summary>
/// پرداخت شده کامل
/// </summary>
Paid = 1,
/// <summary>
/// فاکتور لغو شده
/// </summary>
Cancelled = 4,
/// <summary>
/// // بازپرداخت شده (در صورت برگشت وجه)
/// </summary>
Refunded = 5,
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public class FinancialInvoiceViewModel
{
public long Id { get; set; }
public string InvoiceNumber { get; set; }
public string Description { get; set; }
public string Status { get; set; }
public string PaidAt { get; set; }
public double Amount { get; set; }
public Guid PublicId { get; set; }
public long ContractingPartyId { get; set; }
public string ContractingPartyName { get; set; }
public string CreationDate { get; set; }
public int ItemsCount { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.FinancialInvoice;
public interface IFinancialInvoiceApplication
{
OperationResult Create(CreateFinancialInvoice command);
OperationResult Edit(EditFinancialInvoice command);
OperationResult SetPaid(long id, DateTime paidAt);
OperationResult SetUnpaid(long id);
OperationResult SetCancelled(long id);
OperationResult SetRefunded(long id);
EditFinancialInvoice GetDetails(long id);
List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel);
}

View File

@@ -213,7 +213,7 @@ public interface IInstitutionContractApplication
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
Task<OperationResult<OtpResultViewModel>> SendVerifyOtp(Guid id);
Task<OperationResult> VerifyOtp(Guid publicId, string code);
Task<OperationResult<string>> VerifyOtpAndMakeGateway(Guid publicId, string code, string callbackUrl);
Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId);
#region Extension
@@ -251,6 +251,8 @@ public interface IInstitutionContractApplication
/// <param name="id"></param>
/// <returns></returns>
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
Task<OperationResult> SetPendingWorkflow(long entityId);
}
public class InstitutionContractPrintViewModel

View File

@@ -31,6 +31,50 @@ public interface IInsuranceListApplication
double GetRoundValue(double value);
OperationResult ConfirmInsuranceList(long id);
#region New
/// <summary>
/// دستمزد روزانه مشاغل مقطوع بیمه
/// </summary>
/// <param name="year"></param>
/// <param name="workshopId"></param>
/// <param name="employeeId"></param>
/// <param name="startDateGr"></param>
/// <param name="endDateGr"></param>
/// <param name="jobId"></param>
/// <param name="population"></param>
/// <param name="insuranceJobId"></param>
/// <returns></returns>
double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr,
DateTime? endDateGr, long jobId, string population, long? insuranceJobId);
/// <summary>
/// محاسبه مزایای ماهانه
/// </summary>
/// <param name="endMonthCurrentDay"></param>
/// <param name="consumableItemsItemValue"></param>
/// <param name="housingAllowanceItemValue"></param>
/// <param name="maritalStatus"></param>
/// <param name="countWorkingDays"></param>
/// <param name="typeOfInsuranceSendWorkshop"></param>
/// <param name="jobId"></param>
/// <param name="employeeId"></param>
/// <param name="includeStatus"></param>
/// <returns></returns>
public double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue,
double housingAllowanceItemValue, double maritalStatus, int countWorkingDays,
string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus);
/// <summary>
///
/// </summary>
/// <param name="yearlysalaryItemValue"></param>
/// <param name="employeeId"></param>
/// <param name="workshopId"></param>
/// <param name="year"></param>
/// <returns></returns>
public double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year);
#endregion
List<InsuranceListViewModel> SearchForClient(InsuranceListSearchModel searchModel);
//farokhiChanges

View File

@@ -17,4 +17,14 @@ public class CreatePaymentTransaction
/// مسیر برگشت پس از پرداخت
/// </summary>
public string CallBackUrl { get; set; }
/// <summary>
/// نوع درگاه
/// </summary>
public PaymentTransactionGateWay Gateway { get; set; }
}
public enum PaymentTransactionGateWay
{
AqayePardakht = 1,
SepehrPay = 2
}

View File

@@ -49,7 +49,7 @@ public interface IPaymentTransactionApplication
/// <param name="cardNumber"></param>
/// <param name="bankName"></param>
/// <returns></returns>
OperationResult SetSuccess(long paymentTransactionId, string cardNumber, string bankName);
OperationResult SetSuccess(long paymentTransactionId, string cardNumber, string bankName, string rrn, string digitalReceipt);
Task<OperationResult> SetTransactionId(long id, string transactionId);
}

View File

@@ -27,6 +27,8 @@ namespace CompanyManagment.App.Contracts.Report
public int ContractSignNotDone { get; set; }
public int ContractSignDone { get; set; }
public int ContractSignToBe { get; set; }
//تصفیه
public int AllCheckout { get; set; }
public int CheckoutNotDone { get; set; }
@@ -34,6 +36,8 @@ namespace CompanyManagment.App.Contracts.Report
public int CheckoutSignNotDone { get; set; }
public int CheckoutSignDone { get; set; }
public int CheckoutSignToBe { get; set; }
}

View File

@@ -10,21 +10,23 @@ namespace CompanyManagment.App.Contracts.Report
{
Task<AllReport> GetAllActiveWorkshops(string year, string month);
Task<AllReport> GetAllReports(string year, string month);
WorkshopResult GetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList);
WorkshopResult GetWorkshopContractSignDone(string year, string month, long accountId, List<long> workshopList);
WorkshopResult GetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList);
WorkshopResult GetWorkshopCheckoutSignDone(string year, string month, long accountId, List<long> workshopList);
List<EmployeeNotDone> GetEmployeeContract(string year, string month, long workshopId);
List<EmployeeNotDone> GetEmployeeContractSign(string year, string month, long workshopId);
List<EmployeeNotDone> GetEmployeeCheckout(string year, string month, long workshopId);
List<EmployeeNotDone> GetEmployeeCheckoutSign(string year, string month, long workshopId);
PrintAllContractCheckout GetPrintAllContractDone(string year, string month, long accountId,
Task<WorkshopResult> GetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList);
Task<WorkshopResult> GetWorkshopContractSignDone(string year, string month, long accountId,
List<long> workshopList);
PrintAllContractCheckout GetPrintAllContractSignDone(string year, string month, long accountId,
Task<WorkshopResult> GetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList);
Task<WorkshopResult> GetWorkshopCheckoutSignDone(string year, string month, long accountId,
List<long> workshopList);
PrintAllContractCheckout GetPrintAllCheckoutDone(string year, string month, long accountId,
Task<List<EmployeeNotDone>> GetEmployeeContract(string year, string month, long workshopId);
Task<List<EmployeeNotDone>> GetEmployeeContractSign(string year, string month, long workshopId);
Task<List<EmployeeNotDone>> GetEmployeeCheckout(string year, string month, long workshopId);
Task<List<EmployeeNotDone>> GetEmployeeCheckoutSign(string year, string month, long workshopId);
Task<PrintAllContractCheckout> GetPrintAllContractDone(string year, string month, long accountId,
List<long> workshopList);
PrintAllContractCheckout GetPrintAllCheckoutSignDone(string year, string month, long accountId,
Task<PrintAllContractCheckout> GetPrintAllContractSignDone(string year, string month, long accountId,
List<long> workshopList);
Task<PrintAllContractCheckout> GetPrintAllCheckoutDone(string year, string month, long accountId,
List<long> workshopList);
Task<PrintAllContractCheckout> GetPrintAllCheckoutSignDone(string year, string month, long accountId,
List<long> workshopList);
}
}

View File

@@ -193,8 +193,19 @@ public class CheckoutApplication : ICheckoutApplication
//حق بیمه سهم کارگر
#region InsuranceDeduction
var insuranceOverTime = command.HasInsuranceChekoutOverTime ? command.OvertimePay : 0;
var insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
double insuranceDeduction = 0;
bool hasInsuranceShareTheSameAsList = false;
if (command.InsuranceDeduction == 0)
{
var insuranceOverTime = command.HasInsuranceChekoutOverTime ? command.OvertimePay : 0;
insuranceDeduction = (monthlyWage + bacicYears + consumableItem + housingAllowance + marriedAllowance + insuranceOverTime) * 7 / 100;
}
else
{
insuranceDeduction = command.InsuranceDeduction;
hasInsuranceShareTheSameAsList = true;
}
#endregion
@@ -375,7 +386,7 @@ public class CheckoutApplication : ICheckoutApplication
, command.OvertimePay, command.NightworkPay, command.FridayPay, 0, command.ShiftPay, familyAllowance, bunos, years, command.LeavePay, insuranceDeduction, 0, command.InstallmentDeduction, command.SalaryAidDeduction, command.AbsenceDeduction, sumOfWorkingDays,
command.ArchiveCode, command.PersonnelCode, totalClaims, totalDeductions, totalPayment, command.Signature, marriedAllowance, command.LeaveCheckout, command.CreditLeaves, command.AbsencePeriod, command.AverageHoursPerDay, command.HasRollCall, command.OverTimeWorkValue, command.OverNightWorkValue
, command.FridayWorkValue, command.RotatingShiftValue, command.AbsenceValue, command.TotalDayOfLeaveCompute, command.TotalDayOfYearsCompute, command.TotalDayOfBunosesCompute,
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours);
loanInstallments, salaryAids,checkoutRollCall,command.EmployeeMandatoryHours, hasInsuranceShareTheSameAsList);
_checkoutRepository.CreateCkeckout(checkout).GetAwaiter().GetResult();
//_checkoutRepository.SaveChanges();

View File

@@ -373,7 +373,9 @@ namespace CompanyManagment.Application
Color = color,
PersonnelCode = personnelCodes.FirstOrDefault(y => x.Id == y.EmployeeId)?.PersonnelCode.ToString() ?? "-"
};
}).OrderByDescending(x => x.IsEligible).ThenByDescending(x => x.Reason).ToList();
}).OrderBy(x => x.Color switch { "orange" => 0, "white" => 1, "red" => 2, "green" => 3, "black" => 4, _ => 5 })
.ToList();
return op.Succcedded(employees);
}
}

View File

@@ -0,0 +1,170 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Company.Domain.EmployeeFaceEmbeddingAgg;
using CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
namespace CompanyManagment.Application;
public class EmployeeFaceEmbeddingApplication : IEmployeeFaceEmbeddingApplication
{
private readonly IEmployeeFaceEmbeddingRepository _repository;
public EmployeeFaceEmbeddingApplication(IEmployeeFaceEmbeddingRepository repository)
{
_repository = repository;
}
public async Task<EmployeeFaceEmbeddingDto> GetByIdAsync(string id)
{
var entity = await _repository.GetByIdAsync(id);
return entity == null ? null : MapToDto(entity);
}
public async Task<EmployeeFaceEmbeddingDto> GetByEmployeeIdAsync(long employeeId)
{
var entity = await _repository.GetByEmployeeIdAsync(employeeId);
return entity == null ? null : MapToDto(entity);
}
public async Task<List<EmployeeFaceEmbeddingDto>> GetByWorkshopIdAsync(long workshopId)
{
var entities = await _repository.GetByWorkshopIdAsync(workshopId);
return entities.Select(MapToDto).ToList();
}
public async Task<List<EmployeeFaceEmbeddingDto>> GetByWorkshopIdsAsync(List<long> workshopIds)
{
var entities = await _repository.GetByWorkshopIdsAsync(workshopIds);
return entities.Select(MapToDto).ToList();
}
public async Task<string> SaveAsync(EmployeeFaceEmbeddingDto dto)
{
if (string.IsNullOrWhiteSpace(dto.Id))
{
// ایجاد جدید
var metadata = MapMetadataFromDto(dto.Metadata);
var entity = new EmployeeFaceEmbedding(
dto.EmployeeFullName,
dto.EmployeeId,
dto.WorkshopId,
dto.Embeddings,
metadata
);
await _repository.CreateAsync(entity);
return entity.Id;
}
else
{
// به‌روزرسانی
var entity = await _repository.GetByIdAsync(dto.Id);
if (entity == null)
throw new Exception($"EmployeeFaceEmbedding با شناسه {dto.Id} یافت نشد");
entity.UpdateEmployeeInfo(dto.EmployeeFullName, dto.WorkshopId);
entity.UpdateEmbedding(dto.Embeddings, 0, 0);
entity.UpdateMetadata(MapMetadataFromDto(dto.Metadata), 0, 0);
await _repository.UpdateAsync(entity);
return entity.Id;
}
}
public async Task DeleteAsync(string id)
{
await _repository.DeleteAsync(id);
}
#region Mapping Methods
private EmployeeFaceEmbeddingDto MapToDto(EmployeeFaceEmbedding entity)
{
return new EmployeeFaceEmbeddingDto
{
Id = entity.Id,
EmployeeFullName = entity.EmployeeFullName,
EmployeeId = entity.EmployeeId,
WorkshopId = entity.WorkshopId,
Embeddings = entity.Embeddings,
Metadata = MapMetadataToDto(entity.Metadata)
};
}
private EmployeeFaceEmbeddingMetadataDto MapMetadataToDto(EmployeeFaceEmbeddingMetadata metadata)
{
if (metadata == null) return null;
return new EmployeeFaceEmbeddingMetadataDto
{
AvgEyeDistanceNormalized = metadata.AvgEyeDistanceNormalized,
AvgEyeToFaceRatio = metadata.AvgEyeToFaceRatio,
AvgFaceAspectRatio = metadata.AvgFaceAspectRatio,
AvgDetectionConfidence = metadata.AvgDetectionConfidence,
AvgKeypointsNormalized = MapKeypointsToDto(metadata.AvgKeypointsNormalized),
PerImageMetadata = metadata.PerImageMetadata?.Select(x => new ImageMetadataDto
{
FaceAspectRatio = x.FaceAspectRatio,
EyeDistanceNormalized = x.EyeDistanceNormalized,
EyeToFaceRatio = x.EyeToFaceRatio,
DetectionConfidence = x.DetectionConfidence,
KeypointsNormalized = MapKeypointsToDto(x.KeypointsNormalized)
}).ToList()
};
}
private EmployeeFaceEmbeddingKeypointsDto MapKeypointsToDto(EmployeeFaceEmbeddingKeypoints keypoints)
{
if (keypoints == null) return null;
return new EmployeeFaceEmbeddingKeypointsDto
{
LeftEye = keypoints.LeftEye,
RightEye = keypoints.RightEye,
Nose = keypoints.Nose,
MouthLeft = keypoints.MouthLeft,
MouthRight = keypoints.MouthRight
};
}
private EmployeeFaceEmbeddingMetadata MapMetadataFromDto(EmployeeFaceEmbeddingMetadataDto dto)
{
if (dto == null) return null;
return new EmployeeFaceEmbeddingMetadata
{
AvgEyeDistanceNormalized = dto.AvgEyeDistanceNormalized,
AvgEyeToFaceRatio = dto.AvgEyeToFaceRatio,
AvgFaceAspectRatio = dto.AvgFaceAspectRatio,
AvgDetectionConfidence = dto.AvgDetectionConfidence,
AvgKeypointsNormalized = MapKeypointsFromDto(dto.AvgKeypointsNormalized),
PerImageMetadata = dto.PerImageMetadata?.Select(x => new ImageMetadata
{
FaceAspectRatio = x.FaceAspectRatio,
EyeDistanceNormalized = x.EyeDistanceNormalized,
EyeToFaceRatio = x.EyeToFaceRatio,
DetectionConfidence = x.DetectionConfidence,
KeypointsNormalized = MapKeypointsFromDto(x.KeypointsNormalized)
}).ToList()
};
}
private EmployeeFaceEmbeddingKeypoints MapKeypointsFromDto(EmployeeFaceEmbeddingKeypointsDto dto)
{
if (dto == null) return null;
return new EmployeeFaceEmbeddingKeypoints
{
LeftEye = dto.LeftEye,
RightEye = dto.RightEye,
Nose = dto.Nose,
MouthLeft = dto.MouthLeft,
MouthRight = dto.MouthRight
};
}
#endregion
}

View File

@@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Linq;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.FinancialInvoiceAgg;
using CompanyManagment.App.Contracts.FinancialInvoice;
using CompanyManagment.EFCore;
namespace CompanyManagment.Application;
public class FinancialInvoiceApplication : RepositoryBase<long, FinancialInvoice>, IFinancialInvoiceApplication
{
private readonly IFinancialInvoiceRepository _financialInvoiceRepository;
private readonly CompanyContext _context;
public FinancialInvoiceApplication(IFinancialInvoiceRepository financialInvoiceRepository, CompanyContext context) : base(context)
{
_financialInvoiceRepository = financialInvoiceRepository;
_context = context;
}
public OperationResult Create(CreateFinancialInvoice command)
{
var operation = new OperationResult();
if (command.Amount <= 0)
return operation.Failed("مبلغ فاکتور باید بزرگتر از صفر باشد");
if (command.ContractingPartyId <= 0)
return operation.Failed("طرف قرارداد نامعتبر است");
if (string.IsNullOrWhiteSpace(command.Description))
return operation.Failed("توضیحات فاکتور الزامی است");
var financialInvoice = new FinancialInvoice(command.Amount, command.ContractingPartyId, command.Description);
if (command.Items != null && command.Items.Any())
{
foreach (var item in command.Items)
{
if (string.IsNullOrWhiteSpace(item.Description))
return operation.Failed("توضیحات آیتم الزامی است");
if (item.Amount <= 0)
return operation.Failed("مبلغ آیتم باید بزرگتر از صفر باشد");
var invoiceItem = new FinancialInvoiceItem(item.Description, item.Amount,
financialInvoice.id, item.Type, item.EntityId);
financialInvoice.AddItem(invoiceItem);
}
}
_financialInvoiceRepository.Create(financialInvoice);
_financialInvoiceRepository.SaveChanges();
return operation.Succcedded();
}
public OperationResult Edit(EditFinancialInvoice command)
{
var operation = new OperationResult();
var financialInvoice = _financialInvoiceRepository.Get(command.Id);
if (financialInvoice == null)
return operation.Failed("فاکتور مورد نظر یافت نشد");
if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
return operation.Failed("امکان ویرایش فاکتور پرداخت شده وجود ندارد");
if (string.IsNullOrWhiteSpace(command.Description))
return operation.Failed("توضیحات فاکتور الزامی است");
// Update description
financialInvoice.Description = command.Description;
// Update items if provided
if (command.Items != null)
{
// Clear existing items
if (financialInvoice.Items != null)
{
financialInvoice.Items.Clear();
}
else
{
financialInvoice.SetItems([]);
}
// Add updated items
foreach (var item in command.Items)
{
if (string.IsNullOrWhiteSpace(item.Description))
return operation.Failed("توضیحات آیتم الزامی است");
if (item.Amount <= 0)
return operation.Failed("مبلغ آیتم باید بزرگتر از صفر باشد");
var invoiceItem = new FinancialInvoiceItem(item.Description, item.Amount,
financialInvoice.id, item.Type, item.EntityId);
financialInvoice.AddItem(invoiceItem);
}
}
_financialInvoiceRepository.SaveChanges();
return operation.Succcedded();
}
public OperationResult SetPaid(long id, DateTime paidAt)
{
var operation = new OperationResult();
var financialInvoice = _financialInvoiceRepository.Get(id);
if (financialInvoice == null)
return operation.Failed("فاکتور مورد نظر یافت نشد");
if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
return operation.Failed("فاکتور قبلاً پرداخت شده است");
if (financialInvoice.Status == FinancialInvoiceStatus.Cancelled)
return operation.Failed("امکان پرداخت فاکتور لغو شده وجود ندارد");
financialInvoice.SetPaid(paidAt);
_financialInvoiceRepository.SaveChanges();
return operation.Succcedded();
}
public OperationResult SetUnpaid(long id)
{
var operation = new OperationResult();
var financialInvoice = _financialInvoiceRepository.Get(id);
if (financialInvoice == null)
return operation.Failed("فاکتور مورد نظر یافت نشد");
financialInvoice.SetUnpaid();
_financialInvoiceRepository.SaveChanges();
return operation.Succcedded();
}
public OperationResult SetCancelled(long id)
{
var operation = new OperationResult();
var financialInvoice = _financialInvoiceRepository.Get(id);
if (financialInvoice == null)
return operation.Failed("فاکتور مورد نظر یافت نشد");
if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
return operation.Failed("امکان لغو فاکتور پرداخت شده وجود ندارد");
financialInvoice.SetCancelled();
_financialInvoiceRepository.SaveChanges();
return operation.Succcedded();
}
public OperationResult SetRefunded(long id)
{
var operation = new OperationResult();
var financialInvoice = _financialInvoiceRepository.Get(id);
if (financialInvoice == null)
return operation.Failed("فاکتور مورد نظر یافت نشد");
if (financialInvoice.Status != FinancialInvoiceStatus.Paid)
return operation.Failed("فقط فاکتورهای پرداخت شده قابل بازپرداخت هستند");
financialInvoice.SetRefunded();
_financialInvoiceRepository.SaveChanges();
return operation.Succcedded();
}
public EditFinancialInvoice GetDetails(long id)
{
return _financialInvoiceRepository.GetDetails(id);
}
public List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel)
{
return _financialInvoiceRepository.Search(searchModel);
}
//public OperationResult Remove(long id)
//{
// var operation = new OperationResult();
// try
// {
// var financialInvoice = _financialInvoiceRepository.Get(id);
// if (financialInvoice == null)
// return operation.Failed("فاکتور مورد نظر یافت نشد");
// if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
// return operation.Failed("امکان حذف فاکتور پرداخت شده وجود ندارد");
// // Remove the entity using the context directly since Remove method might not be available
// _context.FinancialInvoiceSet.Remove(financialInvoice);
// _financialInvoiceRepository.SaveChanges();
// return operation.Succcedded();
// }
// catch (Exception ex)
// {
// return operation.Failed("خطا در حذف فاکتور");
// }
//}
}

View File

@@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Application.PaymentGateway;
using _0_Framework.Application.Sms;
using _0_Framework.Application.UID;
using _0_Framework.Exceptions;
@@ -13,16 +15,20 @@ using AccountManagement.Application.Contracts.Account;
using Company.Domain.ContarctingPartyAgg;
using Company.Domain.EmployeeAgg;
using Company.Domain.empolyerAgg;
using Company.Domain.FinancialInvoiceAgg;
using Company.Domain.FinancialStatmentAgg;
using Company.Domain.FinancialTransactionAgg;
using Company.Domain.InstitutionContractAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.PaymentTransactionAgg;
using Company.Domain.RepresentativeAgg;
using Company.Domain.TemporaryClientRegistrationAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.FinancialInvoice;
using CompanyManagment.App.Contracts.FinancialStatment;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
using CompanyManagment.App.Contracts.PaymentTransaction;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.EFCore.Migrations;
@@ -50,6 +56,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
private readonly IAccountApplication _accountApplication;
private readonly ISmsService _smsService;
private readonly IUidService _uidService;
private readonly IFinancialInvoiceRepository _financialInvoiceRepository;
private readonly IPaymentGateway _paymentGateway;
private readonly IPaymentTransactionRepository _paymentTransactionRepository;
public InstitutionContractApplication(IInstitutionContractRepository institutionContractRepository,
@@ -59,7 +68,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
IFinancialStatmentApplication financialStatmentApplication, IWorkshopApplication workshopApplication,
IContractingPartyTempRepository contractingPartyTempRepository,
IFinancialStatmentRepository financialStatmentRepository, IContactInfoApplication contactInfoApplication,
IAccountApplication accountApplication, ISmsService smsService, IUidService uidService)
IAccountApplication accountApplication, ISmsService smsService, IUidService uidService,
IFinancialInvoiceRepository financialInvoiceRepository,IHttpClientFactory httpClientFactory, IPaymentTransactionRepository paymentTransactionRepository)
{
_institutionContractRepository = institutionContractRepository;
_contractingPartyRepository = contractingPartyRepository;
@@ -75,6 +85,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
_accountApplication = accountApplication;
_smsService = smsService;
_uidService = uidService;
_financialInvoiceRepository = financialInvoiceRepository;
_paymentTransactionRepository = paymentTransactionRepository;
_paymentGateway = new SepehrPaymentGateway(httpClientFactory);
}
public OperationResult Create(CreateInstitutionContract command)
@@ -1060,11 +1073,16 @@ public class InstitutionContractApplication : IInstitutionContractApplication
await _financialStatmentRepository.CreateAsync(financialStatement);
}
if (command.IsInstallment)
double invoiceAmount;
string invoiceItemDescription;
FinancialInvoiceItemType invoiceItemType;
long invoiceItemEntityId;
if (command.IsInstallment)
{
var installments =
CalculateInstallment(command.TotalAmount, (int)command.Duration, command.ContractStartFa, true);
// دریافت مبلغ اولین قسط
//این کار برای این هست که اولین قسط باید با تاریخ امروز باشد و باید به وضعیت مالی بدهی ایجاد شود که یوزر اولین بدهی را وارد کند
var firstInstallmentAmount = installments.First().Amount;
@@ -1075,25 +1093,41 @@ public class InstitutionContractApplication : IInstitutionContractApplication
// ایجاد قسط جدید با تاریخ امروز
var todayInstallment = new InstitutionContractInstallment(DateTime.Today, firstInstallmentAmount, "");
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
// اضافه کردن قسط جدید به ابتدای لیست
installments.Insert(0, todayInstallment);
entity.SetInstallments(installments);
await _institutionContractRepository.SaveChangesAsync();
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
invoiceAmount = firstInstallmentAmount;
invoiceItemDescription = $"پرداخت قسط اول قرارداد شماره {entity.ContractNo}";
invoiceItemType = FinancialInvoiceItemType.BuyInstitutionContractInstallment;
invoiceItemEntityId = todayInstallment.Id;
}
else
{
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
"پرداخت کل سرویس", "debt", "بابت خدمات", command.TotalAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
}
invoiceAmount = command.TotalAmount;
invoiceItemDescription = $"پرداخت کل قرارداد شماره {entity.ContractNo}";
invoiceItemType = FinancialInvoiceItemType.BuyInstitutionContract;
invoiceItemEntityId = entity.id;
}
var financialInvoice = new FinancialInvoice(invoiceAmount, contractingParty.id, $"خرید قرارداد مالی شماره {entity.ContractNo}");
var financialInvoiceItem = new FinancialInvoiceItem(invoiceItemDescription, invoiceAmount, 0,invoiceItemType, invoiceItemEntityId);
financialInvoice.AddItem(financialInvoiceItem);
await _institutionContractRepository.CreateAsync(entity);
await _financialInvoiceRepository.CreateAsync(financialInvoice);
await _institutionContractRepository.CreateAsync(entity);
await _institutionContractRepository.SaveChangesAsync();
var mainContactInfo = new CreateContactInfo
@@ -1140,8 +1174,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
CreateContractingPartyAccount(contractingParty.id, res.SendId);
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId);
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId, contractingParty.id,entity.id );
await _institutionContractRepository.SaveChangesAsync();
@@ -1232,9 +1266,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return new OperationResult<OtpResultViewModel>().Succcedded(result);
}
public async Task<OperationResult> VerifyOtp(Guid publicId, string code)
public async Task<OperationResult<string>> VerifyOtpAndMakeGateway(Guid publicId, string code,string callbackUrl)
{
var op = new OperationResult();
var op = new OperationResult<string>();
var institutionContract = await _institutionContractRepository.GetByPublicIdAsync(publicId);
if (institutionContract == null)
{
@@ -1255,32 +1289,67 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (institutionContract.VerifyCode != code)
return op.Failed("کد وارد شده صحیح نمی باشد");
var transaction = await _institutionContractRepository.BeginTransactionAsync();
institutionContract.SetPendingWorkflow();
var dbTransaction = await _institutionContractRepository.BeginTransactionAsync();
var phone = institutionContract.ContactInfoList.FirstOrDefault(x =>
x.SendSms && x.Position == "طرف قرارداد" && x.PhoneType == "شماره همراه");
if (phone !=null)
long entityId = 0;
FinancialInvoiceItemType financialInvoiceItemType;
if (institutionContract.IsInstallment)
{
var userPass = contractingParty.IsLegal == "حقیقی"
? contractingParty.Nationalcode
: contractingParty.NationalId;
var createAcc = new RegisterAccount
{
Fullname = contractingParty.LName,
Username = userPass,
Password = userPass,
Mobile = phone.PhoneNumber,
NationalCode = userPass
};
var res = _accountApplication.RegisterClient(createAcc);
if (res.IsSuccedded)
CreateContractingPartyAccount(contractingParty.id, res.SendId);
entityId = institutionContract.Installments.MinBy(x => x.InstallmentDateGr).Id;
financialInvoiceItemType = FinancialInvoiceItemType.BuyInstitutionContractInstallment;
}
else
{
entityId = institutionContract.id;
financialInvoiceItemType = FinancialInvoiceItemType.BuyInstitutionContract;
}
await transaction.CommitAsync();
var financialInvoice =await _financialInvoiceRepository.GetUnPaidByEntityId(entityId, financialInvoiceItemType);
var amount = financialInvoice.Amount;
var transaction = new PaymentTransaction(institutionContract.ContractingPartyId, amount,
institutionContract.ContractingPartyName, "https://client.gozareshgir.ir",
PaymentTransactionGateWay.SepehrPay);
await _paymentTransactionRepository.CreateAsync(transaction);
await _financialInvoiceRepository.SaveChangesAsync();
var createPayment = new CreatePaymentGatewayRequest()
{
Amount = amount,
TransactionId = transaction.id.ToString(),
CallBackUrl = callbackUrl,
FinancialInvoiceId = financialInvoice.id,
};
var gatewayResponse = await _paymentGateway.Create(createPayment);
if(!gatewayResponse.IsSuccess)
return op.Failed("خطا در ایجاد درگاه پرداخت: " + gatewayResponse.Message + gatewayResponse.ErrorCode);
// institutionContract.SetPendingWorkflow();
//
// var phone = institutionContract.ContactInfoList.FirstOrDefault(x =>
// x.SendSms && x.Position == "طرف قرارداد" && x.PhoneType == "شماره همراه");
// if (phone !=null)
// {
// var userPass = contractingParty.IsLegal == "حقیقی"
// ? contractingParty.Nationalcode
// : contractingParty.NationalId;
// var createAcc = new RegisterAccount
// {
// Fullname = contractingParty.LName,
// Username = userPass,
// Password = userPass,
// Mobile = phone.PhoneNumber,
// NationalCode = userPass
// };
// var res = _accountApplication.RegisterClient(createAcc);
// if (res.IsSuccedded)
// CreateContractingPartyAccount(contractingParty.id, res.SendId);
// }
await dbTransaction.CommitAsync();
await _institutionContractRepository.SaveChangesAsync();
return op.Succcedded();
return op.Succcedded(gatewayResponse.Token);
}
public async Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId)
@@ -1377,8 +1446,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
if (contractingParty == null)
throw new NotFoundException("طرف قرارداد یافت نشد");
var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName;
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
institutionContract.PublicId);
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
institutionContract.PublicId, contractingParty.id, institutionContract.id);
return new OperationResult().Succcedded();
}
@@ -1387,6 +1456,24 @@ public class InstitutionContractApplication : IInstitutionContractApplication
return (await _institutionContractRepository.PrintAllAsync([id])).FirstOrDefault();
}
public async Task<OperationResult> SetPendingWorkflow(long entityId)
{
var op = new OperationResult();
var institutionContract = _institutionContractRepository.Get(entityId);
if (institutionContract == null)
{
return op.Failed("قرارداد مالی یافت نشد");
}
if (institutionContract.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
{
return op.Failed("وضعیت قرارداد مالی برای این عملیات مناسب نمی باشد");
}
institutionContract.SetPendingWorkflow();
await _institutionContractRepository.SaveChangesAsync();
return op.Succcedded();
}
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,

View File

@@ -1707,7 +1707,7 @@ public class InsuranceListApplication : IInsuranceListApplication
return result;
}
private double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId)
public double? GetDailyWageFixedSalary(string year, long workshopId, long employeeId, DateTime? startDateGr, DateTime? endDateGr, long jobId, string population, long? insuranceJobId)
{
double? result = 0;
@@ -1858,7 +1858,7 @@ public class InsuranceListApplication : IInsuranceListApplication
/// <param name="jobId"></param>
/// <param name="employeeId"></param>
/// <returns></returns>
private double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue, double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus)
public double GetMonthlyBenefits(int endMonthCurrentDay, double consumableItemsItemValue, double housingAllowanceItemValue, double maritalStatus, int countWorkingDays, string typeOfInsuranceSendWorkshop, long jobId, long employeeId, bool includeStatus)
{
//ToDo
//افزودن شرط مشمول مزایای
@@ -1898,7 +1898,7 @@ public class InsuranceListApplication : IInsuranceListApplication
private double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
public double ComputeDailyWage(double yearlysalaryItemValue, long employeeId, long workshopId, string year)
{
double dailyWage = yearlysalaryItemValue;
InsuranceListSearchModel searchModel = new InsuranceListSearchModel();

View File

@@ -30,13 +30,14 @@ public class LeftWorkApplication : ILeftWorkApplication
private readonly IEmployeeRepository _employeeRepository;
private readonly IWorkshopRepository _workshopRepository;
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
public LeftWorkApplication(ILeftWorkRepository leftWorkRepository, IContractRepository contractRepository,
public LeftWorkApplication(ILeftWorkRepository leftWorkRepository, IContractRepository contractRepository,
IContractApplication contractApplication, IWorkingHoursApplication workingHoursApplication,
IWorkingHoursItemsApplication workingHoursItemsApplication, IEmployeeRepository employeeRepository,
IWorkshopRepository workshopRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IRollCallEmployeeRepository rollCallEmployeeRepository)
IWorkshopRepository workshopRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository,
IRollCallEmployeeRepository rollCallEmployeeRepository)
{
_leftWorkRepository = leftWorkRepository;
_contractRepository = contractRepository;
@@ -51,7 +52,6 @@ public class LeftWorkApplication : ILeftWorkApplication
public OperationResult Create(CreateLeftWork command)
{
// var Contracts = _contractRepository.Search(new ContractSearchModel()
// {
// EmployeeId = command.EmployeeId,
@@ -70,7 +70,6 @@ public class LeftWorkApplication : ILeftWorkApplication
var start = command.StartWorkDate.ToGeorgianDateTime();
//if (_leftWorkRepository.Exists(x =>
// x.StartWorkDate > start && x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId))
// return operation.Failed("تاریخ وارد شده کوچکتر از سابقه شروع به کار قبلی است");
@@ -112,16 +111,17 @@ public class LeftWorkApplication : ILeftWorkApplication
return operation.Failed("تاریخ وارد شده در بازه زمانی سابقه ترک کار قبلی است");
var employeeFullName = _employeeRepository.GetDetails(command.EmployeeId).EmployeeFullName;
var workshop = _workshopRepository.GetDetails(command.WorkshopId);
var workshopName = workshop.WorkshopFullName;
var workshop = _workshopRepository.GetDetails(command.WorkshopId);
var workshopName = workshop.WorkshopFullName;
var leftWork = new LeftWork(left, start, command.WorkshopId,
command.EmployeeId, employeeFullName, workshopName, command.JobId, command.IncludeStatus,
command.AddBonusesPay, command.AddYearsPay, command.AddLeavePay,workshop.ComputeOptions,workshop.BonusesOptions);
command.AddBonusesPay, command.AddYearsPay, command.AddLeavePay, workshop.ComputeOptions,
workshop.BonusesOptions);
_leftWorkRepository.Create(leftWork);
_leftWorkRepository.SaveChanges();
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(command.EmployeeId);
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(command.EmployeeId, command.WorkshopId);
return operation.Succcedded();
return operation.Succcedded();
}
//public OperationResult Create(CreateLeftWork command)
@@ -193,8 +193,8 @@ public class LeftWorkApplication : ILeftWorkApplication
command.EmployeeId, command.JobId, command.IncludeStatus, command.AddBonusesPay, command.AddYearsPay,
command.AddLeavePay);
_leftWorkRepository.SaveChanges();
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(command.EmployeeId);
return operation.Succcedded();
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(command.EmployeeId, command.WorkshopId);
return operation.Succcedded();
}
public EditLeftWork GetDetails(long id)
@@ -214,11 +214,9 @@ public class LeftWorkApplication : ILeftWorkApplication
public List<LeftWorkViewModel> SearchCreateContract(LeftWorkSearchModel searchModel)
{
return _leftWorkRepository.SearchCreateContract(searchModel);
}
public async Task<List<LeftWorkViewModel>> searchAsync(LeftWorkSearchModel searchModel)
{
@@ -228,7 +226,6 @@ public class LeftWorkApplication : ILeftWorkApplication
public string GetBeforeDate(string date)
{
var persianBefore = "";
var year = Convert.ToInt32(date.Substring(0, 4));
var month = Convert.ToInt32(date.Substring(5, 2));
@@ -255,10 +252,8 @@ public class LeftWorkApplication : ILeftWorkApplication
}
public void LeftWorkExtension(long contractId, string CStart, string CEnd)
{
var step1 = _contractApplication.GetDetails(contractId);
var step2 = _workingHoursApplication.GetByContractId(contractId);
var step3 = _workingHoursItemsApplication.GetWorkingHoursItems();
@@ -380,13 +375,11 @@ public class LeftWorkApplication : ILeftWorkApplication
ContarctStart = CStart,
ContractEnd = CEnd,
GetWorkDateHide = step1.GetWorkDate,
};
var step5 = _contractApplication.MandatoryHours(computing);
string workingDays = string.Empty;
if (step5.NumberOfWorkingDays == "0")
{
workingDays = step5.ComplexNumberOfWorkingDays;
}
else
@@ -477,8 +470,6 @@ public class LeftWorkApplication : ILeftWorkApplication
OverTimeWorkM = step5.OverTimeWorkM == "0" ? "" : step5.OverTimeWorkM,
OverNightWorkH = step5.OverNightWorkH == "0" ? "" : step5.OverNightWorkH,
OverNightWorkM = step5.OverNightWorkM == "0" ? "" : step5.OverNightWorkM,
};
var resss = _contractApplication.Create(createNew);
}
@@ -529,7 +520,9 @@ public class LeftWorkApplication : ILeftWorkApplication
item.LeftWorkDate = string.IsNullOrWhiteSpace(item.LeftWorkDate) ? "1500/01/01" : item.LeftWorkDate;
var left = item.LeftWorkDate.ToGeorgianDateTime();
var start = item.StartWorkDate.ToGeorgianDateTime();
if (_leftWorkRepository.Exists(x => x.StartWorkDate > start && left == null && x.EmployeeId == informationLeftwork.EmployeeId && x.WorkshopId == informationLeftwork.WorkshopId && x.id!=item.Id))
if (_leftWorkRepository.Exists(x =>
x.StartWorkDate > start && left == null && x.EmployeeId == informationLeftwork.EmployeeId &&
x.WorkshopId == informationLeftwork.WorkshopId && x.id != item.Id))
return operation.Failed("وارد کردن تاریخ پایان کار اجباری است ");
if (_leftWorkRepository.Exists(x =>
x.StartWorkDate == start && x.EmployeeId == informationLeftwork.EmployeeId &&
@@ -540,17 +533,23 @@ public class LeftWorkApplication : ILeftWorkApplication
x.EmployeeId == informationLeftwork.EmployeeId &&
x.WorkshopId == informationLeftwork.WorkshopId && x.id != item.Id))
return operation.Failed("شروع به کار قبلی این شخص ترک کار ندارد ");
if (_leftWorkRepository.Exists(x => x.StartWorkDate <= start && x.LeftWorkDate < left && x.LeftWorkDate >= start && x.EmployeeId == informationLeftwork.EmployeeId && x.WorkshopId == informationLeftwork.WorkshopId && x.id != item.Id))
if (_leftWorkRepository.Exists(x =>
x.StartWorkDate <= start && x.LeftWorkDate < left && x.LeftWorkDate >= start &&
x.EmployeeId == informationLeftwork.EmployeeId &&
x.WorkshopId == informationLeftwork.WorkshopId && x.id != item.Id))
return operation.Failed("تاریخ وارد شده در بازه زمانی سابقه ترک کار قبلی است");
}
}
operation = _leftWorkRepository.CreateLeftWork(informationLeftwork);
if (informationLeftwork != null && operation.IsSuccedded) IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(informationLeftwork.EmployeeId);
return operation;
}
operation = _leftWorkRepository.CreateLeftWork(informationLeftwork);
if (informationLeftwork != null && operation.IsSuccedded)
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(informationLeftwork.EmployeeId,
informationLeftwork.WorkshopId);
return operation;
}
public OperationResult CreateLeftWorkByLeftWorkGroups(string employeeFullName, long commandEmployeeId, List<PersonnelCodeViewModel> commandPersonnelCode, List<LeftWorkGroup> leftWorkGroups)
public OperationResult CreateLeftWorkByLeftWorkGroups(string employeeFullName, long commandEmployeeId,
List<PersonnelCodeViewModel> commandPersonnelCode, List<LeftWorkGroup> leftWorkGroups)
{
var operation = new OperationResult();
@@ -560,7 +559,9 @@ public class LeftWorkApplication : ILeftWorkApplication
{
foreach (var item2 in item.LeftWorkViewModels)
{
item2.LeftWorkDate = string.IsNullOrWhiteSpace(item2.LeftWorkDate) ? "1500/01/01" : item2.LeftWorkDate;
item2.LeftWorkDate = string.IsNullOrWhiteSpace(item2.LeftWorkDate)
? "1500/01/01"
: item2.LeftWorkDate;
var left = item2.LeftWorkDate.ToGeorgianDateTime();
var start = item2.StartWorkDate.ToGeorgianDateTime();
if (_leftWorkRepository.Exists(x =>
@@ -586,14 +587,16 @@ public class LeftWorkApplication : ILeftWorkApplication
}
}
operation = _leftWorkRepository.CreateLeftWorkByLeftWorkGroups(employeeFullName, commandEmployeeId, commandPersonnelCode, leftWorkGroups);
if (operation.IsSuccedded) IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(commandEmployeeId);
return operation;
}
operation = _leftWorkRepository.CreateLeftWorkByLeftWorkGroups(employeeFullName, commandEmployeeId,
commandPersonnelCode, leftWorkGroups);
if (operation.IsSuccedded)
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(commandEmployeeId);
return operation;
}
public OperationResult CheckDeleteLeftWork(long workshopId, long employeeId, string date, int type)
{
return _leftWorkRepository.CheckDeleteLeftWork( workshopId, employeeId, date.ToGeorgianDateTime(),type);
return _leftWorkRepository.CheckDeleteLeftWork(workshopId, employeeId, date.ToGeorgianDateTime(), type);
}
public OperationResult CheckEditLeftWork(long workshopId, long employeeId, string date, int type)
@@ -607,21 +610,23 @@ public class LeftWorkApplication : ILeftWorkApplication
}
#region Pooya
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
{
//get last leftworks for employee in all workshops
var leftWorks = _leftWorkRepository.search(new LeftWorkSearchModel() { EmployeeId = employeeId }).GroupBy(x => x.WorkshopId).Select(x =>
{
var leftWork = x.MaxBy(y => y.StartWorkDateGr);
return new LeftWorkViewModel()
var leftWorks = _leftWorkRepository.search(new LeftWorkSearchModel() { EmployeeId = employeeId })
.GroupBy(x => x.WorkshopId).Select(x =>
{
EmployeeId = employeeId,
WorkshopId = x.Key,
LeftWorkDateGr = leftWork.LeftWorkDateGr.Date.AddDays(-1),
StartWorkDateGr = leftWork.StartWorkDateGr
};
}).ToList();
var leftWork = x.MaxBy(y => y.StartWorkDateGr);
return new LeftWorkViewModel()
{
EmployeeId = employeeId,
WorkshopId = x.Key,
LeftWorkDateGr = leftWork.LeftWorkDateGr.Date.AddDays(-1),
StartWorkDateGr = leftWork.StartWorkDateGr
};
}).ToList();
//get rollCallEmployee associated with those leftworks which have a higher end date than leftworkDate
var rollCallsEmployee = _rollCallEmployeeRepository.GetByEmployeeIdWithStatuses(employeeId)
@@ -632,17 +637,90 @@ public class LeftWorkApplication : ILeftWorkApplication
x.WorkshopId,
x.EmployeeId,
y.LeftWorkDateGr,
Status = x.Statuses.OrderByDescending(z => z.StartDate).FirstOrDefault(z => z.StartDateGr.Date < y.LeftWorkDateGr && z.EndDateGr.Date > y.LeftWorkDateGr)
Status = x.Statuses.OrderByDescending(z => z.StartDate).FirstOrDefault(z =>
z.StartDateGr.Date < y.LeftWorkDateGr && z.EndDateGr.Date > y.LeftWorkDateGr)
});
//shaping up the list to send as parameter to repository
var newRollCallRecords = joinedList.Where(x => x.Status != null).Select(x => new AdjustRollCallEmployeesWithEmployeeLeftWork()
{
LeaveDate = x.LeftWorkDateGr,
RollCallStatusId = x.Status.Id
}).ToList();
if(newRollCallRecords.Count > 0)
var newRollCallRecords = joinedList.Where(x => x.Status != null).Select(x =>
new AdjustRollCallEmployeesWithEmployeeLeftWork()
{
LeaveDate = x.LeftWorkDateGr,
RollCallStatusId = x.Status.Id
}).ToList();
if (newRollCallRecords.Count > 0)
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates(newRollCallRecords);
foreach (var rollCallEmployeeViewModel in rollCallsEmployee)
{
var maxLeftWork = leftWorks.FirstOrDefault(x => x.WorkshopId == rollCallEmployeeViewModel.WorkshopId);
if (maxLeftWork == null)
{
continue;
}
var employeeStatus = _rollCallEmployeeRepository.GetBy(rollCallEmployeeViewModel.EmployeeId,
rollCallEmployeeViewModel.WorkshopId);
var rollCallEmployeeStatusList = employeeStatus.EmployeesStatus
.Where(x => x.StartDate >= maxLeftWork.LeftWorkDateGr).ToList();
if (rollCallEmployeeStatusList.Any())
{
_rollCallEmployeeStatusRepository.RemoveRange(rollCallEmployeeStatusList);
_rollCallEmployeeStatusRepository.SaveChanges();
}
}
}
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId, long workshopId)
{
//get last leftworks for employee in all workshops
var leftWorks = _leftWorkRepository.search(new LeftWorkSearchModel()
{ EmployeeId = employeeId, WorkshopId = workshopId })
.Select(x => new LeftWorkViewModel()
{
EmployeeId = employeeId,
WorkshopId = x.WorkshopId,
LeftWorkDateGr = x.LeftWorkDateGr.Date.AddDays(-1),
StartWorkDateGr = x.StartWorkDateGr
}).ToList();
var maxLeftWork = leftWorks.MaxBy(y => y.StartWorkDateGr);
//get rollCallEmployee associated with those leftworks which have a higher end date than leftworkDate
var rollCallsEmployee = _rollCallEmployeeRepository.GetBy(employeeId, workshopId);
// var joinedList = rollCallsEmployee.Join(leftWorks, x => x.WorkshopId, y => y.WorkshopId, (x, y) => new
// {
// x.WorkshopId,
// x.EmployeeId,
// y.LeftWorkDateGr,
// Status = x.Statuses.OrderByDescending(z => z.StartDate).FirstOrDefault(z => z.StartDateGr.Date < y.LeftWorkDateGr && z.EndDateGr.Date > y.LeftWorkDateGr)
// });
var status = rollCallsEmployee.EmployeesStatus.OrderByDescending(z => z.StartDate)
.FirstOrDefault(rollCallEmployeeStatus => rollCallEmployeeStatus.StartDate.Date < maxLeftWork.LeftWorkDateGr
&& rollCallEmployeeStatus.EndDate.Date >
maxLeftWork.LeftWorkDateGr);
if (status != null)
{
var adjust = new AdjustRollCallEmployeesWithEmployeeLeftWork()
{
LeaveDate = maxLeftWork.LeftWorkDateGr,
RollCallStatusId = status.id
};
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates([adjust]);
}
var rollCallEmployeeStatusList = rollCallsEmployee.EmployeesStatus
.Where(x => x.StartDate >= maxLeftWork.LeftWorkDateGr).ToList();
if (rollCallEmployeeStatusList.Any())
{
_rollCallEmployeeStatusRepository.RemoveRange(rollCallEmployeeStatusList);
_rollCallEmployeeStatusRepository.SaveChanges();
}
}
#endregion

View File

@@ -27,26 +27,30 @@ namespace CompanyManagment.Application;
public class LeftWorkTempApplication : ILeftWorkTempApplication
{
private readonly ILeftWorkTempRepository _leftWorkTempRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IWorkshopRepository _workshopRepository;
private readonly IEmployeeRepository _employeeRepository;
private readonly IJobRepository _jobRepository;
private readonly ICheckoutRepository _checkoutRepository;
private readonly IContractRepository _contractRepository;
private readonly ILeftWorkTempRepository _leftWorkTempRepository;
private readonly ILeftWorkRepository _leftWorkRepository;
private readonly IWorkshopRepository _workshopRepository;
private readonly IEmployeeRepository _employeeRepository;
private readonly IJobRepository _jobRepository;
private readonly ICheckoutRepository _checkoutRepository;
private readonly IContractRepository _contractRepository;
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository;
private readonly IRollCallEmployeeStatusRepository _rollCallEmployeeStatusRepository;
public LeftWorkTempApplication(ILeftWorkTempRepository leftWorkTempRepository, ILeftWorkRepository leftWorkRepository, IWorkshopRepository workshopRepository, IEmployeeRepository employeeRepository, IJobRepository jobRepository, ICheckoutRepository checkoutRepository, IContractRepository contractRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository, IRollCallEmployeeRepository rollCallEmployeeRepository)
{
_leftWorkTempRepository = leftWorkTempRepository;
_leftWorkRepository = leftWorkRepository;
_workshopRepository = workshopRepository;
_employeeRepository = employeeRepository;
_jobRepository = jobRepository;
_checkoutRepository = checkoutRepository;
_contractRepository = contractRepository;
public LeftWorkTempApplication(ILeftWorkTempRepository leftWorkTempRepository,
ILeftWorkRepository leftWorkRepository, IWorkshopRepository workshopRepository,
IEmployeeRepository employeeRepository, IJobRepository jobRepository, ICheckoutRepository checkoutRepository,
IContractRepository contractRepository, IRollCallEmployeeStatusRepository rollCallEmployeeStatusRepository,
IRollCallEmployeeRepository rollCallEmployeeRepository)
{
_leftWorkTempRepository = leftWorkTempRepository;
_leftWorkRepository = leftWorkRepository;
_workshopRepository = workshopRepository;
_employeeRepository = employeeRepository;
_jobRepository = jobRepository;
_checkoutRepository = checkoutRepository;
_contractRepository = contractRepository;
_rollCallEmployeeStatusRepository = rollCallEmployeeStatusRepository;
_rollCallEmployeeRepository = rollCallEmployeeRepository;
}
@@ -59,15 +63,16 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
{
#region Validation
if (_leftWorkTempRepository.Exists(x=>x.WorkshopId == command.WorkshopId && x.EmployeeId == employeeId))
if (_leftWorkTempRepository.Exists(x => x.WorkshopId == command.WorkshopId && x.EmployeeId == employeeId))
{
return op.Failed("برای پرسنل وارد شده قبلا درخواست ترک کار ثبت کرده اید");
return op.Failed("برای پرسنل وارد شده قبلا درخواست ترک کار ثبت کرده اید");
}
if (command.LeftWorkTime.TryToGeorgianDateTime(out var leftWorkDateGr) == false)
{
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
}
if (command.LastDayStanding.TryToGeorgianDateTime(out var lastDayStandingDateGr) == false)
{
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
@@ -101,7 +106,6 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
}
//if (leftWork.StartWorkDate >= leftWorkDateGr)
//{
// return op.Failed("ترک کار نمیتواند کوچک تر یا مساوی شروع به کار باشد");
@@ -121,10 +125,10 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
// return op.Failed("این پرسنل در تاریخ ترک کار وارد شده دارای قرارداد میباشد");
//}
#endregion
var leftWorkTemp = LeftWorkTemp.CreateLeftWork(leftWork.id, leftWork.StartWorkDate, leftWorkDateGr, lastDayStandingDateGr,
var leftWorkTemp = LeftWorkTemp.CreateLeftWork(leftWork.id, leftWork.StartWorkDate, leftWorkDateGr,
lastDayStandingDateGr,
command.WorkshopId, employeeId, leftWork.JobId);
await _leftWorkTempRepository.CreateAsync(leftWorkTemp);
@@ -135,61 +139,63 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
}
public Task<GetStartWorkTempDetails> GetStartAndLeftWorkDetails(long employeeId, long workshopId)
{
return _leftWorkTempRepository.GetStartAndLeftWorkDetails(employeeId, workshopId);
}
{
return _leftWorkTempRepository.GetStartAndLeftWorkDetails(employeeId, workshopId);
}
public async Task<OperationResult> AcceptStartWork(AcceptStartWorkTemp command)
{
var op = new OperationResult();
if (command.StartDateTime.TryToGeorgianDateTime(out var startDateGr) == false)
{
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
}
public async Task<OperationResult> AcceptStartWork(AcceptStartWorkTemp command)
{
var op = new OperationResult();
if (command.StartDateTime.TryToGeorgianDateTime(out var startDateGr) == false)
{
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
}
var leftWorkTemp = _leftWorkTempRepository.Get(command.LeftWorkTempId);
var leftWorkTemp = _leftWorkTempRepository.Get(command.LeftWorkTempId);
if (leftWorkTemp.LeftWorkType != LeftWorkTempType.StartWork)
{
return op.Failed("اطلاعات وارد شده نامعتبر است");
}
if (leftWorkTemp.LeftWorkType != LeftWorkTempType.StartWork)
{
return op.Failed("اطلاعات وارد شده نامعتبر است");
}
if (_leftWorkRepository.Exists(x => x.WorkshopId == leftWorkTemp.WorkshopId && x.EmployeeId == leftWorkTemp.EmployeeId && x.LeftWorkDate >= startDateGr))
{
return op.Failed("شروع به کار وارد شده با ترک کار های قبلی تداخل دارد");
}
if (_leftWorkRepository.Exists(x =>
x.WorkshopId == leftWorkTemp.WorkshopId && x.EmployeeId == leftWorkTemp.EmployeeId &&
x.LeftWorkDate >= startDateGr))
{
return op.Failed("شروع به کار وارد شده با ترک کار های قبلی تداخل دارد");
}
if (_jobRepository.Exists(x => x.id == command.JobId) == false)
{
return op.Failed("سمت وارد شده نامعتبر است");
}
if (_jobRepository.Exists(x => x.id == command.JobId) == false)
{
return op.Failed("سمت وارد شده نامعتبر است");
}
var defaultTime = new DateTime(2121, 03, 21);
var defaultTime = new DateTime(2121, 03, 21);
var workshop = _workshopRepository.Get(leftWorkTemp.WorkshopId);
var employee = _employeeRepository.Get(leftWorkTemp.EmployeeId);
var workshop = _workshopRepository.Get(leftWorkTemp.WorkshopId);
var employee = _employeeRepository.Get(leftWorkTemp.EmployeeId);
var newLeftWork = new LeftWork(defaultTime, startDateGr, leftWorkTemp.WorkshopId, leftWorkTemp.EmployeeId,
employee.FullName, workshop.WorkshopFullName, command.JobId, false, false, false, false, "", "");
var newLeftWork = new LeftWork(defaultTime, startDateGr, leftWorkTemp.WorkshopId, leftWorkTemp.EmployeeId,
employee.FullName, workshop.WorkshopFullName, command.JobId, false, false, false, false, "", "");
await _leftWorkRepository.CreateAsync(newLeftWork);
_leftWorkTempRepository.Remove(leftWorkTemp);
var rollCallEmployee = _rollCallEmployeeRepository.GetBy(leftWorkTemp.EmployeeId, leftWorkTemp.WorkshopId);
await _leftWorkRepository.CreateAsync(newLeftWork);
_leftWorkTempRepository.Remove(leftWorkTemp);
var rollCallEmployee = _rollCallEmployeeRepository.GetBy(leftWorkTemp.EmployeeId, leftWorkTemp.WorkshopId);
var rollCallStatus = rollCallEmployee?.EmployeesStatus.MaxBy(x => x.StartDate);
var rollCallStatus = rollCallEmployee?.EmployeesStatus.MaxBy(x => x.StartDate);
if (rollCallStatus != null)
{
var startWork = newLeftWork.StartWorkDate;
rollCallStatus.Edit(startWork, rollCallStatus.EndDate);
if (rollCallStatus != null)
{
var startWork = newLeftWork.StartWorkDate;
rollCallStatus.Edit(startWork, rollCallStatus.EndDate);
}
}
await _leftWorkRepository.SaveChangesAsync();
await _leftWorkTempRepository.SaveChangesAsync();
await _leftWorkRepository.SaveChangesAsync();
await _leftWorkTempRepository.SaveChangesAsync();
return op.Succcedded();
}
return op.Succcedded();
}
public async Task<OperationResult> AcceptLeftWork(AcceptLeftWorkTemp command)
{
@@ -237,9 +243,12 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
x.WorkshopId == leftWorkTemp.WorkshopId &&
x.ContractStart <= lastDayStandingGr && x.ContractEnd >= lastDayStandingGr))
{
return op.Failed("این پرسنل در تاریخ ترک کار وارد شده دارای فیش حقوقی میباشد. ابتدا فیش حقوقی پرسنل را حذف کنید ");
return op.Failed(
"این پرسنل در تاریخ ترک کار وارد شده دارای فیش حقوقی میباشد. ابتدا فیش حقوقی پرسنل را حذف کنید ");
}
var transaction = await _rollCallEmployeeStatusRepository.BeginTransactionAsync();
leftWork.Edit(leftWorkDateGr, leftWork.StartWorkDate, leftWork.WorkshopId, leftWork.EmployeeId, leftWork.JobId,
leftWork.IncludeStatus, leftWork.AddBonusesPay, leftWork.AddYearsPay, leftWork.AddLeavePay);
@@ -247,8 +256,9 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
await _leftWorkRepository.SaveChangesAsync();
await _leftWorkTempRepository.SaveChangesAsync();
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(leftWork.EmployeeId);
IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(leftWork.EmployeeId, leftWork.WorkshopId);
await transaction.CommitAsync();
return op.Succcedded();
}
@@ -259,45 +269,59 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
public List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId)
{
return _leftWorkTempRepository.GetLeftWorksByWorkshopId(workshopId);
return _leftWorkTempRepository.GetLeftWorksByWorkshopId(workshopId);
}
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId, long workshopId)
{
//get last leftworks for employee in all workshops
var leftWorks = _leftWorkRepository.search(new LeftWorkSearchModel() { EmployeeId = employeeId }).GroupBy(x => x.WorkshopId).Select(x =>
{
var leftWork = x.MaxBy(y => y.StartWorkDateGr);
return new LeftWorkViewModel()
var leftWorks = _leftWorkRepository.search(new LeftWorkSearchModel()
{ EmployeeId = employeeId, WorkshopId = workshopId })
.Select(x => new LeftWorkViewModel()
{
EmployeeId = employeeId,
WorkshopId = x.Key,
LeftWorkDateGr = leftWork.LeftWorkDateGr.Date.AddDays(-1),
StartWorkDateGr = leftWork.StartWorkDateGr
};
}).ToList();
WorkshopId = x.WorkshopId,
LeftWorkDateGr = x.LeftWorkDateGr.Date.AddDays(-1),
StartWorkDateGr = x.StartWorkDateGr
}).ToList();
var maxLeftWork = leftWorks.MaxBy(y => y.StartWorkDateGr);
//get rollCallEmployee associated with those leftworks which have a higher end date than leftworkDate
var rollCallsEmployee = _rollCallEmployeeRepository.GetByEmployeeIdWithStatuses(employeeId)
.Where(x => leftWorks.Any(y => y.WorkshopId == x.WorkshopId)).ToList();
var rollCallsEmployee = _rollCallEmployeeRepository.GetBy(employeeId, workshopId);
var joinedList = rollCallsEmployee.Join(leftWorks, x => x.WorkshopId, y => y.WorkshopId, (x, y) => new
{
x.WorkshopId,
x.EmployeeId,
y.LeftWorkDateGr,
Status = x.Statuses.OrderByDescending(z => z.StartDate).FirstOrDefault(z => z.StartDateGr.Date < y.LeftWorkDateGr && z.EndDateGr.Date > y.LeftWorkDateGr)
});
// var joinedList = rollCallsEmployee.Join(leftWorks, x => x.WorkshopId, y => y.WorkshopId, (x, y) => new
// {
// x.WorkshopId,
// x.EmployeeId,
// y.LeftWorkDateGr,
// Status = x.Statuses.OrderByDescending(z => z.StartDate).FirstOrDefault(z => z.StartDateGr.Date < y.LeftWorkDateGr && z.EndDateGr.Date > y.LeftWorkDateGr)
// });
//shaping up the list to send as parameter to repository
var newRollCallRecords = joinedList.Where(x => x.Status != null).Select(x => new AdjustRollCallEmployeesWithEmployeeLeftWork()
var status = rollCallsEmployee.EmployeesStatus.OrderByDescending(z => z.StartDate)
.FirstOrDefault(rollCallEmployeeStatus => rollCallEmployeeStatus.StartDate.Date < maxLeftWork.LeftWorkDateGr
&& rollCallEmployeeStatus.EndDate.Date >
maxLeftWork.LeftWorkDateGr);
if (status != null)
{
LeaveDate = x.LeftWorkDateGr,
RollCallStatusId = x.Status.Id
}).ToList();
if (newRollCallRecords.Count > 0)
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates(newRollCallRecords);
var adjust = new AdjustRollCallEmployeesWithEmployeeLeftWork()
{
LeaveDate = maxLeftWork.LeftWorkDateGr,
RollCallStatusId = status.id
};
_rollCallEmployeeStatusRepository.AdjustRollCallStatusEndDates([adjust]);
}
var rollCallEmployeeStatusList = rollCallsEmployee.EmployeesStatus
.Where(x => x.StartDate >= maxLeftWork.LeftWorkDateGr).ToList();
if (rollCallEmployeeStatusList.Any())
{
_rollCallEmployeeStatusRepository.RemoveRange(rollCallEmployeeStatusList);
_rollCallEmployeeStatusRepository.SaveChanges();
}
}
}

View File

@@ -50,7 +50,7 @@ public class PaymentTransactionApplication : IPaymentTransactionApplication
command.ContractingPartyId,
command.Amount,
contractingPartyName,
command.CallBackUrl);
command.CallBackUrl,command.Gateway);
await _paymentTransactionRepository.CreateAsync(entity);
await _paymentTransactionRepository.SaveChangesAsync();
@@ -87,7 +87,7 @@ public class PaymentTransactionApplication : IPaymentTransactionApplication
return op.Succcedded();
}
public OperationResult SetSuccess(long paymentTransactionId,string cardNumber, string bankName)
public OperationResult SetSuccess(long paymentTransactionId,string cardNumber, string bankName, string rrn, string digitalReceipt)
{
var op = new OperationResult();
@@ -97,7 +97,7 @@ public class PaymentTransactionApplication : IPaymentTransactionApplication
{
return op.Failed("تراکنش مورد نظر یافت نشد");
}
paymentTransaction.SetPaid(cardNumber, bankName);
paymentTransaction.SetPaid(cardNumber, bankName,rrn, digitalReceipt);
_paymentTransactionRepository.SaveChanges();
return op.Succcedded();

View File

@@ -29,67 +29,67 @@ public class ReportApplication : IReportApplication
return await _reportRepository.GetAllActiveWorkshopsNew(year, month);
}
public WorkshopResult GetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList)
public async Task<WorkshopResult> GetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList)
{
return _reportRepository.GetWorkshopContractDone(year, month, accountId, workshopList);
return await _reportRepository.GetWorkshopContractDone(year, month, accountId, workshopList);
}
public WorkshopResult GetWorkshopContractSignDone(string year, string month, long accountId, List<long> workshopList)
public async Task<WorkshopResult> GetWorkshopContractSignDone(string year, string month, long accountId, List<long> workshopList)
{
return _reportRepository.GetWorkshopContractSignDone(year, month, accountId, workshopList);
return await _reportRepository.GetWorkshopContractSignDone(year, month, accountId, workshopList);
}
public WorkshopResult GetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList)
public async Task<WorkshopResult> GetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList)
{
return _reportRepository.GetWorkshopCheckoutDone(year, month, accountId, workshopList);
return await _reportRepository.GetWorkshopCheckoutDone(year, month, accountId, workshopList);
}
public WorkshopResult GetWorkshopCheckoutSignDone(string year, string month, long accountId, List<long> workshopList)
public async Task<WorkshopResult> GetWorkshopCheckoutSignDone(string year, string month, long accountId, List<long> workshopList)
{
return _reportRepository.GetWorkshopCheckoutSignDone(year, month, accountId, workshopList);
return await _reportRepository.GetWorkshopCheckoutSignDone(year, month, accountId, workshopList);
}
public List<EmployeeNotDone> GetEmployeeContract(string year, string month, long workshopId)
public async Task<List<EmployeeNotDone>> GetEmployeeContract(string year, string month, long workshopId)
{
return _reportRepository.GetEmployeeContract(year, month, workshopId);
return await _reportRepository.GetEmployeeContract(year, month, workshopId);
}
public List<EmployeeNotDone> GetEmployeeContractSign(string year, string month, long workshopId)
public async Task<List<EmployeeNotDone>> GetEmployeeContractSign(string year, string month, long workshopId)
{
return _reportRepository.GetEmployeeContractSign(year, month, workshopId);
return await _reportRepository.GetEmployeeContractSign(year, month, workshopId);
}
public List<EmployeeNotDone> GetEmployeeCheckout(string year, string month, long workshopId)
public async Task<List<EmployeeNotDone>> GetEmployeeCheckout(string year, string month, long workshopId)
{
return _reportRepository.GetEmployeeCheckout(year, month, workshopId);
return await _reportRepository.GetEmployeeCheckout(year, month, workshopId);
}
public List<EmployeeNotDone> GetEmployeeCheckoutSign(string year, string month, long workshopId)
public async Task<List<EmployeeNotDone>> GetEmployeeCheckoutSign(string year, string month, long workshopId)
{
return _reportRepository.GetEmployeeCheckoutSign(year, month, workshopId);
return await _reportRepository.GetEmployeeCheckoutSign(year, month, workshopId);
}
#region Print
public PrintAllContractCheckout GetPrintAllContractDone(string year, string month, long accountId,
public async Task<PrintAllContractCheckout> GetPrintAllContractDone(string year, string month, long accountId,
List<long> workshopList)
{
return _reportRepository.GetPrintAllContractDone(year, month, accountId, workshopList);
return await _reportRepository.GetPrintAllContractDone(year, month, accountId, workshopList);
}
public PrintAllContractCheckout GetPrintAllContractSignDone(string year, string month, long accountId,
public async Task<PrintAllContractCheckout> GetPrintAllContractSignDone(string year, string month, long accountId,
List<long> workshopList)
{
return _reportRepository.GetPrintAllContractSignDone(year, month, accountId, workshopList);
return await _reportRepository.GetPrintAllContractSignDone(year, month, accountId, workshopList);
}
public PrintAllContractCheckout GetPrintAllCheckoutDone(string year, string month, long accountId,
public async Task<PrintAllContractCheckout> GetPrintAllCheckoutDone(string year, string month, long accountId,
List<long> workshopList)
{
return _reportRepository.GetPrintAllCheckoutDone(year, month, accountId, workshopList);
return await _reportRepository.GetPrintAllCheckoutDone(year, month, accountId, workshopList);
}
public PrintAllContractCheckout GetPrintAllCheckoutSignDone(string year, string month, long accountId,
public async Task<PrintAllContractCheckout> GetPrintAllCheckoutSignDone(string year, string month, long accountId,
List<long> workshopList)
{
return _reportRepository.GetPrintAllCheckoutSignDone(year, month, accountId, workshopList);
return await _reportRepository.GetPrintAllCheckoutSignDone(year, month, accountId, workshopList);
}
#endregion

View File

@@ -45,6 +45,7 @@ using Company.Domain.FileEmployerAgg;
using Company.Domain.FileState;
using Company.Domain.FileTiming;
using Company.Domain.FileTitle;
using Company.Domain.FinancialInvoiceAgg;
using Company.Domain.FinancialStatmentAgg;
using Company.Domain.FinancialTransactionAgg;
using Company.Domain.FineAgg;
@@ -204,12 +205,13 @@ public class CompanyContext : DbContext
public DbSet<AuthorizedBankDetails> AuthorizedBankDetails { get; set; }
#endregion
public DbSet<FinancialInvoice> FinancialInvoices { get; set; }
#region Pooya
#endregion
public DbSet<EmployeeDocumentItem> EmployeeDocumentItems { get; set; }
#region Pooya
public DbSet<EmployeeDocumentItem> EmployeeDocumentItems { get; set; }
public DbSet<EmployeeDocuments> EmployeeDocuments { get; set; }
public DbSet<WorkshopSubAccount> WorkshopSubAccounts { get; set; }
@@ -230,6 +232,8 @@ public class CompanyContext : DbContext
#endregion
public DbSet<CheckoutWarningMessage> CheckoutWarningMessages { get; set; }
public DbSet<CustomizeCheckout> CustomizeCheckouts { get; set; }
public DbSet<CustomizeCheckoutTemp> CustomizeCheckoutTemps { get; set; }
public DbSet<TaxLeftWorkItem> TaxLeftWorkItems { get; set; }

View File

@@ -13,6 +13,7 @@
</PackageReference>
<PackageReference Include="Microsoft.QualityTools.Testing.Fakes" Version="16.11.230815" />
<PackageReference Include="MongoDB.Driver" Version="3.5.0" />
<PackageReference Include="Parbad.Gateway.Sepehr" Version="1.7.0" />
<PackageReference Include="PersianTools.Core" Version="2.0.4" />
</ItemGroup>

View File

@@ -50,12 +50,18 @@ class CheckoutMapping : IEntityTypeConfiguration<Checkout>
builder.Property(x => x.TotalDayOfLeaveCompute).HasMaxLength(10);
builder.Property(x => x.TotalDayOfYearsCompute).HasMaxLength(10);
builder.Property(x => x.TotalDayOfBunosesCompute).HasMaxLength(10);
builder.Property(x => x.EmployeeMandatoryHours).HasTimeSpanConversion();
builder.HasOne(x => x.Workshop)
.WithMany(x => x.Checkouts)
.HasForeignKey(x => x.WorkshopId);
builder.HasMany(x => x.CheckoutWarningMessageList)
.WithOne(x => x.Checkout)
.HasForeignKey(x => x.CheckoutId);
builder.OwnsMany(x => x.LoanInstallments, installments =>
{
installments.Property(x => x.AmountForMonth).HasMaxLength(25);

View File

@@ -0,0 +1,26 @@
using System;
using _0_Framework.Application.Enums;
using Company.Domain.CheckoutAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class CheckoutWarningMessageMapping : IEntityTypeConfiguration<CheckoutWarningMessage>
{
public void Configure(EntityTypeBuilder<CheckoutWarningMessage> builder)
{
builder.ToTable("CheckoutWarningMessage");
builder.HasKey(x => x.id);
builder.Property(x => x.WarningMessage).HasMaxLength(150);
builder.Property(x => x.TypeOfCheckoutWarning).HasConversion(
v => v.ToString(),
v => (TypeOfCheckoutWarning)Enum.Parse(typeof(TypeOfCheckoutWarning), v)).HasMaxLength(30);
builder.HasOne(x => x.Checkout)
.WithMany(x => x.CheckoutWarningMessageList)
.HasForeignKey(x => x.CheckoutId);
}
}

View File

@@ -0,0 +1,17 @@
using Company.Domain.FinancialInvoiceAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class FinancialInvoiceItemMapping : IEntityTypeConfiguration<FinancialInvoiceItem>
{
public void Configure(EntityTypeBuilder<FinancialInvoiceItem> builder)
{
builder.Property(x=>x.Description).HasMaxLength(800);
builder.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
builder.HasOne(x => x.FinancialInvoice).WithMany(x => x.Items)
.HasForeignKey(x => x.FinancialInvoiceId);
}
}

View File

@@ -0,0 +1,25 @@
using Company.Domain.FinancialInvoiceAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class FinancialInvoiceMapping:IEntityTypeConfiguration<FinancialInvoice>
{
public void Configure(EntityTypeBuilder<FinancialInvoice> builder)
{
builder.HasKey(x => x.id);
builder.Property(x => x.Status).HasConversion<string>().HasMaxLength(20);
builder.Property(x => x.PaidAt).IsRequired(false);
builder.Property(x => x.Description).HasMaxLength(800);
builder.Property(x => x.InvoiceNumber).HasMaxLength(22);
builder.HasMany(x => x.Items).WithOne(x => x.FinancialInvoice)
.HasForeignKey(x => x.FinancialInvoiceId).IsRequired().OnDelete(DeleteBehavior.Cascade);
builder.HasMany(x => x.PaymentTransactions).WithOne(x => x.FinancialInvoice)
.HasForeignKey(x => x.FinancialInvoiceId).IsRequired(false).OnDelete(DeleteBehavior.NoAction);
}
}

View File

@@ -14,7 +14,7 @@ public class FinancialTransactionMapping : IEntityTypeConfiguration<FinancialTra
builder.Property(x => x.TdateFa);
builder.Property(x => x.TdateFa).HasMaxLength(10);
builder.Property(x => x.TypeOfTransaction).HasMaxLength(10);
builder.Property(x => x.DescriptionOption).HasMaxLength(50);
builder.Property(x => x.DescriptionOption).HasMaxLength(100);
builder.Property(x => x.Description).HasMaxLength(600);
builder.Property(x => x.Deptor);
builder.Property(x => x.Creditor);

View File

@@ -15,8 +15,12 @@ public class PaymentTransactionMapping:IEntityTypeConfiguration<PaymentTransacti
builder.Property(x => x.CardNumber).HasMaxLength(25);
builder.Property(x => x.BankName).HasMaxLength(50);
builder.Property(x => x.Status).HasConversion<string>().HasMaxLength(35);
builder.Property(x => x.Gateway).HasConversion<string>().HasMaxLength(35);
builder.Property(x => x.ContractingPartyName).HasMaxLength(255);
builder.Property(x => x.CallBackUrl).HasMaxLength(500);
builder.Property(x => x.Rrn).HasMaxLength(50);
builder.Property(x => x.DigitalReceipt).HasMaxLength(50);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddfinancialInvoiceTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "FinancialInvoice",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Month = table.Column<int>(type: "int", nullable: false),
Year = table.Column<int>(type: "int", nullable: false),
Status = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
PaidAt = table.Column<DateTime>(type: "datetime2", nullable: true),
Amount = table.Column<double>(type: "float", nullable: false),
SmsCode = table.Column<string>(type: "nvarchar(122)", maxLength: 122, nullable: true),
FinancialStatementId = table.Column<long>(type: "bigint", nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FinancialInvoice", x => x.id);
table.ForeignKey(
name: "FK_FinancialInvoice_FinancialStatments_FinancialStatementId",
column: x => x.FinancialStatementId,
principalTable: "FinancialStatments",
principalColumn: "id");
});
migrationBuilder.CreateIndex(
name: "IX_FinancialInvoice_FinancialStatementId",
table: "FinancialInvoice",
column: "FinancialStatementId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FinancialInvoice");
}
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class hasInsuranceShareTheSameAsList_checkoutTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "HasInsuranceShareTheSameAsList",
table: "Checkouts",
type: "bit",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "HasInsuranceShareTheSameAsList",
table: "Checkouts");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class CheckoutWarningMessage : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsUpdateNeeded",
table: "Checkouts",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "CheckoutWarningMessage",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WarningMessage = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: true),
CheckoutId = table.Column<long>(type: "bigint", nullable: false),
TypeOfCheckoutWarning = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CheckoutWarningMessage", x => x.id);
table.ForeignKey(
name: "FK_CheckoutWarningMessage_Checkouts_CheckoutId",
column: x => x.CheckoutId,
principalTable: "Checkouts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CheckoutWarningMessage_CheckoutId",
table: "CheckoutWarningMessage",
column: "CheckoutId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CheckoutWarningMessage");
migrationBuilder.DropColumn(
name: "IsUpdateNeeded",
table: "Checkouts");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addGatewaysintransaction : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Gateway",
table: "PaymentTransactions",
type: "nvarchar(35)",
maxLength: 35,
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Gateway",
table: "PaymentTransactions");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addrrnanddigitalreceipt : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "DigitalReceipt",
table: "PaymentTransactions",
type: "nvarchar(50)",
maxLength: 50,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Rrn",
table: "PaymentTransactions",
type: "nvarchar(50)",
maxLength: 50,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DigitalReceipt",
table: "PaymentTransactions");
migrationBuilder.DropColumn(
name: "Rrn",
table: "PaymentTransactions");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,226 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addfinancialinvoice : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FinancialInvoice_FinancialStatments_FinancialStatementId",
table: "FinancialInvoice");
migrationBuilder.DropPrimaryKey(
name: "PK_FinancialInvoice",
table: "FinancialInvoice");
migrationBuilder.DropColumn(
name: "Month",
table: "FinancialInvoice");
migrationBuilder.DropColumn(
name: "SmsCode",
table: "FinancialInvoice");
migrationBuilder.DropColumn(
name: "Year",
table: "FinancialInvoice");
migrationBuilder.RenameTable(
name: "FinancialInvoice",
newName: "FinancialInvoices");
migrationBuilder.RenameColumn(
name: "FinancialStatementId",
table: "FinancialInvoices",
newName: "FinancialStatmentid");
migrationBuilder.RenameIndex(
name: "IX_FinancialInvoice_FinancialStatementId",
table: "FinancialInvoices",
newName: "IX_FinancialInvoices_FinancialStatmentid");
migrationBuilder.AddColumn<long>(
name: "FinancialInvoiceId",
table: "PaymentTransactions",
type: "bigint",
nullable: true);
migrationBuilder.AddColumn<long>(
name: "ContractingPartyId",
table: "FinancialInvoices",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<string>(
name: "Description",
table: "FinancialInvoices",
type: "nvarchar(800)",
maxLength: 800,
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsActive",
table: "FinancialInvoices",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<Guid>(
name: "PublicId",
table: "FinancialInvoices",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddPrimaryKey(
name: "PK_FinancialInvoices",
table: "FinancialInvoices",
column: "id");
migrationBuilder.CreateTable(
name: "FinancialInvoiceItem",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Description = table.Column<string>(type: "nvarchar(800)", maxLength: 800, nullable: true),
Amount = table.Column<double>(type: "float", nullable: false),
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
EntityId = table.Column<long>(type: "bigint", nullable: false),
FinancialInvoiceId = table.Column<long>(type: "bigint", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FinancialInvoiceItem", x => x.id);
table.ForeignKey(
name: "FK_FinancialInvoiceItem_FinancialInvoices_FinancialInvoiceId",
column: x => x.FinancialInvoiceId,
principalTable: "FinancialInvoices",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_PaymentTransactions_FinancialInvoiceId",
table: "PaymentTransactions",
column: "FinancialInvoiceId");
migrationBuilder.CreateIndex(
name: "IX_FinancialInvoiceItem_FinancialInvoiceId",
table: "FinancialInvoiceItem",
column: "FinancialInvoiceId");
migrationBuilder.AddForeignKey(
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
table: "FinancialInvoices",
column: "FinancialStatmentid",
principalTable: "FinancialStatments",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "FK_PaymentTransactions_FinancialInvoices_FinancialInvoiceId",
table: "PaymentTransactions",
column: "FinancialInvoiceId",
principalTable: "FinancialInvoices",
principalColumn: "id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
table: "FinancialInvoices");
migrationBuilder.DropForeignKey(
name: "FK_PaymentTransactions_FinancialInvoices_FinancialInvoiceId",
table: "PaymentTransactions");
migrationBuilder.DropTable(
name: "FinancialInvoiceItem");
migrationBuilder.DropIndex(
name: "IX_PaymentTransactions_FinancialInvoiceId",
table: "PaymentTransactions");
migrationBuilder.DropPrimaryKey(
name: "PK_FinancialInvoices",
table: "FinancialInvoices");
migrationBuilder.DropColumn(
name: "FinancialInvoiceId",
table: "PaymentTransactions");
migrationBuilder.DropColumn(
name: "ContractingPartyId",
table: "FinancialInvoices");
migrationBuilder.DropColumn(
name: "Description",
table: "FinancialInvoices");
migrationBuilder.DropColumn(
name: "IsActive",
table: "FinancialInvoices");
migrationBuilder.DropColumn(
name: "PublicId",
table: "FinancialInvoices");
migrationBuilder.RenameTable(
name: "FinancialInvoices",
newName: "FinancialInvoice");
migrationBuilder.RenameColumn(
name: "FinancialStatmentid",
table: "FinancialInvoice",
newName: "FinancialStatementId");
migrationBuilder.RenameIndex(
name: "IX_FinancialInvoices_FinancialStatmentid",
table: "FinancialInvoice",
newName: "IX_FinancialInvoice_FinancialStatementId");
migrationBuilder.AddColumn<int>(
name: "Month",
table: "FinancialInvoice",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "SmsCode",
table: "FinancialInvoice",
type: "nvarchar(122)",
maxLength: 122,
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Year",
table: "FinancialInvoice",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddPrimaryKey(
name: "PK_FinancialInvoice",
table: "FinancialInvoice",
column: "id");
migrationBuilder.AddForeignKey(
name: "FK_FinancialInvoice_FinancialStatments_FinancialStatementId",
table: "FinancialInvoice",
column: "FinancialStatementId",
principalTable: "FinancialStatments",
principalColumn: "id");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addinvoicenumber : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
table: "FinancialInvoices");
migrationBuilder.DropIndex(
name: "IX_FinancialInvoices_FinancialStatmentid",
table: "FinancialInvoices");
migrationBuilder.DropColumn(
name: "FinancialStatmentid",
table: "FinancialInvoices");
migrationBuilder.AddColumn<string>(
name: "InvoiceNumber",
table: "FinancialInvoices",
type: "nvarchar(18)",
maxLength: 18,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "InvoiceNumber",
table: "FinancialInvoices");
migrationBuilder.AddColumn<long>(
name: "FinancialStatmentid",
table: "FinancialInvoices",
type: "bigint",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_FinancialInvoices_FinancialStatmentid",
table: "FinancialInvoices",
column: "FinancialStatmentid");
migrationBuilder.AddForeignKey(
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
table: "FinancialInvoices",
column: "FinancialStatmentid",
principalTable: "FinancialStatments",
principalColumn: "id");
}
}
}

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class changemaxlengthforfinancialinvoicenumber : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "InvoiceNumber",
table: "FinancialInvoices",
type: "nvarchar(22)",
maxLength: 22,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(18)",
oldMaxLength: 18,
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "InvoiceNumber",
table: "FinancialInvoices",
type: "nvarchar(18)",
maxLength: 18,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(22)",
oldMaxLength: 22,
oldNullable: true);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class changedescriptionOptionmaxlength : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "DescriptionOption",
table: "FinancialTransactions",
type: "nvarchar(100)",
maxLength: 100,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50,
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "DescriptionOption",
table: "FinancialTransactions",
type: "nvarchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100,
oldNullable: true);
}
}
}

View File

@@ -415,6 +415,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<bool>("HasAmountConflict")
.HasColumnType("bit");
b.Property<bool>("HasInsuranceShareTheSameAsList")
.HasColumnType("bit");
b.Property<bool>("HasRollCall")
.HasColumnType("bit");
@@ -431,6 +434,9 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.Property<bool>("IsUpdateNeeded")
.HasColumnType("bit");
b.Property<bool>("LeaveCheckout")
.HasColumnType("bit");
@@ -543,6 +549,33 @@ namespace CompanyManagment.EFCore.Migrations
b.ToTable("Checkouts", (string)null);
});
modelBuilder.Entity("Company.Domain.CheckoutAgg.CheckoutWarningMessage", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<long>("CheckoutId")
.HasColumnType("bigint");
b.Property<string>("TypeOfCheckoutWarning")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("WarningMessage")
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.HasKey("id");
b.HasIndex("CheckoutId");
b.ToTable("CheckoutWarningMessage", (string)null);
});
modelBuilder.Entity("Company.Domain.ClassifiedSalaryAgg.ClassifiedSalary", b =>
{
b.Property<long>("id")
@@ -2794,6 +2827,86 @@ namespace CompanyManagment.EFCore.Migrations
b.ToTable("File_Titles", (string)null);
});
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<long>("ContractingPartyId")
.HasColumnType("bigint");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasMaxLength(800)
.HasColumnType("nvarchar(800)");
b.Property<string>("InvoiceNumber")
.HasMaxLength(22)
.HasColumnType("nvarchar(22)");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<DateTime?>("PaidAt")
.HasColumnType("datetime2");
b.Property<Guid>("PublicId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.HasKey("id");
b.ToTable("FinancialInvoices");
});
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoiceItem", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasMaxLength(800)
.HasColumnType("nvarchar(800)");
b.Property<long>("EntityId")
.HasColumnType("bigint");
b.Property<long>("FinancialInvoiceId")
.HasColumnType("bigint");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("id");
b.HasIndex("FinancialInvoiceId");
b.ToTable("FinancialInvoiceItem");
});
modelBuilder.Entity("Company.Domain.FinancialStatmentAgg.FinancialStatment", b =>
{
b.Property<long>("id")
@@ -2845,8 +2958,8 @@ namespace CompanyManagment.EFCore.Migrations
.HasColumnType("nvarchar(600)");
b.Property<string>("DescriptionOption")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<long>("FinancialStatementId")
.HasColumnType("bigint");
@@ -4957,6 +5070,22 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<string>("DigitalReceipt")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<long?>("FinancialInvoiceId")
.HasColumnType("bigint");
b.Property<string>("Gateway")
.IsRequired()
.HasMaxLength(35)
.HasColumnType("nvarchar(35)");
b.Property<string>("Rrn")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(35)
@@ -4971,6 +5100,8 @@ namespace CompanyManagment.EFCore.Migrations
b.HasKey("id");
b.HasIndex("FinancialInvoiceId");
b.ToTable("PaymentTransactions", (string)null);
});
@@ -7211,6 +7342,17 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("Workshop");
});
modelBuilder.Entity("Company.Domain.CheckoutAgg.CheckoutWarningMessage", b =>
{
b.HasOne("Company.Domain.CheckoutAgg.Checkout", "Checkout")
.WithMany("CheckoutWarningMessageList")
.HasForeignKey("CheckoutId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Checkout");
});
modelBuilder.Entity("Company.Domain.ClientEmployeeWorkshopAgg.ClientEmployeeWorkshop", b =>
{
b.HasOne("Company.Domain.EmployeeAgg.Employee", "Employee")
@@ -9893,6 +10035,17 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("FileTiming");
});
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoiceItem", b =>
{
b.HasOne("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", "FinancialInvoice")
.WithMany("Items")
.HasForeignKey("FinancialInvoiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("FinancialInvoice");
});
modelBuilder.Entity("Company.Domain.FinancialTransactionAgg.FinancialTransaction", b =>
{
b.HasOne("Company.Domain.FinancialStatmentAgg.FinancialStatment", "FinancialStatment")
@@ -10440,6 +10593,16 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("PaymentToEmployee");
});
modelBuilder.Entity("Company.Domain.PaymentTransactionAgg.PaymentTransaction", b =>
{
b.HasOne("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", "FinancialInvoice")
.WithMany("PaymentTransactions")
.HasForeignKey("FinancialInvoiceId")
.OnDelete(DeleteBehavior.NoAction);
b.Navigation("FinancialInvoice");
});
modelBuilder.Entity("Company.Domain.PenaltyTitle.PenaltyTitle", b =>
{
b.HasOne("Company.Domain.Petition.Petition", "Petition")
@@ -10730,6 +10893,11 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("PetitionsList");
});
modelBuilder.Entity("Company.Domain.CheckoutAgg.Checkout", b =>
{
b.Navigation("CheckoutWarningMessageList");
});
modelBuilder.Entity("Company.Domain.ContarctingPartyAgg.PersonalContractingParty", b =>
{
b.Navigation("ContractingPartyBankAccounts");
@@ -10839,6 +11007,13 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("FileStates");
});
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", b =>
{
b.Navigation("Items");
b.Navigation("PaymentTransactions");
});
modelBuilder.Entity("Company.Domain.FinancialStatmentAgg.FinancialStatment", b =>
{
b.Navigation("FinancialTransactionList");

View File

@@ -524,6 +524,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
entity.SetLoanInstallment(command.LoanInstallments, command.InstallmentDeduction);
entity.SetCheckoutRollCall(command.CheckoutRollCall);
entity.SetEmployeeMandatoryHours(command.EmployeeMandatoryHours);
if(command.HasInsuranceShareTheSameAsList)
entity.SetInsuranceShare();
await _context.SaveChangesAsync();
}
@@ -1689,7 +1691,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
return new List<CheckoutViewModel>();
}
#endregion
var query = _context.CheckoutSet
var query = _context.CheckoutSet.Include(w => w.CheckoutWarningMessageList)
.AsSplitQuery().Select(x => new CheckoutViewModel()
{
Id = x.id,
@@ -1724,7 +1726,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
SalaryAidDateTimeGe = s.SalaryAidDateTime
}).ToList(),
HasAmountConflict = x.HasAmountConflict
HasAmountConflict = x.HasAmountConflict,
IsUpdateNeeded = x.IsUpdateNeeded,
CheckoutWarningMessageList = x.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
{
WarningMessage = wm.WarningMessage,
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
}).ToList()
}).Where(x => x.WorkshopId == searchModel.WorkshopId);
if (searchModel.EmployeeId > 0)
@@ -1992,7 +2001,7 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
// );
var checkouts =
_context.CheckoutSet.Where(x => workshopAcounts.Contains(x.WorkshopId))
_context.CheckoutSet.Include(w=>w.CheckoutWarningMessageList).Where(x => workshopAcounts.Contains(x.WorkshopId))
.Join(_context.Workshops.AsSplitQuery(),
ch => ch.WorkshopId,
workshop => workshop.id,
@@ -2261,7 +2270,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
CreationDate = x.ch.CreationDate,
EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
IsBlockCantracingParty = x.contractingParty.IsBlock,
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
IsUpdateNeeded = x.ch.IsUpdateNeeded,
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm=> new CheckoutWarningMessageModel
{
WarningMessage = wm.WarningMessage,
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
}).ToList()
}).OrderByDescending(x=>x.Id).Take(3000).ToList().DistinctBy(x => x.Id)
@@ -2299,7 +2315,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
CreationDate = x.ch.CreationDate,
EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
IsBlockCantracingParty = x.contractingParty.IsBlock,
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
IsUpdateNeeded = x.ch.IsUpdateNeeded,
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
{
WarningMessage = wm.WarningMessage,
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
}).ToList()
}).OrderByDescending(x => x.Id)
.GroupBy(x => x.Id)
@@ -2365,7 +2388,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
CreationDate = x.ch.CreationDate,
EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
IsBlockCantracingParty = x.contractingParty.IsBlock,
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
IsUpdateNeeded = x.ch.IsUpdateNeeded,
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
{
WarningMessage = wm.WarningMessage,
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
}).ToList()
}).GroupBy(x => x.Id).Select(x => x.First()).ToList()
.OrderByDescending(x => x.ContractStartGr).ToList();
@@ -2398,7 +2428,14 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
CreationDate = x.ch.CreationDate,
EmployerName = $"{x.workshopEmployer.Employer.FName} {x.workshopEmployer.Employer.LName}",
IsBlockCantracingParty = x.contractingParty.IsBlock,
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout
HasSignCheckout = x.option != null ? x.option.SignCheckout : x.workshop.SignCheckout,
IsUpdateNeeded = x.ch.IsUpdateNeeded,
CheckoutWarningMessageList = x.ch.CheckoutWarningMessageList.Select(wm => new CheckoutWarningMessageModel
{
WarningMessage = wm.WarningMessage,
TypeOfCheckoutWarning = wm.TypeOfCheckoutWarning,
}).ToList()
}).GroupBy(x => x.Id)
.Select(x => x.First()).ToList()

View File

@@ -19,39 +19,41 @@ using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyContext, IRollCallEmployeeRepository _rollCallEmployeeRepository)
public class CustomizeWorkshopGroupSettingsRepository(
CompanyContext companyContext,
IRollCallEmployeeRepository _rollCallEmployeeRepository)
: RepositoryBase<long, CustomizeWorkshopGroupSettings>(companyContext),
ICustomizeWorkshopGroupSettingsRepository
{
private readonly CompanyContext _companyContext = companyContext;
private readonly IRollCallEmployeeRepository _rollCallEmployeeRepository = _rollCallEmployeeRepository;
public CustomizeWorkshopGroupSettings GetIncludeWorkshopSettings(long id)
{
return _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery().Include(x => x.CustomizeWorkshopSettings)
.FirstOrDefault(x => x.id == id);
.FirstOrDefault(x => x.id == id);
}
public CustomizeWorkshopGroupSettings GetWorkshopMainGroup(long workshopId)
{
return _companyContext.CustomizeWorkshopGroupSettings
.Include(x=>x.CustomizeWorkshopSettings)
.Include(x=> x.CustomizeWorkshopEmployeeSettingsCollection)
.AsSplitQuery().FirstOrDefault(x => x.MainGroup && x.CustomizeWorkshopSettings.WorkshopId == workshopId);
return _companyContext.CustomizeWorkshopGroupSettings
.Include(x => x.CustomizeWorkshopSettings)
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.AsSplitQuery().FirstOrDefault(x => x.MainGroup && x.CustomizeWorkshopSettings.WorkshopId == workshopId);
}
public List<EmployeeViewModel> GetEmployeesWithoutGroup(long customizeWorkshopSettingId)
{
var workshopSettings = _companyContext.CustomizeWorkshopSettings.Find(customizeWorkshopSettingId);
var workshopSettings = _companyContext.CustomizeWorkshopSettings.Find(customizeWorkshopSettingId);
if (workshopSettings == null)
return new();
var existsEmployees = _companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery().Include(x=>x.CustomizeWorkshopGroupSettings)
.Where(x => x.WorkshopId == workshopSettings.WorkshopId && !x.CustomizeWorkshopGroupSettings.MainGroup)
.Select(x=>x.EmployeeId).ToList();
.AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => x.WorkshopId == workshopSettings.WorkshopId && !x.CustomizeWorkshopGroupSettings.MainGroup)
.Select(x => x.EmployeeId).ToList();
var workshopId = workshopSettings.WorkshopId;
var rollCallEmployees = _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
@@ -81,79 +83,81 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
var dateNow = DateTime.Now.Date;
//var existsEmployees = _companyContext.CustomizeWorkshopEmployeeSettings
// .AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettings)
// .Where(x => x.WorkshopId == workshopId && !x.CustomizeWorkshopGroupSettings.MainGroup)
// .Select(x => x.EmployeeId).ToList();
//var existsEmployees = _companyContext.CustomizeWorkshopEmployeeSettings
// .AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettings)
// .Where(x => x.WorkshopId == workshopId && !x.CustomizeWorkshopGroupSettings.MainGroup)
// .Select(x => x.EmployeeId).ToList();
//var rollCallEmployees = _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
//var rollCallEmployees = _rollCallEmployeeRepository.GetActivePersonnelByWorkshopId(workshopId);
//var employees = rollCallEmployees
// .Where(x => !existsEmployees.Contains(x.EmployeeId))
// .Select(x => new EmployeeViewModel()
// {
// EmployeeFullName = x.EmployeeFullName,
// Id = x.EmployeeId
// }).ToList();
//var employees = rollCallEmployees
// .Where(x => !existsEmployees.Contains(x.EmployeeId))
// .Select(x => new EmployeeViewModel()
// {
// EmployeeFullName = x.EmployeeFullName,
// Id = x.EmployeeId
// }).ToList();
var employees = _companyContext.RollCallEmployees
.Include(x =>
x.EmployeesStatus)
.Where(
x =>
x.WorkshopId == workshopId &&
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
x.HasUploadedImage == "true")
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery()
.Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => !x.CustomizeWorkshopGroupSettings.MainGroup && x.WorkshopId == workshopId), rollCallEmployee => rollCallEmployee.EmployeeId,
cws => cws.EmployeeId,
(rollCallEmployee, cws) => new { rollCallEmployee, cws })
.SelectMany(x => x.cws.DefaultIfEmpty(), (x, cws) => new { x.rollCallEmployee, cws })
.Where(x => x.cws == null).Select(x=> new EmployeeViewModel()
{
var employees = _companyContext.RollCallEmployees
.Include(x =>
x.EmployeesStatus)
.Where(x =>
x.WorkshopId == workshopId &&
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
x.HasUploadedImage == "true")
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery()
.Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => !x.CustomizeWorkshopGroupSettings.MainGroup && x.WorkshopId == workshopId),
rollCallEmployee => rollCallEmployee.EmployeeId,
cws => cws.EmployeeId,
(rollCallEmployee, cws) => new { rollCallEmployee, cws })
.SelectMany(x => x.cws.DefaultIfEmpty(), (x, cws) => new { x.rollCallEmployee, cws })
.Where(x => x.cws == null).Select(x => new EmployeeViewModel()
{
EmployeeFullName = x.rollCallEmployee.EmployeeFullName,
Id = x.rollCallEmployee.EmployeeId
});
});
return employees.ToList();
return employees.ToList();
}
public bool HasAnyEmployeeWithoutGroup(long workshopId)
{
var dateNow = DateTime.Now.Date;
var dateNow = DateTime.Now.Date;
var leftWork = _companyContext.LeftWorkList.Where(x =>
x.WorkshopId == workshopId && x.StartWorkDate <= dateNow && x.LeftWorkDate >= dateNow);
var rollCallEmployeesWithoutCWS = _companyContext.RollCallEmployees
.Include(x =>
x.EmployeesStatus)
.Where(
x =>
x.WorkshopId == workshopId &&
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
x.HasUploadedImage == "true"&&
leftWork.Any(l => l.EmployeeId == x.EmployeeId && l.WorkshopId == x.WorkshopId))
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery()
.Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => !x.CustomizeWorkshopGroupSettings.MainGroup && x.WorkshopId == workshopId), rollCallEmployee => rollCallEmployee.EmployeeId,
cws => cws.EmployeeId,
(rollCallEmployee, cws) => new { rollCallEmployee, cws })
.SelectMany(x => x.cws.DefaultIfEmpty(), (x, cws) => new { x.rollCallEmployee, cws })
.Any(x => x.cws == null);
return rollCallEmployeesWithoutCWS;
.Include(x =>
x.EmployeesStatus)
.Where(x =>
x.WorkshopId == workshopId &&
x.EmployeesStatus.Any(y => y.StartDate.Date <= dateNow && y.EndDate.Date > dateNow) &&
x.HasUploadedImage == "true" &&
leftWork.Any(l => l.EmployeeId == x.EmployeeId && l.WorkshopId == x.WorkshopId))
.GroupJoin(_companyContext.CustomizeWorkshopEmployeeSettings
.AsSplitQuery()
.Include(x => x.CustomizeWorkshopGroupSettings)
.Where(x => !x.CustomizeWorkshopGroupSettings.MainGroup && x.WorkshopId == workshopId),
rollCallEmployee => rollCallEmployee.EmployeeId,
cws => cws.EmployeeId,
(rollCallEmployee, cws) => new { rollCallEmployee, cws })
.SelectMany(x => x.cws.DefaultIfEmpty(), (x, cws) => new { x.rollCallEmployee, cws })
.Any(x => x.cws == null);
return rollCallEmployeesWithoutCWS;
}
public CustomizeWorkshopGroupSettings GetWithEmployees(long groupId)
{
return _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery().Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
return _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery()
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.id == groupId);
}
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetShiftChangedEmployeeSettingsByGroupSettingsId(long groupSettingsId)
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetShiftChangedEmployeeSettingsByGroupSettingsId(
long groupSettingsId)
{
var groupEmployeeSettingsList = _companyContext.CustomizeWorkshopGroupSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
@@ -169,23 +173,26 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
x.id
}).ToList();
return groupEmployeeSettingsList.Join(employees, x => x.EmployeeId, y => y.id, (x, y) => new CustomizeWorkshopEmployeeSettingsViewModel()
{
EmployeeId = x.EmployeeId,
Id = x.id,
IsShiftChanged = x.IsShiftChanged,
IsSettingChanged = x.IsSettingChanged,
Name = y.FullName,
RollCallWorkshopShifts = x.CustomizeWorkshopEmployeeSettingsShifts.Select(z => new CustomizeWorkshopShiftViewModel()
return groupEmployeeSettingsList.Join(employees, x => x.EmployeeId, y => y.id, (x, y) =>
new CustomizeWorkshopEmployeeSettingsViewModel()
{
EndTime = z.EndTime.ToString("HH:mm"),
Placement = z.Placement,
StartTime = z.StartTime.ToString("HH:mm")
}).ToList()
}).ToList();
EmployeeId = x.EmployeeId,
Id = x.id,
IsShiftChanged = x.IsShiftChanged,
IsSettingChanged = x.IsSettingChanged,
Name = y.FullName,
RollCallWorkshopShifts = x.CustomizeWorkshopEmployeeSettingsShifts.Select(z =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = z.EndTime.ToString("HH:mm"),
Placement = z.Placement,
StartTime = z.StartTime.ToString("HH:mm")
}).ToList()
}).ToList();
}
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetSettingChangedEmployeeSettingsByGroupSettingsId(long groupSettingsId)
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetSettingChangedEmployeeSettingsByGroupSettingsId(
long groupSettingsId)
{
var groupEmployeeSettingsList = _companyContext.CustomizeWorkshopGroupSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
@@ -201,38 +208,52 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
x.id
}).ToList();
return groupEmployeeSettingsList.Join(employees, x => x.EmployeeId, y => y.id, (x, y) => new CustomizeWorkshopEmployeeSettingsViewModel()
{
EmployeeId = x.EmployeeId,
Id = x.id,
IsSettingChanged = x.IsSettingChanged,
IsShiftChanged = x.IsShiftChanged,
Name = y.FullName,
RollCallWorkshopShifts = x.CustomizeWorkshopEmployeeSettingsShifts.Select(z => new CustomizeWorkshopShiftViewModel()
return groupEmployeeSettingsList.Join(employees, x => x.EmployeeId, y => y.id, (x, y) =>
new CustomizeWorkshopEmployeeSettingsViewModel()
{
EndTime = z.EndTime.ToString("HH:mm"),
Placement = z.Placement,
StartTime = z.StartTime.ToString("HH:mm")
}).ToList()
}).ToList();
EmployeeId = x.EmployeeId,
Id = x.id,
IsSettingChanged = x.IsSettingChanged,
IsShiftChanged = x.IsShiftChanged,
Name = y.FullName,
RollCallWorkshopShifts = x.CustomizeWorkshopEmployeeSettingsShifts.Select(z =>
new CustomizeWorkshopShiftViewModel()
{
EndTime = z.EndTime.ToString("HH:mm"),
Placement = z.Placement,
StartTime = z.StartTime.ToString("HH:mm")
}).ToList()
}).ToList();
}
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsByGroupSettingsId(long groupSettingsId)
{
var entity = _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery().Include(x=>x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.id == groupSettingsId);
var entity = _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery()
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.FirstOrDefault(x => x.id == groupSettingsId);
if (entity == null)
return new();
var employees = entity.CustomizeWorkshopEmployeeSettingsCollection;
if (employees.Count == 0)
return [];
var workshopId = employees.FirstOrDefault()?.WorkshopId??0;
if (workshopId == 0)
return [];
var employeeIds = employees.Select(x => x.EmployeeId).ToList();
var employeeIds = employees.Select(x => x.EmployeeId);
var names = _companyContext.Employees.Where(x => employeeIds.Contains(x.id))
.Select(x => new { x.id, x.FullName }).ToList();
var names = _companyContext.Employees.Where(x => employeeIds.Contains(x.id)).Select(x => new { x.id, x.FullName }).ToList();
var leftWork = _companyContext.LeftWorkList.Where(x =>
x.WorkshopId == workshopId &&
employeeIds.Contains(x.EmployeeId)).ToList();
var joinedList = employees.Join(names, x => x.EmployeeId, y => y.id, (x, y) =>
new CustomizeWorkshopEmployeeSettingsViewModel
@@ -243,82 +264,86 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
Salary = x.Salary,
IsSettingChanged = x.IsSettingChanged,
IsShiftChanged = x.IsShiftChanged,
RollCallWorkshopShifts = x.CustomizeWorkshopEmployeeSettingsShifts.Select(z => new CustomizeWorkshopShiftViewModel()
{
EndTime = z.EndTime.ToString("HH:mm"),
StartTime = z.StartTime.ToString("HH:mm"),
Placement = z.Placement
}).ToList(),
RollCallWorkshopShifts = x.CustomizeWorkshopEmployeeSettingsShifts
.Select(z => new CustomizeWorkshopShiftViewModel()
{
EndTime = z.EndTime.ToString("HH:mm"),
StartTime = z.StartTime.ToString("HH:mm"),
Placement = z.Placement
}).ToList(),
IrregularShift = x.IrregularShift,
WorkshopShiftStatus = x.WorkshopShiftStatus,
LeavePermittedDays = x.LeavePermittedDays,
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts
.Select(r=> new CustomizeRotatingShiftsViewModel(){StartTime = r.StartTime.ToString("HH:mm") , EndTime =r.EndTime.ToString("HH:mm") }).ToList()
.Select(r => new CustomizeRotatingShiftsViewModel
{
StartTime = r.StartTime.ToString("HH:mm"),
EndTime = r.EndTime.ToString("HH:mm")
}).ToList(),
HasLeft = leftWork.OrderByDescending(l=>l.StartWorkDate).FirstOrDefault(l => x.EmployeeId == l.EmployeeId)?.HasLeft ?? false
});
return joinedList.ToList();
return joinedList.OrderBy(x=>x.HasLeft).ToList();
}
public EditCustomizeWorkshopGroupSettings GetCustomizeWorkshopGroupSettingsDetails(long groupId)
{
var entity = _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery().FirstOrDefault(x => x.id == groupId);
return new EditCustomizeWorkshopGroupSettings()
{
//FridayWork = entity.FridayWork,
FridayPay = new (){ FridayPayType = entity.FridayPay.FridayPayType, Value = entity.FridayPay.Value },
FridayPay = new() { FridayPayType = entity.FridayPay.FridayPayType, Value = entity.FridayPay.Value },
LateToWork = new()
{
{
LateToWorkTimeFinesVewModels = entity.LateToWork.LateToWorkTimeFines.Select(x =>
new LateToWorkTimeFineVewModel() { FineMoney = x.FineMoney, Minute = x.Minute }).ToList(),
Value = entity.LateToWork.Value, LateToWorkType = entity.LateToWork.LateToWorkType
},
HolidayWork = entity.HolidayWork,
FineAbsenceDeduction = new()
{
{
Value = entity.FineAbsenceDeduction.Value,
FineAbsenceDayOfWeekViewModels = entity.FineAbsenceDeduction.FineAbsenceDayOfWeekCollection
.Select(x => new FineAbsenceDayOfWeekViewModel() { DayOfWeek = x.DayOfWeek }).ToList(),
FineAbsenceDeductionType = entity.FineAbsenceDeduction.FineAbsenceDeductionType
},
EarlyExit = new()
{
{
EarlyExitTimeFinesViewModels = entity.EarlyExit.EarlyExitTimeFines.Select(x =>
new EarlyExitTimeFineViewModel() { FineMoney = x.FineMoney, Minute = x.Minute }).ToList(),
Value = entity.EarlyExit.Value, EarlyExitType = entity.EarlyExit.EarlyExitType
},
BonusesPay = new()
{
{
Value = entity.BonusesPay.Value, BonusesPayType = entity.BonusesPay.BonusesPayType,
PaymentType = entity.BonusesPay.PaymentType
},
ShiftPay = new()
{
{
Value = entity.ShiftPay.Value, ShiftPayType = entity.ShiftPay.ShiftPayType,
ShiftType = entity.ShiftPay.ShiftType
},
InsuranceDeduction = new()
{
{
Value = entity.InsuranceDeduction.Value,
InsuranceDeductionType = entity.InsuranceDeduction.InsuranceDeductionType
},
OverTimePay = new()
{ OverTimePayType = entity.OverTimePay.OverTimePayType, Value = entity.OverTimePay.Value },
{ OverTimePayType = entity.OverTimePay.OverTimePayType, Value = entity.OverTimePay.Value },
BaseYearsPay = new()
{
{
BaseYearsPayType = entity.BaseYearsPay.BaseYearsPayType,
Value = entity.BaseYearsPay.Value
},
NightWorkPay = new()
{ NightWorkingType = entity.NightWorkPay.NightWorkingType, Value = entity.NightWorkPay.Value },
LeavePay =new() { Value = entity.LeavePay.Value, LeavePayType = entity.LeavePay.LeavePayType },
{ NightWorkingType = entity.NightWorkPay.NightWorkingType, Value = entity.NightWorkPay.Value },
LeavePay = new() { Value = entity.LeavePay.Value, LeavePayType = entity.LeavePay.LeavePayType },
MarriedAllowance = new()
{
{
Value = entity.MarriedAllowance.Value,
MarriedAllowanceType = entity.MarriedAllowance.MarriedAllowanceType
},
FamilyAllowance = new()
{
{
FamilyAllowanceType = entity.FamilyAllowance.FamilyAllowanceType,
Value = entity.FamilyAllowance.Value
},
@@ -332,23 +357,27 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
IsShiftChanged = entity.IsShiftChange,
ShiftViewModel = entity.CustomizeWorkshopGroupSettingsShifts.Select(x =>
new CustomizeWorkshopShiftViewModel()
{ EndTime = x.EndTime.ToString("HH:mm"), Placement = x.Placement, StartTime = x.StartTime.ToString("HH:mm") }).ToList(),
{
EndTime = x.EndTime.ToString("HH:mm"), Placement = x.Placement,
StartTime = x.StartTime.ToString("HH:mm")
}).ToList(),
LeavePermittedDays = entity.LeavePermittedDays,
CustomizeRotatingShiftsViewModels = entity.CustomizeRotatingShifts.Select(x=> new CustomizeRotatingShiftsViewModel()
{
EndTime = x.EndTime.ToString("HH:mm"),
StartTime = x.StartTime.ToString("HH:mm")
}).ToList(),
OffDayOfWeeks = entity.WeeklyOffDays.Select(x=>x.DayOfWeek).ToList()
CustomizeRotatingShiftsViewModels = entity.CustomizeRotatingShifts.Select(x =>
new CustomizeRotatingShiftsViewModel()
{
EndTime = x.EndTime.ToString("HH:mm"),
StartTime = x.StartTime.ToString("HH:mm")
}).ToList(),
OffDayOfWeeks = entity.WeeklyOffDays.Select(x => x.DayOfWeek).ToList()
};
}
public List<CustomizeWorkshopGroupSettings> GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(long workshopSettingsId)
public List<CustomizeWorkshopGroupSettings> GetAllGroupsIncludeEmployeeSettingsByWorkshopSettingsId(
long workshopSettingsId)
{
return _companyContext.CustomizeWorkshopGroupSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.Where(x => x.CustomizeWorkshopSettingId == workshopSettingsId).ToList();
return _companyContext.CustomizeWorkshopGroupSettings
.AsSplitQuery().Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)
.Where(x => x.CustomizeWorkshopSettingId == workshopSettingsId).ToList();
}
public void Remove(long groupId)
@@ -360,7 +389,8 @@ public class CustomizeWorkshopGroupSettingsRepository(CompanyContext companyCont
_companyContext.SaveChanges();
}
public CustomizeWorkshopGroupSettingsViewModel GetEmployeesGroupSettingsByEmployeeId(long employeeId, long workshopId)
public CustomizeWorkshopGroupSettingsViewModel GetEmployeesGroupSettingsByEmployeeId(long employeeId,
long workshopId)
{
return _companyContext.CustomizeWorkshopGroupSettings
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection)

View File

@@ -0,0 +1,103 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.FinancialInvoiceAgg;
using CompanyManagment.App.Contracts.FinancialInvoice;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
public class FinancialInvoiceRepository : RepositoryBase<long, FinancialInvoice>, IFinancialInvoiceRepository
{
private readonly CompanyContext _context;
public FinancialInvoiceRepository(CompanyContext context) : base(context)
{
_context = context;
}
public EditFinancialInvoice GetDetails(long id)
{
var financialInvoice = _context.FinancialInvoices
.Include(x => x.Items)
.FirstOrDefault(x => x.id == id);
if (financialInvoice == null)
return null;
return new EditFinancialInvoice
{
Id = financialInvoice.id,
Description = financialInvoice.Description,
Amount = financialInvoice.Amount,
Status = financialInvoice.Status,
InvoiceNumber = financialInvoice.InvoiceNumber,
Items = financialInvoice.Items?.Select(x => new EditFinancialInvoiceItem
{
Id = x.id,
Description = x.Description,
Amount = x.Amount,
Type = x.Type,
EntityId = x.EntityId
}).ToList()
};
}
public List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel)
{
var query = _context.FinancialInvoices
.Include(x => x.Items)
.AsQueryable();
if (!string.IsNullOrWhiteSpace(searchModel.Description))
query = query.Where(x => x.Description.Contains(searchModel.Description));
if (searchModel.Status.HasValue)
query = query.Where(x => x.Status == searchModel.Status.Value);
if (searchModel.ContractingPartyId.HasValue)
query = query.Where(x => x.ContractingPartyId == searchModel.ContractingPartyId.Value);
if (!string.IsNullOrWhiteSpace(searchModel.FromDate))
{
var fromDate = searchModel.FromDate.ToGeorgianDateTime();
query = query.Where(x => x.CreationDate >= fromDate);
}
if (!string.IsNullOrWhiteSpace(searchModel.ToDate))
{
var toDate = searchModel.ToDate.ToGeorgianDateTime();
query = query.Where(x => x.CreationDate <= toDate);
}
if (searchModel.MinAmount.HasValue)
query = query.Where(x => x.Amount >= searchModel.MinAmount.Value);
if (searchModel.MaxAmount.HasValue)
query = query.Where(x => x.Amount <= searchModel.MaxAmount.Value);
return query.OrderByDescending(x => x.id)
.Select(x => new FinancialInvoiceViewModel
{
Id = x.id,
Description = x.Description,
Status = x.Status.ToString(),
PaidAt = x.PaidAt.HasValue ? x.PaidAt.Value.ToFarsi() : "",
Amount = x.Amount,
PublicId = x.PublicId,
ContractingPartyId = x.ContractingPartyId,
CreationDate = x.CreationDate.ToFarsi(),
ItemsCount = x.Items != null ? x.Items.Count : 0
}).ToList();
}
public async Task<FinancialInvoice> GetUnPaidByEntityId(long entityId,
FinancialInvoiceItemType financialInvoiceItemType)
{
return await _context.FinancialInvoices.Include(x => x.Items)
.Where(x => x.Status == FinancialInvoiceStatus.Unpaid).FirstOrDefaultAsync(x => x.Items
.Any(y => y.Type == financialInvoiceItemType && y.EntityId == entityId));
}
}

View File

@@ -265,7 +265,21 @@ public class FinancialStatmentRepository : RepositoryBase<long, FinancialStatmen
}
public async Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel)
public async Task<double> GetClientDebtAmountByContractingPartyId(long contractingPartyId)
{
var resStatement = await _context.FinancialStatments.Include(x => x.FinancialTransactionList)
.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
if (resStatement == null)
return 0;
return resStatement.FinancialTransactionList.Sum(x => x.Deptor) -
resStatement.FinancialTransactionList.Sum(x => x.Creditor);
}
public async Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel)
{
var contractingParty = await _context.PersonalContractingParties
.FirstOrDefaultAsync(x=>x.id == contractingPartyId);
@@ -413,6 +427,6 @@ public class FinancialStatmentRepository : RepositoryBase<long, FinancialStatmen
public async Task<FinancialStatment> GetByContractingPartyId(long contractingPartyId)
{
return await _context.FinancialStatments.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
return await _context.FinancialStatments.Include(x=>x.FinancialTransactionList).FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
}
}

View File

@@ -124,7 +124,7 @@ public class FineRepository : RepositoryBase<long, Fine>, IFineRepository
}
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
var list = query.ToList().Select(x => new FineViewModel()
var list = query.OrderByDescending(x=>x.FineDate).ToList().Select(x => new FineViewModel()
{
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,

View File

@@ -14,6 +14,7 @@ using _0_Framework.InfraStructure;
using Company.Domain.ContarctingPartyAgg;
using Company.Domain.ContractingPartyAccountAgg;
using Company.Domain.empolyerAgg;
using Company.Domain.FinancialInvoiceAgg;
using Company.Domain.FinancialStatmentAgg;
using Company.Domain.FinancialTransactionAgg;
using Company.Domain.InstitutionContractAgg;
@@ -23,6 +24,7 @@ using Company.Domain.InstitutionContractExtensionTempAgg;
using Company.Domain.InstitutionPlanAgg;
using Company.Domain.WorkshopAgg;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.FinancialInvoice;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.InstitutionContractContactinfo;
using CompanyManagment.App.Contracts.Law;
@@ -1839,7 +1841,10 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
public async Task<InstitutionContract> GetByPublicIdAsync(Guid id)
{
return await _context.InstitutionContractSet.Include(x=>x.ContactInfoList).FirstOrDefaultAsync(x => x.PublicId == id);
return await _context.InstitutionContractSet
.Include(x=>x.ContactInfoList)
.Include(x=>x.Installments)
.FirstOrDefaultAsync(x => x.PublicId == id);
}
#region Extension
@@ -2295,6 +2300,10 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
}
var today = DateTime.Today;
double invoiceAmount;
string invoiceItemDescription;
FinancialInvoiceItemType invoiceItemType;
long invoiceItemEntityId;
if (request.IsInstallment && payment is InstitutionContractPaymentMonthlyViewModel monthly)
{
var installments = monthly.Installments.Select(x =>
@@ -2311,23 +2320,40 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
// ایجاد قسط جدید با تاریخ امروز
var todayInstallment = new InstitutionContractInstallment(DateTime.Today, firstInstallmentAmount, "");
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
// اضافه کردن قسط جدید به ابتدای لیست
installments.Insert(0, todayInstallment);
entity.SetInstallments(installments);
await SaveChangesAsync();
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
"قسط اول سرویس", "debt", "بابت خدمات", firstInstallmentAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
invoiceAmount = firstInstallmentAmount;
invoiceItemDescription = $"پرداخت قسط اول قرارداد شماره {entity.ContractNo}";
invoiceItemType = FinancialInvoiceItemType.BuyInstitutionContractInstallment;
invoiceItemEntityId = todayInstallment.Id;
}
else
{
var financialTransaction = new FinancialTransaction(0, today, today.ToFarsi(),
"پرداخت کل سرویس", "debt", "بابت خدمات", totalAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
invoiceAmount = totalAmount;
invoiceItemDescription = $"پرداخت کل قرارداد شماره {entity.ContractNo}";
invoiceItemType = FinancialInvoiceItemType.BuyInstitutionContract;
invoiceItemEntityId = entity.id;
}
var financialInvoice = new FinancialInvoice(invoiceAmount, contractingParty.id, $"خرید قرارداد مالی شماره {entity.ContractNo}");
var financialInvoiceItem = new FinancialInvoiceItem(invoiceItemDescription, invoiceAmount, 0,invoiceItemType, invoiceItemEntityId);
financialInvoice.AddItem(financialInvoiceItem);
await _context.AddAsync(financialInvoice);
await SaveChangesAsync();
foreach (var contactInfo in institutionContractTemp.ContactInfos)
{
if (contactInfo.PhoneNumber != null)
@@ -2342,8 +2368,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
await SaveChangesAsync();
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId);
await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName,
entity.PublicId, contractingParty.id, entity.id);
await SaveChangesAsync();
@@ -2623,10 +2649,12 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
Id = x.id,
Text = x.WorkshopFullName
});
var employers = _context.Employers.Select(x => new InstitutionContractSelectListViewModel()
//کارفرما ها به غیر از آن هایی که به طرف حساب ---- وصل هستند
var employers = _context.Employers.Where(x=>x.ContractingPartyId != 30428)
.Select(x => new InstitutionContractSelectListViewModel()
{
Id = x.id,
Text = x.FName + " " + x.LName
Text = x.FullName
});
var representatives = _context.RepresentativeSet.Select(x => new InstitutionContractSelectListViewModel()
{

View File

@@ -7,11 +7,14 @@ using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.InfraStructure;
using AccountMangement.Infrastructure.EFCore;
using Company.Domain.CheckoutAgg;
using Company.Domain.EmployeeAgg;
using Company.Domain.EmployeeChildrenAgg;
using Company.Domain.EmployeeInsurancListDataAgg;
using Company.Domain.empolyerAgg;
using Company.Domain.InsuranceListAgg;
using Company.Domain.InsuranceWorkshopAgg;
using Company.Domain.InsuranceYearlySalaryAgg;
@@ -132,6 +135,11 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var id = insuranceListObj.id;
if (command.EmployeeInsurancListDataList != null && command.EmployeeInsurancListDataList.Count > 0)
{
var farisMonthName = Tools.ToFarsiMonthByNumber(command.Month);
var checkouts = _context.CheckoutSet.Where(x =>
x.WorkshopId == command.WorkshopId && x.Year == command.Year && x.Month == farisMonthName &&
x.IsActiveString == "true");
foreach (var item in command.EmployeeInsurancListDataList)
{
if (item.EmployeeInsurancListDataId == 0)
@@ -158,6 +166,29 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
item.LeftWorkDate, item.JobId, item.IncludeStatus, item.BaseYears,
item.MarriedAllowance, item.OverTimePay, item.FamilyAllowance);
}
if (checkouts.Any())
{
var checkout = checkouts.FirstOrDefault(x => x.EmployeeId == item.EmployeeId);
if (checkout != null)
{
if (item.InsuranceShare.ToMoney() != checkout.InsuranceDeduction.ToMoney())
{
checkout.SetUpdateNeeded();
if (!_context.CheckoutWarningMessages.Any(x => x.CheckoutId == checkout.id && x.TypeOfCheckoutWarning != TypeOfCheckoutWarning.InsuranceEmployeeShare))
{
var createWarrning =
new CheckoutWarningMessage(
"مبلغ بیمه سهم کارگر با مبلغ محاسبه شده در لیست بیمه مغایرت دارد", checkout.id, TypeOfCheckoutWarning.InsuranceEmployeeShare);
_context.CheckoutWarningMessages.Add(createWarrning);
}
_context.SaveChanges();
}
}
}
}
_employeeInsurancListDataRepository.SaveChanges();
@@ -698,6 +729,11 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
var id = insuranceListObj.id;
if (command.EmployeeInsurancListDataList != null && command.EmployeeInsurancListDataList.Count > 0)
{
var farisMonthName = Tools.ToFarsiMonthByNumber(command.Month);
var checkouts = _context.CheckoutSet.Where(x =>
x.WorkshopId == command.WorkshopId && x.Year == command.Year && x.Month == farisMonthName &&
x.IsActiveString == "true");
foreach (var item in command.EmployeeInsurancListDataList)
{
var employeeInsurancListData = new EmployeeInsurancListData(id,
@@ -711,6 +747,28 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
item.LeftWorkDate, item.JobId, item.IncludeStatus, item.BaseYears, item.MarriedAllowance,
item.OverTimePay, item.FamilyAllowance);
_employeeInsurancListDataRepository.Create(employeeInsurancListData);
if (checkouts.Any())
{
var checkout = checkouts.FirstOrDefault(x => x.EmployeeId == item.EmployeeId);
if (checkout != null)
{
if (item.InsuranceShare.ToMoney() != checkout.InsuranceDeduction.ToMoney())
{
checkout.SetUpdateNeeded();
if (!_context.CheckoutWarningMessages.Any(x => x.CheckoutId == checkout.id && x.TypeOfCheckoutWarning != TypeOfCheckoutWarning.InsuranceEmployeeShare))
{
var createWarrning =
new CheckoutWarningMessage(
"مبلغ بیمه سهم کارگر با مبلغ محاسبه شده در لیست بیمه مغایرت دارد", checkout.id, TypeOfCheckoutWarning.InsuranceEmployeeShare);
_context.CheckoutWarningMessages.Add(createWarrning);
}
_context.SaveChanges();
}
}
}
}
_employeeInsurancListDataRepository.SaveChanges();
@@ -1411,6 +1469,27 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
}
public List<EmployeeInsurancListDataViewModel> EmployeeInsuranceDataBy(DateTime startDate, long workshopId)
{
var res = _context.InsuranceListSet
.Where(x => x.StartDate <= startDate && x.EndDate >= startDate &&
x.WorkshopId == workshopId)
.Join(_context.EmployeeInsurancListDataSet,
insuranceList => insuranceList.id,
employeeInsurancListData => employeeInsurancListData.InsuranceListId,
(insuranceList, employeeInsurancListData) => new EmployeeInsurancListDataViewModel
{
InsuranceListId = insuranceList.id,
EmployeeId = employeeInsurancListData.EmployeeId,
WorkingDays = employeeInsurancListData.WorkingDays,
BenefitsIncludedNonContinuous = employeeInsurancListData.BenefitsIncludedNonContinuous,
InsuranceShare = employeeInsurancListData.InsuranceShare,
});
return res.ToList();
}
public List<EmployeeDetailsForInsuranceListViewModel> GetEmployeeInsuranceDataForEdit(long insuranceListId,
DateTime startDate, DateTime endDate)
{

View File

@@ -97,7 +97,7 @@ public class LoanRepository : RepositoryBase<long, Loan>, ILoanRepository
query = query.Where(x => x.StartInstallmentPayment >= startDate && x.StartInstallmentPayment <= endDate);
}
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
var list = query.ToList().Select(x => new LoanViewModel()
var list = query.OrderByDescending(x=>x.StartInstallmentPayment).ToList().Select(x => new LoanViewModel()
{
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,7 @@ using _0_Framework.InfraStructure;
using Company.Domain.RewardAgg;
using CompanyManagment.App.Contracts.Reward;
using Microsoft.EntityFrameworkCore;
using SharpCompress.Compressors.Xz;
namespace CompanyManagment.EFCore.Repository;
@@ -119,12 +120,12 @@ public class RewardRepository : RepositoryBase<long, Reward>, IRewardRepository
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
var list = query.ToList().Select(x => new RewardViewModel
var list = query.ToList().OrderByDescending(x=>x.GrantDate).Select(x => new RewardViewModel
{
WorkshopId = x.WorkshopId,
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,
Description = x.Description,
Description = x.Description ?? "",
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
EmployeeId = x.EmployeeId,
GrantDateFa = x.GrantDate.ToFarsi(),

View File

@@ -478,7 +478,8 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
public RollCallEmployee GetBy(long employeeId, long workshopId)
{
return _context.RollCallEmployees.Include(x => x.EmployeesStatus).FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
return _context.RollCallEmployees.Include(x => x.EmployeesStatus)
.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
}
#endregion

View File

@@ -1,30 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Security.AccessControl;
using System.Threading;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Sms;
using Company.Domain.SmsResultAgg;
using CompanyManagment.App.Contracts.SmsResult;
using IPE.SmsIrClient;
using IPE.SmsIrClient.Models.Requests;
using IPE.SmsIrClient.Models.Results;
using Microsoft.Extensions.Configuration;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace _0_Framework.Application.Sms;
namespace CompanyManagment.EFCore.Services;
public class SmsService : ISmsService
{
private readonly IConfiguration _configuration;
private readonly ISmsResultRepository _smsResultRepository;
private readonly bool _isDevEnvironment;
private readonly List<string> _testNumbers;
public SmsIr SmsIr { get; set; }
public SmsService(IConfiguration configuration)
public SmsService(IConfiguration configuration, ISmsResultRepository smsResultRepository)
{
_configuration = configuration;
_smsResultRepository = smsResultRepository;
SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
// خواندن تنظیمات SMS از appsettings
var smsSettings = _configuration.GetSection("SmsSettings");
_isDevEnvironment = smsSettings.GetValue<bool>("IsTestMode");
_testNumbers = smsSettings.GetSection("TestNumbers").Get<List<string>>() ?? new List<string>();
}
/// <summary>
/// متد مرکزی برای ارسال پیامک که محیط dev را چک می‌کند
/// </summary>
private async Task<SmsIrResult<VerifySendResult>> VerifySendSmsAsync(string number, int templateId, VerifySendParameter[] parameters)
{
// اگر محیط dev است و شماره‌های تست وجود دارد، به شماره‌های تست ارسال می‌شود
if (_isDevEnvironment && _testNumbers is { Count: > 0 })
{
// ارسال به همه شماره‌های تست
SmsIrResult<VerifySendResult> lastResult = null;
foreach (var testNumber in _testNumbers)
{
lastResult = await SmsIr.VerifySendAsync(testNumber, templateId, parameters);
}
return lastResult; // برگرداندن نتیجه آخرین ارسال
}
else
{
// ارسال به شماره واقعی
return await SmsIr.VerifySendAsync(number, templateId, parameters);
}
}
public void Send(string number, string message)
@@ -54,12 +85,7 @@ public class SmsService : ISmsService
}
public bool VerifySend(string number, string message)
{
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
//var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" });
var verificationSendResult = smsIr.VerifySendAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", message) });
var verificationSendResult = VerifySendSmsAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", message) });
Thread.Sleep(2000);
if (verificationSendResult.IsCompletedSuccessfully)
{
@@ -88,11 +114,7 @@ public class SmsService : ISmsService
public bool LoginSend(string number, string message)
{
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
//var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" });
var verificationSendResult = smsIr.VerifySendAsync(number, 635330, new VerifySendParameter[] { new VerifySendParameter("LOGINCODE", message) });
var verificationSendResult = VerifySendSmsAsync(number, 635330, new VerifySendParameter[] { new VerifySendParameter("LOGINCODE", message) });
Thread.Sleep(2000);
if (verificationSendResult.IsCompletedSuccessfully)
{
@@ -117,11 +139,8 @@ public class SmsService : ISmsService
public async Task<SentSmsViewModel> SendVerifyCodeToClient(string number, string code)
{
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
var result = new SentSmsViewModel();
//var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" });
var sendResult = await smsIr.VerifySendAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", code) });
var sendResult = await VerifySendSmsAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", code) });
Thread.Sleep(2000);
if (sendResult.Message == "موفق")
@@ -146,9 +165,8 @@ public class SmsService : ISmsService
var checkLength = fullName.Length;
if (checkLength > 25)
fullName = fullName.Substring(0, 24);
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
var sendResult = smsIr.VerifySendAsync(number, 725814, new VerifySendParameter[] { new VerifySendParameter("FULLNAME", fullName), new VerifySendParameter("USERNAME", userName), new VerifySendParameter("PASSWORD", userName) });
var sendResult = VerifySendSmsAsync(number, 725814, new VerifySendParameter[] { new VerifySendParameter("FULLNAME", fullName), new VerifySendParameter("USERNAME", userName), new VerifySendParameter("PASSWORD", userName) });
Console.WriteLine(userName + " - " + sendResult.Result.Status);
@@ -330,26 +348,57 @@ public class SmsService : ISmsService
}
}
public async Task<bool> SendInstitutionVerificationLink(string number,string fullName, Guid institutionId)
public async Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId)
{
var guidStr=institutionId.ToString();
var firstPart = guidStr.Substring(0, 15);
var secondPart = guidStr.Substring(15);
var verificationSendResult =await SmsIr.VerifySendAsync(number, 527519, new VerifySendParameter[]
var verificationSendResult =await VerifySendSmsAsync(number, 527519, new VerifySendParameter[]
{
new("FULLNAME", fullName),
new("CODE1",firstPart),
new("CODE2",secondPart)
});
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ایجاد قرارداد مالی",
fullName, number, contractingPartyId, institutionContractId);
await _smsResultRepository.CreateAsync(smsResult);
await _smsResultRepository.SaveChangesAsync();
return verificationSendResult.Status == 0;
}
public async Task<bool> SendInstitutionVerificationCode(string number, string code)
public async Task<bool> SendInstitutionAmendmentVerificationLink(string number, string fullName, Guid institutionId,
long contractingPartyId, long institutionContractId)
{
var verificationSendResult =await SmsIr.VerifySendAsync(number, 965348, new VerifySendParameter[]
var guidStr=institutionId.ToString();
var firstPart = guidStr.Substring(0, 15);
var secondPart = guidStr.Substring(15);
var verificationSendResult =await VerifySendSmsAsync(number, 527519, new VerifySendParameter[]
{
new("FULLNAME", fullName),
new("CODE1",firstPart),
new("CODE2",secondPart)
});
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ارتقا قرارداد مالی",
fullName, number, contractingPartyId, institutionContractId);
await _smsResultRepository.CreateAsync(smsResult);
await _smsResultRepository.SaveChangesAsync();
return verificationSendResult.Status == 0;
}
public async Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
long contractingPartyId, long institutionContractId)
{
var verificationSendResult =await VerifySendSmsAsync(number, 965348, new VerifySendParameter[]
{
new("VERIFYCODE", code)
});
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "کد تاییدیه قرارداد مالی",
contractingPartyFullName, number, contractingPartyId, institutionContractId);
await _smsResultRepository.CreateAsync(smsResult);
await _smsResultRepository.SaveChangesAsync();
return verificationSendResult.Status == 0;
}

View File

@@ -214,17 +214,22 @@ using Company.Domain.AuthorizedBankDetailsAgg;
using Company.Domain.ContractingPartyBankAccountsAgg;
using Company.Domain.PaymentInstrumentAgg;
using Company.Domain.PaymentTransactionAgg;
using Company.Domain.FinancialInvoiceAgg;
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
using CompanyManagment.App.Contracts.ContractingPartyBankAccounts;
using CompanyManagment.App.Contracts.PaymentInstrument;
using CompanyManagment.App.Contracts.PaymentTransaction;
using CompanyManagment.App.Contracts.AuthorizedPerson;
using Company.Domain.AuthorizedPersonAgg;
using Company.Domain.EmployeeFaceEmbeddingAgg;
using Company.Domain.InstitutionContractExtensionTempAgg;
using Company.Domain.LawAgg;
using CompanyManagement.Infrastructure.Mongo.EmployeeFaceEmbeddingRepo;
using CompanyManagement.Infrastructure.Mongo.InstitutionContractInsertTempRepo;
using CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
using CompanyManagment.App.Contracts.Law;
using CompanyManagment.EFCore.Repository;
using CompanyManagment.App.Contracts.FinancialInvoice;
namespace PersonalContractingParty.Config;
@@ -478,7 +483,14 @@ public class PersonalBootstrapper
services.AddTransient<IAuthorizedBankDetailsApplication, AuthorizedBankDetailsApplication>();
services
.AddTransient<IInstitutionContractExtenstionTempRepository, InstitutionContractExtenstionTempRepository>();
.AddTransient<IInstitutionContractExtenstionTempRepository, InstitutionContractExtenstionTempRepository>();
services.AddTransient<IEmployeeFaceEmbeddingRepository, EmployeeFaceEmbeddingRepository>();
services.AddTransient<IEmployeeFaceEmbeddingApplication, EmployeeFaceEmbeddingApplication>();
services.AddTransient<IFinancialInvoiceRepository, FinancialInvoiceRepository>();
services.AddTransient<IFinancialInvoiceApplication, FinancialInvoiceApplication>();
#endregion
#region Pooya

View File

@@ -9,20 +9,20 @@ using WorkFlow.Application.Contracts.WorkFlow;
namespace Query.AdminReports.Handlers
{
public interface IGetWorkshopWithRollCallHandler
{
List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters);
}
public interface IGetWorkshopWithRollCallHandler
{
List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters);
}
public class GetWorkshopWithRollCallHandler: IGetWorkshopWithRollCallHandler
{
public class GetWorkshopWithRollCallHandler : IGetWorkshopWithRollCallHandler
{
private readonly CompanyContext _companyContext;
private readonly IWorkFlowApplication workFlowApplication;
public GetWorkshopWithRollCallHandler(CompanyContext companyContext, IWorkFlowApplication workFlowApplication)
{
_companyContext = companyContext;
this.workFlowApplication = workFlowApplication;
_companyContext = companyContext;
this.workFlowApplication = workFlowApplication;
}
public List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters)
@@ -30,7 +30,6 @@ namespace Query.AdminReports.Handlers
var now = DateTime.Now.Date;
var lastWeek = now.AddDays(-7);
//workshop filter by parameters
var rollCallServiceQuery = _companyContext.RollCallServices.AsSplitQuery();
@@ -46,35 +45,49 @@ namespace Query.AdminReports.Handlers
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.ServiceType == parameters.RollCallServiceType);
if (parameters.FilterMode == FilterMode.Active)
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.StartService.Date <= now && x.EndService.Date >= now);
else if (parameters.FilterMode == FilterMode.DeActive)
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.EndService.Date < now || x.StartService.Date > now);
rollCallServiceQuery =
rollCallServiceQuery.Where(x => x.StartService.Date <= now && x.EndService.Date >= now);
var workshopsWithService = rollCallServiceQuery.Join(allWorkshops, x => x.WorkshopId, y => y.id, (rcs, workshop) =>
new WorkshopWithRollCallServiceQueryModel()
{
WorkshopId = workshop.id,
RollCallServiceType = rcs.ServiceType,
WorkshopName = workshop.WorkshopFullName,
MaxPersonValid = rcs.MaxPersonValid,
IsActive = rcs.StartService <= DateTime.Now && rcs.EndService >= DateTime.Now,
ServiceStart = rcs.StartService,
ServiceEnd = rcs.EndService
});
else if (parameters.FilterMode == FilterMode.DeActive)
rollCallServiceQuery =
rollCallServiceQuery.Where(x => x.EndService.Date < now || x.StartService.Date > now);
var workshopsWithService = rollCallServiceQuery.Join(allWorkshops, x => x.WorkshopId, y => y.id,
(rcs, workshop) =>
new WorkshopWithRollCallServiceQueryModel()
{
WorkshopId = workshop.id,
RollCallServiceType = rcs.ServiceType,
WorkshopName = workshop.WorkshopFullName,
MaxPersonValid = rcs.MaxPersonValid,
IsActive = rcs.StartService <= DateTime.Now && rcs.EndService >= DateTime.Now,
ServiceStart = rcs.StartService,
ServiceEnd = rcs.EndService
});
//workshop population
var workshopLeftWorks = _companyContext.Workshops.AsSplitQuery().Where(x => workshopsWithService.Any(y => y.WorkshopId == x.id)).Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
.Select(x => new
{
WorkshopId = x.id,
LeftWorks = x.LeftWorks.Where(y => y.StartWorkDate <= lastWeek && y.LeftWorkDate > now).Select(y => y.EmployeeId),
LeftWorkInsurances = x.LeftWorkInsurances.Where(y => y.StartWorkDate <= lastWeek && (y.LeftWorkDate > now || y.LeftWorkDate == null)).Select(y => y.EmployeeId)
}).ToList();
var workshopLeftWorks = _companyContext.Workshops.AsSplitQuery()
.Where(x => workshopsWithService.Any(y => y.WorkshopId == x.id)).Include(x => x.LeftWorks)
.Include(x => x.LeftWorkInsurances)
.Select(x => new
{
WorkshopId = x.id,
LeftWorks = x.LeftWorks.Where(y => y.StartWorkDate <= lastWeek && y.LeftWorkDate > now)
.Select(y => y.EmployeeId),
LeftWorkInsurances = x.LeftWorkInsurances
.Where(y => y.StartWorkDate <= lastWeek && (y.LeftWorkDate > now || y.LeftWorkDate == null))
.Select(y => y.EmployeeId)
}).ToList();
var workshopsWorkingEmployeesList = workshopLeftWorks
.Select(x => new { x.WorkshopId, TotalWorkingEmployeesCount = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct().Count(), EmployeeIds = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct() }).ToList();
.Select(x =>
new
{
x.WorkshopId,
TotalWorkingEmployeesCount = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct().Count(),
EmployeeIds = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct()
}).ToList();
var activeEmployees = _companyContext.RollCallEmployees.AsSplitQuery()
@@ -83,15 +96,25 @@ namespace Query.AdminReports.Handlers
workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId))
.Select(x => new { x.WorkshopId, x.EmployeeId });
var lastWeekRollCalls = _companyContext.RollCalls.AsSplitQuery().Where(x => x.StartDate.HasValue && x.StartDate.Value >= lastWeek
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).GroupBy(x => x.EmployeeId).Select(x => x.Key);
var lastWeekRollCalls = _companyContext.RollCalls.AsSplitQuery()
.Where(x => x.StartDate.HasValue &&
x.StartDate.Value >= lastWeek
&& workshopsWithService
.Any(y => y.WorkshopId == x.WorkshopId))
.GroupBy(x => x.EmployeeId)
.Select(x => x.Key);
var leaves = _companyContext.LeaveList.AsSplitQuery().Where(x => x.StartLeave <= lastWeek && x.EndLeave >= now && (x.LeaveType == "استعلاجی" || x.PaidLeaveType == "روزانه")
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => x.EmployeeId);
var leaves = _companyContext.LeaveList.AsSplitQuery().Where(x =>
x.StartLeave <= lastWeek && x.EndLeave >= now &&
(x.LeaveType == "استعلاجی" || x.PaidLeaveType == "روزانه")
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId))
.Select(x => x.EmployeeId);
var activeEmployeesList = activeEmployees.ToList().Where(x => workshopsWorkingEmployeesList.Any(w => w.WorkshopId == x.WorkshopId && w.EmployeeIds.Contains(x.EmployeeId)));
var activeEmployeesList = activeEmployees.ToList().Where(x =>
workshopsWorkingEmployeesList.Any(w =>
w.WorkshopId == x.WorkshopId && w.EmployeeIds.Contains(x.EmployeeId)));
var lastWeekRollCallsList = lastWeekRollCalls.ToList();
var leavesList = leaves.ToList();
var workshopsWithServiceList = workshopsWithService.ToList();
@@ -107,12 +130,13 @@ namespace Query.AdminReports.Handlers
MaxPersonValid = x.MaxPersonValid,
WorkshopName = x.WorkshopName,
ActiveEmployeesCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId),
ActiveEmployeesWithRollCallInLastWeekCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId &&
ActiveEmployeesWithRollCallInLastWeekCount = activeEmployeesList.Count(y =>
y.WorkshopId == x.WorkshopId &&
lastWeekRollCallsList.Contains(y.EmployeeId) && !leavesList.Contains(y.EmployeeId)),
TotalEmployeesCount = workshopsWorkingEmployeesList.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.TotalWorkingEmployeesCount ?? 0,
TotalEmployeesCount = workshopsWorkingEmployeesList
.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.TotalWorkingEmployeesCount ?? 0,
//UndoneWorkFlowsCount = workFlowApplication.GetAllWorkFlowCount(x.WorkshopId).Result
}).OrderByDescending(x => x.IsActive).ToList();
}
}
}
}

View File

@@ -13,15 +13,8 @@
public int ActiveEmployeesWithRollCallInLastWeekCount { get; set; }
public int UndoneWorkFlowsCount { get; set; }
public float ActiveEmployeesWithRollCallPercentage
{
get
{
return ((float)ActiveEmployeesWithRollCallInLastWeekCount / ActiveEmployeesCount) * 100;
}
}
public float ActiveEmployeesWithRollCallPercentage => ActiveEmployeesCount == 0 ? 0f : ((float)ActiveEmployeesWithRollCallInLastWeekCount / ActiveEmployeesCount) * 100f;
public int MaxPersonValid { get; set; }
public bool IsActive { get; set; }

View File

@@ -0,0 +1,49 @@
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account;
using Microsoft.AspNetCore.Mvc;
using Query.AdminReports.Handlers;
using Query.AdminReports.Models;
using ServiceHost.BaseControllers;
using WorkFlow.Application.Contracts.WorkFlow;
namespace ServiceHost.Areas.Admin.Controllers;
public class RollCallController:AdminBaseController
{
private readonly IGetWorkshopWithRollCallHandler _workshopWithRollCallHandler;
private readonly IWorkFlowApplication _workFlowApplication;
private readonly long _currentAccountId;
public RollCallController(IGetWorkshopWithRollCallHandler workshopWithRollCallHandler,IAuthHelper _authHelper, IWorkFlowApplication workFlowApplication)
{
_workshopWithRollCallHandler = workshopWithRollCallHandler;
_workFlowApplication = workFlowApplication;
_currentAccountId = _authHelper.CurrentAccountId();
}
[HttpGet("report")]
public ActionResult<List<WorkshopWithRollCallServiceQueryModel>> GetRollCallReport([FromQuery] WorkshopWithRollCallServiceQueryParameters searchModel)
{
var result = _workshopWithRollCallHandler.Handle(searchModel);
return result;
}
[HttpGet("report/workshops-select-list")]
public ActionResult<List<WorkshopSelectList>> GetWorkshopsSelectList()
{
var result = _workshopWithRollCallHandler.Handle(new WorkshopWithRollCallServiceQueryParameters())
.Select(x => new WorkshopSelectList
{
Id = x.WorkshopId,
WorkshopFullName = x.WorkshopName
}).Distinct().ToList();
return result;
}
[HttpGet("repoert/workfloecount/{workshopId}")]
public async Task<ActionResult<int>> GetWorkFlowCountByWorkshopId(long workshopId)
{
var result = await _workFlowApplication.GetAllWorkFlowCount(workshopId, _currentAccountId);
return result;
}
}

View File

@@ -2,6 +2,7 @@ using System.Collections.Concurrent;
using System.Transactions;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Application.PaymentGateway;
using _0_Framework.Application.Sms;
using _0_Framework.Exceptions;
using AccountManagement.Application.Contracts.Account;
@@ -37,6 +38,8 @@ public class institutionContractController : AdminBaseController
private readonly IWorkshopApplication _workshopApplication;
private readonly ITemporaryClientRegistrationApplication _temporaryClientRegistration;
private readonly ITemporaryClientRegistrationApplication _clientRegistrationApplication;
private readonly IPaymentGateway _paymentGateway;
private static readonly ConcurrentDictionary<Guid, SemaphoreSlim> _locks
= new ConcurrentDictionary<Guid, SemaphoreSlim>();
@@ -45,7 +48,8 @@ public class institutionContractController : AdminBaseController
public institutionContractController(IInstitutionContractApplication institutionContractApplication,
IPersonalContractingPartyApp contractingPartyApplication, IContactInfoApplication contactInfoApplication,
IAccountApplication accountApplication, IEmployerApplication employerApplication,
IWorkshopApplication workshopApplication, ITemporaryClientRegistrationApplication temporaryClientRegistration, ITemporaryClientRegistrationApplication clientRegistrationApplication)
IWorkshopApplication workshopApplication, ITemporaryClientRegistrationApplication temporaryClientRegistration,
ITemporaryClientRegistrationApplication clientRegistrationApplication,IHttpClientFactory httpClientFactory)
{
_institutionContractApplication = institutionContractApplication;
_contractingPartyApplication = contractingPartyApplication;
@@ -55,6 +59,7 @@ public class institutionContractController : AdminBaseController
_workshopApplication = workshopApplication;
_temporaryClientRegistration = temporaryClientRegistration;
_clientRegistrationApplication = clientRegistrationApplication;
_paymentGateway = new SepehrPaymentGateway(httpClientFactory);
}
/// <summary>
@@ -462,11 +467,37 @@ public class institutionContractController : AdminBaseController
[HttpPost("/api/institutionContract/Verify")]
[AllowAnonymous]
public async Task<ActionResult<OperationResult>> Verify([FromBody] InstitutionVerificationRequest command)
public async Task<ActionResult<OperationResult<string>>> Verify([FromBody] InstitutionVerificationRequest command)
{
var res = await _institutionContractApplication.VerifyOtp(command.Id, command.Code);
return res;
// URL برای redirect به درگاه پرداخت
var paymentRedirectUrl = Url.Action("ProcessPayment", "institutionContract", new { area = "Admin" }, Request.Scheme);
var res = await _institutionContractApplication.VerifyOtpAndMakeGateway(command.Id, command.Code, paymentRedirectUrl);
if (!res.IsSuccedded)
return new OperationResult<string>().Failed(res.Message);
var payUrl = _paymentGateway.GetStartPayUrl(res.Data);
// URL کامل برای redirect شامل paymentUrl به عنوان query parameter
var redirectUrl = $"{paymentRedirectUrl}?paymentUrl={Uri.EscapeDataString(payUrl)}";
return new OperationResult<string>().Succcedded(redirectUrl);
}
[HttpGet("/api/institutionContract/ProcessPayment")]
[AllowAnonymous]
public IActionResult ProcessPayment([FromQuery] string paymentUrl)
{
if (string.IsNullOrEmpty(paymentUrl))
{
return BadRequest("Payment URL is required");
}
// redirect به درگاه پرداخت
return Redirect(paymentUrl);
}
[HttpPost("/api/institutionContract/Verification/{id:guid}/send-otp")]
[AllowAnonymous]

View File

@@ -32,6 +32,12 @@ using ServiceHost.Hubs;
using System.Diagnostics.Contracts;
using WorkFlow.Application.Contracts.WorkFlow;
using System.Globalization;
using Company.Domain.LeftWorkInsuranceAgg;
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
using Company.Domain.InsuranceListAgg;
using CompanyManagment.App.Contracts.InsuranceList;
using CompanyManagment.EFCore.Repository;
using System.Linq;
namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts;
@@ -59,6 +65,9 @@ public class IndexModel : PageModel
private readonly IYearlySalaryApplication _yearlySalaryApplication;
private readonly IYearlySalaryRepository _yearlySalaryRepository;
private readonly IWorkFlowApplication _workFlowApplication;
private readonly ILeftWorkInsuranceRepository _leftWorkInsuranceRepository;
private readonly IInsuranceListApplication _insuranceListApplication;
private readonly IInsuranceListRepository _insuranceListRepository;
public List<CheckoutViewModel> chekoutlist;
@@ -100,7 +109,7 @@ public class IndexModel : PageModel
ILeaveApplication leaveApplication, IHubContext<CheckoutHub> hubContext,
IEmployeeComputeOptionsApplication employeeComputeOptionsApplication,
IRollCallMandatoryApplication rollCallMandatoryApplication,
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApp, IWorkFlowApplication workFlowApplication)
IRollCallEmployeeStatusApplication rollCallEmployeeStatusApp, IWorkFlowApplication workFlowApplication, ILeftWorkInsuranceRepository leftWorkInsuranceRepository, IInsuranceListApplication insuranceListApplication, IInsuranceListRepository insuranceListRepository)
{
_contractApplication = contractApplication;
_workshopApplication = workshopApplication;
@@ -124,6 +133,9 @@ public class IndexModel : PageModel
_rollCallMandatoryApplication = rollCallMandatoryApplication;
_rollCallEmployeeStatusApp = rollCallEmployeeStatusApp;
_workFlowApplication = workFlowApplication;
_leftWorkInsuranceRepository = leftWorkInsuranceRepository;
_insuranceListApplication = insuranceListApplication;
_insuranceListRepository = insuranceListRepository;
}
public string Message { get; set; }
@@ -165,7 +177,7 @@ public class IndexModel : PageModel
var searchResult = await _checkoutApplication.SearchCheckoutOptimized(searchModel);
var result = new MainViewModel();
var result = new CompanyManagment.App.Contracts.Checkout.MainViewModel();
result.IsSysManager = accountId is 2 or 3;
result.MainList = searchResult;
if (searchModel.WorkshopId != 0 || searchModel.EmployeeId != 0)
@@ -759,11 +771,36 @@ public class IndexModel : PageModel
var maxNumber = Convert.ToDouble(ContractsId.Count());
if (ContractsId.Count > 0)
{
#region Insurance
var watch = new Stopwatch();
watch.Start();
var contractpData = _contractApplication.GetDetails(ContractsId[0]);
var startMonthFa = $"{ConvertYear}/{ConvertMonth.PadLeft(2, '0')}/01";
DateTime startDateGr = startMonthFa.ToGeorgianDateTime();
DateTime endDateGr = startMonthFa.FindeEndOfMonth().ToGeorgianDateTime();
int endOfMonth = Convert.ToInt32((startMonthFa.FindeEndOfMonth()).Substring(8, 2));
var insuranceListData =
_insuranceListRepository.EmployeeInsuranceDataBy(startDateGr, contractpData.WorkshopIds);
var yearlysaleries = _yearlySalaryApplication.GetInsuranceItems(startDateGr, endDateGr, ConvertYear);
var insuranceEmployeeData =
_leftWorkInsuranceRepository.GetEmployeeInsuranceLeftWorksAndInformation(contractpData.WorkshopIds, startDateGr,
endDateGr);
Console.WriteLine("checkout-test-timer" + watch.Elapsed);
watch.Stop();
#endregion
//int i = 0;
foreach (var item in ContractsId)
{
var contract = _contractApplication.GetDetails(item);
//var workingHours = _workingHoursApplication.GetByContractId(contract.Id);
var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(contract.Id);
var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth,
@@ -992,7 +1029,78 @@ public class IndexModel : PageModel
officialHoliday, totalHoursH, totalHoursM, consumableItemDouble, housingAllowanceDouble,
familyAllowanceDouble, marriedAllowanceDouble, workshop.IsOldContract);
#region Insurance
double insuranceShare = 0;
//اگر پرسنل داری شروع بکار بیمه بود
var insuranceEmployeeDataItem =
insuranceEmployeeData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
//اگر لیست بیمه برای پرسنل ساخته شده بود
var insuranceListDataWithDetails =
insuranceListData.FirstOrDefault(x => x.EmployeeId == contract.EmployeeId);
if (insuranceListDataWithDetails != null)
{
insuranceShare = insuranceListDataWithDetails.InsuranceShare;
}
else
{
if (insuranceEmployeeDataItem != null && insuranceEmployeeDataItem.StartWorkDateGr <= separation.ContractEndGr)
{
var workingDays = Tools.GetEmployeeInsuranceWorkingDays(insuranceEmployeeDataItem.StartWorkDateGr, separation.LeftWorkDate, startDateGr, endDateGr, insuranceEmployeeDataItem.EmployeeId);
var leftWorkFa = workingDays.hasLeftWorkInMonth ? separation.LeftWorkDate.ToFarsi() : "";
//به دست آوردن دستمزد روزانه با توجه به اینکه کارگاه مشاغل مقطوع است یا خیر
double dailyWage = 0;
if (workshop.FixedSalary)
{
var res = _insuranceListApplication.GetDailyWageFixedSalary(ConvertYear, workshop.Id, insuranceEmployeeDataItem.EmployeeId, startDateGr,
endDateGr, insuranceEmployeeDataItem.JobId, workshop.Population, workshop.InsuranceJobId);
dailyWage = res ?? 0;
}
else
{
var res = _insuranceListApplication.ComputeDailyWage(yearlysaleries.DayliWage, insuranceEmployeeDataItem.EmployeeId, workshop.Id, ConvertYear);
dailyWage = res;
}
//بدست آوردن پایه سنوات
var baseYears = _insuranceListRepository.GetEmployeeInsuranceBaseYear(insuranceEmployeeDataItem.EmployeeId, workshop.Id,
workingDays.countWorkingDays, startDateGr, endDateGr, workingDays.startWork, workingDays.endWork, workingDays.hasLeftWorkInMonth);
//جمع مزد روزانه و پایه سنوات
var dailyWagePlusBaseYears = dailyWage + baseYears.baseYear;
//دستمزد ماهانه با محاسبه پایه سنوات
var monthlySalary = _insuranceListApplication.GetRoundValue(dailyWagePlusBaseYears * workingDays.countWorkingDays);
//حق تاهل
var marriedAllowance = employee.MaritalStatus == "متاهل" ? yearlysaleries.MarriedAllowance : 0;
//محاسبه مزایای ماهانه
var monthlyBenefits = _insuranceListApplication.GetMonthlyBenefits(endOfMonth, yearlysaleries.ConsumableItems, yearlysaleries.HousingAllowance, marriedAllowance, workingDays.countWorkingDays, workshop.TypeOfInsuranceSend, insuranceEmployeeDataItem.JobId, insuranceEmployeeDataItem.EmployeeId, insuranceEmployeeDataItem.IncludeStatus);
if (workshop.InsuranceCheckoutOvertime)
{
monthlyBenefits = _insuranceListApplication.GetRoundValue(monthlyBenefits += overTimeWorking);
}
//محاسبه جمع مزایای مشمول و دستمزد ماهانه
var benefitsIncludedContinuous = monthlyBenefits + monthlySalary;
//محاسبه حق بیمه سهم بیمه شده
insuranceShare = (benefitsIncludedContinuous * 7) / 100;
}
}
#endregion
var command = new CreateCheckout
{
EmployeeFullName = employee.EmployeeFullName,
@@ -1098,7 +1206,11 @@ public class IndexModel : PageModel
DailySalaryAffected = mandatoryCompute.DailySalaryAffected,
#region InsuranceShare
InsuranceDeduction = _insuranceListApplication.GetRoundValue(insuranceShare),
#endregion

View File

@@ -2,8 +2,135 @@
@{
<style>
.btn-lime {
background-color: #84cc16;
border: 1px solid #84cc16;
background-color: #84cc16;
border: 1px solid #84cc16;
}
.fulltext {
opacity: 0;
white-space: nowrap;
}
.ellipsed {
display: block;
width: 100%;
text-overflow: ellipsis;
overflow-x: clip;
white-space: nowrap;
}
.date-box {
display: flex;
align-items: center;
}
.tooltipfull-containerText {
cursor: pointer;
position: absolute;
display: inline-block;
right: -2px;
top: 13px;
}
.tooltip {
opacity: 0;
z-index: 99;
color: #fff;
width: 220px;
display: block;
font-size: 14px;
font-family: 'IranSans';
padding: 5px 10px;
border-radius: 3px;
text-align: center;
/*text-shadow: 1px 1px 2px #111;*/
background: #e67e22;
border: 1px solid #e67e22;
box-shadow: 0 0 3px rgba(0,0,0,0.5);
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
position: absolute;
right: -50px;
bottom: 40px;
}
.tooltip:before, .tooltip:after {
content: '';
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #e67e22;
position: absolute;
bottom: -10px;
left: 70%;
}
.tooltip-container:hover .tooltip, a:hover .tooltip {
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.tooltipfull {
opacity: 0;
z-index: 99;
color: #fff;
/* width: 180px;*/
display: block;
font-size: 12px;
font-family: 'IranSans';
padding: 5px 10px;
border-radius: 15px;
text-align: center;
/*text-shadow: 1px 1px 2px #111;*/
background: #950000;
border: 1px solid #950000;
box-shadow: 0 0 3px rgba(0,0,0,0.5);
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
/* -ms-transition: all .2s ease-in-out;*/
transition: all .2s ease-in-out;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
position: absolute;
right: -2px;
bottom: 20px;
white-space: nowrap;
}
.tooltipfull:before, .tooltipfull:after {
content: '';
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #950000;
position: absolute;
bottom: -10px;
left: 50%;
}
.tooltipfull-containerText:hover .tooltipfull, a:hover .tooltipfull {
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
</style>
@@ -102,14 +229,41 @@
<td class="code-td">
<span class="ellipsed">
@item.Month
@{
<span>&nbsp;</span>
if(item.IsUpdateNeeded){
<i style="color: #cb1c1c; font-size:17px !important" class="fa fa-exclamation-triangle" aria-hidden="true"></i>
}
}
</span>
<div class="tooltipfull-containerText">
<p class="fulltext">
@item.Month
</p>
<span class="tooltipfull">
@item.Month
</span>
@{
if (item.IsUpdateNeeded)
{
foreach (var warning in item.CheckoutWarningMessageList)
{
<p class="fulltext">
@warning.WarningMessage
</p>
<span class="tooltipfull" style="right: -103px;bottom: 20px;">
@warning.WarningMessage
</span>
}
}
else
{
<p class="fulltext">
@item.Month
</p>
<span class="tooltipfull">
@item.Month
</span>
}
}
</div>
</td>
<td class="name-td">

View File

@@ -287,7 +287,7 @@
<div class="textsChart">
<p class="alltxt">
<span style="width: 40px;display: inline-block;">@Model.ContrcatDone</span> : <span style="width: 62px;display: inline-block;">کل</span>
<span style="width: 40px;display: inline-block;">@Model.ContractSignToBe</span> : <span style="width: 62px;display: inline-block;">کل</span>
</p>
<p class="alldonetxt">
<span style="width: 40px;display: inline-block;">@Model.ContractSignDone</span> : <span style="width: 62px;display: inline-block;color: #283344;">انجام شده</span>
@@ -353,7 +353,7 @@
<div class="textsChart">
<p class="alltxt">
<span style="width: 40px;display: inline-block;">@Model.CheckoutDone</span> : <span style="width: 62px;display: inline-block;">کل</span>
<span style="width: 40px;display: inline-block;">@Model.CheckoutSignToBe</span> : <span style="width: 62px;display: inline-block;">کل</span>
</p>
<p class="alldonetxt">
<span style="width: 40px;display: inline-block;">@Model.CheckoutSignDone</span> : <span style="width: 62px;display: inline-block;color: #283344;">انجام شده</span>

View File

@@ -1,4 +1,5 @@
using _0_Framework.Application;
using AccountMangement.Infrastructure.EFCore;
using CompanyManagment.App.Contracts.Report;
using CompanyManagment.App.Contracts.Workshop;
using CompanyManagment.App.Contracts.YearlySalary;
@@ -42,6 +43,7 @@ public class IndexModel : PageModel
public int ContrcatDone { get; set; }
public int ContractSignNotDone { get; set; }
public int ContractSignDone { get; set; }
public int ContractSignToBe { get; set; }
//تصفیه
public int AllCheckout { get; set; }
@@ -49,8 +51,9 @@ public class IndexModel : PageModel
public int CheckoutDone { get; set; }
public int CheckoutSignNotDone { get; set; }
public int CheckoutSignDone { get; set; }
public int CheckoutSignToBe { get; set; }
public async Task OnGet(string year, string month)
public async Task OnGet(string year, string month)
{
YearlyList = _yearlySalaryApplication.GetYears();
var allReports = await _reportApplication.GetAllReports(year, month);
@@ -73,19 +76,23 @@ public class IndexModel : PageModel
ContrcatDone = allReports.ContrcatDone;
ContractSignNotDone = allReports.ContractSignNotDone;
ContractSignDone = allReports.ContractSignDone;
AllCheckout = allReports.AllCheckout;
ContractSignToBe = allReports.ContractSignToBe;
AllCheckout = allReports.AllCheckout;
CheckoutNotDone = allReports.CheckoutNotDone;
CheckoutDone = allReports.CheckoutDone;
CheckoutSignNotDone = allReports.CheckoutSignNotDone;
CheckoutSignDone = allReports.CheckoutSignDone;
CheckoutSignToBe = allReports.CheckoutSignToBe;
}
#region workshopFirstLoad
public IActionResult OnGetWorkshopContractDone(string year, string month, long accountId, List<long> workshopList)
{
var res = _reportApplication.GetWorkshopContractDone(year, month, accountId, workshopList);
var res = _reportApplication.GetWorkshopContractDone(year, month, accountId, workshopList).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -96,7 +103,7 @@ public class IndexModel : PageModel
public IActionResult OnGetWorkshopContractSignDone(string year, string month, long accountId, List<long> workshopList)
{
var res = _reportApplication.GetWorkshopContractSignDone(year, month, accountId, workshopList);
var res = _reportApplication.GetWorkshopContractSignDone(year, month, accountId, workshopList).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -107,7 +114,7 @@ public class IndexModel : PageModel
public IActionResult OnGetWorkshopCheckoutDone(string year, string month, long accountId, List<long> workshopList)
{
var res = _reportApplication.GetWorkshopCheckoutDone(year, month, accountId, workshopList);
var res = _reportApplication.GetWorkshopCheckoutDone(year, month, accountId, workshopList).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -118,7 +125,7 @@ public class IndexModel : PageModel
public IActionResult OnGetWorkshopCheckoutSignDone(string year, string month, long accountId, List<long> workshopList)
{
var res = _reportApplication.GetWorkshopCheckoutSignDone(year, month, accountId, workshopList);
var res = _reportApplication.GetWorkshopCheckoutSignDone(year, month, accountId, workshopList).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -133,7 +140,7 @@ public class IndexModel : PageModel
public IActionResult OnGetEmployeeContract(string year, string month, long workshopId)
{
var res = _reportApplication.GetEmployeeContract(year, month, workshopId);
var res = _reportApplication.GetEmployeeContract(year, month, workshopId).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -143,7 +150,7 @@ public class IndexModel : PageModel
public IActionResult OnGetEmployeeContractSign(string year, string month, long workshopId)
{
var res = _reportApplication.GetEmployeeContractSign(year, month, workshopId);
var res = _reportApplication.GetEmployeeContractSign(year, month, workshopId).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -153,7 +160,7 @@ public class IndexModel : PageModel
public IActionResult OnGetEmployeeCheckout(string year, string month, long workshopId)
{
var res = _reportApplication.GetEmployeeCheckout(year, month, workshopId);
var res = _reportApplication.GetEmployeeCheckout(year, month, workshopId).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -163,7 +170,7 @@ public class IndexModel : PageModel
public IActionResult OnGetEmployeeCheckoutSign(string year, string month, long workshopId, long accountId)
{
var res = _reportApplication.GetEmployeeCheckoutSign(year, month, workshopId);
var res = _reportApplication.GetEmployeeCheckoutSign(year, month, workshopId).GetAwaiter().GetResult();
return new JsonResult(new
{
success = true,
@@ -180,14 +187,14 @@ public class IndexModel : PageModel
{
var workshopIds = Tools.ExtractNumbers(workshopList);
var res = _reportApplication.GetPrintAllContractDone(year, month, accountId, workshopIds);
var res = _reportApplication.GetPrintAllContractDone(year, month, accountId, workshopIds).GetAwaiter().GetResult();
return Partial("PrintAll", res);
}
public IActionResult OnGetPrintAllContractSignDone(string year, string month, long accountId, string workshopList)
{
var workshopIds = Tools.ExtractNumbers(workshopList);
var res = _reportApplication.GetPrintAllContractSignDone(year, month, accountId, workshopIds);
var res = _reportApplication.GetPrintAllContractSignDone(year, month, accountId, workshopIds).GetAwaiter().GetResult();
return Partial("PrintAll", res);
}
@@ -195,14 +202,14 @@ public class IndexModel : PageModel
{
var workshopIds = Tools.ExtractNumbers(workshopList);
var res = _reportApplication.GetPrintAllCheckoutDone(year, month, accountId, workshopIds);
var res = _reportApplication.GetPrintAllCheckoutDone(year, month, accountId, workshopIds).GetAwaiter().GetResult();
return Partial("PrintAll", res);
}
public IActionResult OnGetPrintAllCheckoutSignDone(string year, string month, long accountId, string workshopList)
{
var workshopIds = Tools.ExtractNumbers(workshopList);
var res = _reportApplication.GetPrintAllCheckoutSignDone(year, month, accountId, workshopIds);
var res = _reportApplication.GetPrintAllCheckoutSignDone(year, month, accountId, workshopIds).GetAwaiter().GetResult();
return Partial("PrintAll", res);
}
//================Employee
@@ -211,7 +218,7 @@ public class IndexModel : PageModel
public IActionResult OnGetPrintEmployeeContract(string year, string month, long workshopId, string accountFullName)
{
var workshop = _workshopApplication.GetDetails(workshopId);
var res = _reportApplication.GetEmployeeContract(year, month, workshopId);
var res = _reportApplication.GetEmployeeContract(year, month, workshopId).GetAwaiter().GetResult();
var next = $"{year}/{month}/01";
var y = Convert.ToInt32(year);
var m = Convert.ToInt32(month);
@@ -235,7 +242,7 @@ public class IndexModel : PageModel
string accountFullName)
{
var workshop = _workshopApplication.GetDetails(workshopId);
var res = _reportApplication.GetEmployeeContractSign(year, month, workshopId);
var res = _reportApplication.GetEmployeeContractSign(year, month, workshopId).GetAwaiter().GetResult();
var next = $"{year}/{month}/01";
var y = Convert.ToInt32(year);
var m = Convert.ToInt32(month);
@@ -258,7 +265,7 @@ public class IndexModel : PageModel
public IActionResult OnGetPrintEmployeeCheckout(string year, string month, long workshopId, string accountFullName)
{
var workshop = _workshopApplication.GetDetails(workshopId);
var res = _reportApplication.GetEmployeeCheckout(year, month, workshopId);
var res = _reportApplication.GetEmployeeCheckout(year, month, workshopId).GetAwaiter().GetResult();
var final = new PrintEmployeeNotDone
{
@@ -277,7 +284,7 @@ public class IndexModel : PageModel
string accountFullName)
{
var workshop = _workshopApplication.GetDetails(workshopId);
var res = _reportApplication.GetEmployeeCheckoutSign(year, month, workshopId);
var res = _reportApplication.GetEmployeeCheckoutSign(year, month, workshopId).GetAwaiter().GetResult();
var final = new PrintEmployeeNotDone
{

View File

@@ -176,7 +176,7 @@
@* قراردادهای موسسه</a> *@
@* </li> *@
<li permission="308">
<a class="clik3" asp-area="AdminNew" asp-page="/Company/RollCall/Index">
<a class="clik3" href="https://admin@(AppSetting.Value.Domain)/rollcall">
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
</svg>

View File

@@ -18,9 +18,14 @@ using System.Text.Json.Serialization;
using _0_Framework.Application.PaymentGateway;
using Company.Domain.InstitutionContractAgg;
using Company.Domain.InstitutionPlanAgg;
using Company.Domain.PaymentTransactionAgg;
using CompanyManagment.App.Contracts.InstitutionContract;
using CompanyManagment.App.Contracts.PaymentTransaction;
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using Microsoft.Extensions.Options;
using Parbad;
using Parbad.AspNetCore;
using Parbad.Gateway.Sepehr;
using static ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk.IndexModel2;
namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
@@ -34,6 +39,9 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
private readonly AccountContext _accountContext;
private readonly IPaymentGateway _paymentGateway;
private readonly ITemporaryClientRegistrationApplication _clientRegistrationApplication;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IOnlinePayment _onlinePayment;
[BindProperty] public IFormFile File { get; set; }
@@ -41,14 +49,16 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
public IndexModel(IAndroidApkVersionApplication application, IRollCallDomainService rollCallDomainService,
CompanyContext context, AccountContext accountContext, IHttpClientFactory httpClientFactory,
IOptions<AppSettingConfiguration> appSetting,
ITemporaryClientRegistrationApplication clientRegistrationApplication)
ITemporaryClientRegistrationApplication clientRegistrationApplication, IOnlinePayment onlinePayment)
{
_application = application;
_rollCallDomainService = rollCallDomainService;
_context = context;
_accountContext = accountContext;
_httpClientFactory = httpClientFactory;
_clientRegistrationApplication = clientRegistrationApplication;
_paymentGateway = new AqayePardakhtPaymentGateway(httpClientFactory, appSetting);
_onlinePayment = onlinePayment;
_paymentGateway = new SepehrPaymentGateway(httpClientFactory);
}
public void OnGet()
@@ -63,7 +73,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
}
public IActionResult OnPostShiftDate()
public async Task<IActionResult> OnPostShiftDate()
{
//var startRollCall = new DateTime(2025, 2, 19);
//var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall);
@@ -73,10 +83,119 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
//var notEndedRollCalls = rollCalls.Where(x => x.EndDate == null).ToList();
//RefactorAllTheRollCallsOnEsfand(endedRollCalls, notEndedRollCalls);
//CreateRewardForKebabMahdi().GetAwaiter().GetResult();
SetEntityIdForCheckoutValues();
SetEntityIdForCheckoutValuesTemp();
ViewData["message"] = "ایجاد شد";
return Page();
var callBack = Url.Action("Verify", "General", null, Request.Scheme);
var amount = 10000;
var transaction = new PaymentTransaction(30427, amount, "سید حسن مصباح", "https://client.gozareshgir.ir", PaymentTransactionGateWay.SepehrPay);
_context.PaymentTransactions.Add(transaction);
await _context.SaveChangesAsync();
var command = new CreatePaymentGatewayRequest()
{
TransactionId = transaction.id.ToString(),
Amount = amount,
CallBackUrl = callBack
};
var createRes = await _paymentGateway.Create(command);
if (createRes.IsSuccess)
{
transaction.SetTransactionId(createRes.Token);
await _context.SaveChangesAsync();
var payUrl = _paymentGateway.GetStartPayUrl(createRes.Token);
return Redirect(payUrl);
}
else
{
return BadRequest(createRes.Status + "خطا در ارسال به درگاه پرداخت");
}
}
private async System.Threading.Tasks.Task CreateDadmehrWorkshopFaceEmbedding()
{
var basePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "faces");
if (!Directory.Exists(basePath))
{
ViewData["message"] = "مسیر پوشه یافت نشد";
return;
}
var directories = Directory.GetDirectories(basePath);
var client = new HttpClient();
foreach (var mainDirectory in directories)
{
var subDirectories = Directory.GetDirectories(mainDirectory);
var workshopName = Path.GetFileName(mainDirectory);
foreach (var directory in subDirectories)
{
var directoryName = Path.GetFileName(directory);
var employee = await _context.Employees
.FirstOrDefaultAsync(x => x.id == Convert.ToInt64(directoryName));
var fullname = employee != null ? employee.FullName : "نامشخص";
var imageFiles = Directory.GetFiles(directory, "*.*")
.Take(2)
.ToArray();
if (imageFiles.Length < 2)
{
Console.WriteLine($"تعداد تصاویر کافی برای {directoryName} وجود ندارد");
continue;
}
using var formData = new MultipartFormDataContent();
formData.Add(new StringContent(directoryName), "employee_id");
formData.Add(new StringContent(workshopName), "workshop_id");
formData.Add(new StringContent(fullname), "employee_full_name");
FileStream file1Stream = null;
FileStream file2Stream = null;
try
{
// ارسال فایل اول
file1Stream = new FileStream(imageFiles[0], FileMode.Open, FileAccess.Read);
var file1Content = new StreamContent(file1Stream);
file1Content.Headers.ContentType =
new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg");
formData.Add(file1Content, "picture1", Path.GetFileName(imageFiles[0]));
// ارسال فایل دوم
file2Stream = new FileStream(imageFiles[1], FileMode.Open, FileAccess.Read);
var file2Content = new StreamContent(file2Stream);
file2Content.Headers.ContentType =
new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg");
formData.Add(file2Content, "picture2", Path.GetFileName(imageFiles[1]));
var response = await client.PostAsync("http://127.0.0.1:8000/embeddings", formData);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine($"✓ {directoryName}: {result}");
}
else
{
var error = await response.Content.ReadAsStringAsync();
Console.WriteLine($"✗ {directoryName}: {response.StatusCode} - {error}");
}
}
finally
{
file1Stream?.Dispose();
file2Stream?.Dispose();
}
}
}
}
public IActionResult OnPostShiftDateNew()
@@ -121,14 +240,14 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
Amount = 1000,
Email = "mahanch83@gmail.com",
CallBackUrl = Url.Page("/CallBack/Index", null, null, Request.Scheme, Request.Host.Value),
InvoiceId = "{C771E841-B810-413D-9D4C-9F659575B8CC}",
TransactionId = "{C771E841-B810-413D-9D4C-9F659575B8CC}",
};
var createResponse = await _paymentGateway.Create(command, cancellationToken);
if (createResponse.Status == "success")
{
return Redirect(_paymentGateway.GetStartPayUrl(createResponse.TransactionId));
return Redirect(_paymentGateway.GetStartPayUrl(createResponse.Token));
}
//TranslateCode(result?.ErrorCode);
@@ -695,7 +814,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
//TODO: set data for institution price
var workshops = item.contractingParty.Employers
.SelectMany(e => e.WorkshopEmployers.Select(we => we.Workshop)).ToList()
.DistinctBy(x=>x.id).ToList();
.DistinctBy(x => x.id).ToList();
var initialWorkshop = workshops
.Select(w =>
@@ -750,56 +869,56 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
//var oneMonthSum = current.Sum(x => x.Price);
item.contract.SetWorkshopGroup(group);
// var totalPaymentAndWorkshopList = await _clientRegistrationApplication.GetTotalPaymentAndWorkshopList(oneMonthSum,duration: InstitutionContractDuration.TwelveMonths,false);
// item.contract.SetAmount(totalPaymentAndWorkshopList.OneTimeTotalPaymentStr.MoneyToDouble(),
// totalPaymentAndWorkshopList.OneTimeValueAddedTaxStr.MoneyToDouble(),totalPaymentAndWorkshopList.DiscountedAmountForOneMonth.MoneyToDouble());
// var totalPaymentAndWorkshopList = await _clientRegistrationApplication.GetTotalPaymentAndWorkshopList(oneMonthSum,duration: InstitutionContractDuration.TwelveMonths,false);
// item.contract.SetAmount(totalPaymentAndWorkshopList.OneTimeTotalPaymentStr.MoneyToDouble(),
// totalPaymentAndWorkshopList.OneTimeValueAddedTaxStr.MoneyToDouble(),totalPaymentAndWorkshopList.DiscountedAmountForOneMonth.MoneyToDouble());
}
var remoteIds = remoteContractsQuery.Select(x => x.contract.id);
var inPersonContracts =await query
.Where(x=>!remoteIds.Contains(x.contractingParty.id)).ToListAsync();
var inPersonContracts = await query
.Where(x => !remoteIds.Contains(x.contractingParty.id)).ToListAsync();
foreach (var item in inPersonContracts)
{
var workshops = item.contractingParty.Employers
.SelectMany(e => e.WorkshopEmployers.Select(we => we.Workshop)).ToList()
.DistinctBy(x=>x.id).ToList();
.DistinctBy(x => x.id).ToList();
var initialWorkshop = workshops
.Select(w =>
{
var personnelCount =
w.LeftWorks.Count(lw => lw.StartWorkDate <= today && lw.LeftWorkDate >= today);
bool hasRollCallPlan = true;
bool hasRollCallPlanInPerson = false;
bool hasCustomizeCheckoutPlan = w.id == 170;
bool hasContractPlan = true;
bool hasContractPlanInPerson = true;
bool hasInsurancePlan =true;
bool hasInsurancePlan = true;
bool hasInsurancePlanInPerson = true;
var initial = InstitutionContractWorkshopInitial.CreateManual(w.WorkshopFullName, hasRollCallPlan,
hasRollCallPlanInPerson,hasCustomizeCheckoutPlan,
hasContractPlan,hasContractPlanInPerson,
hasInsurancePlan,hasInsurancePlanInPerson,personnelCount,0,
var initial = InstitutionContractWorkshopInitial.CreateManual(w.WorkshopFullName,
hasRollCallPlan,
hasRollCallPlanInPerson, hasCustomizeCheckoutPlan,
hasContractPlan, hasContractPlanInPerson,
hasInsurancePlan, hasInsurancePlanInPerson, personnelCount, 0,
w.id, w.WorkshopEmployers.Select(x => x.EmployerId
).ToList());
return initial;
}).ToList();
var group = new InstitutionContractWorkshopGroup(item.contract.id, initialWorkshop);
await _context.AddAsync(group);
await _context.SaveChangesAsync();
initialWorkshop.ForEach(x =>
{
var workshopId = workshops.First(w => x.WorkshopId.Value == w.id).id;
x.SetWorkshopId(workshopId);
});
item.contract.SetWorkshopGroup(group);
}
await _context.SaveChangesAsync();

Some files were not shown because too many files have changed in this diff Show More