Added TDSPercentage in view model in expense and payment request
This commit is contained in:
parent
381723d785
commit
27399322b8
@ -34,46 +34,149 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#region ======================================================= System Masters =======================================================
|
||||||
public DbSet<RefreshToken> RefreshTokens { get; set; }
|
public DbSet<RefreshToken> RefreshTokens { get; set; }
|
||||||
public DbSet<TenantStatus> TenantStatus { get; set; }
|
public DbSet<TenantStatus> TenantStatus { get; set; }
|
||||||
public DbSet<SubscriptionStatus> SubscriptionStatus { get; set; }
|
public DbSet<SubscriptionStatus> SubscriptionStatus { get; set; }
|
||||||
|
public DbSet<Module> Modules { get; set; }
|
||||||
|
public DbSet<Feature> Features { get; set; }
|
||||||
|
public DbSet<FeaturePermission> FeaturePermissions { get; set; }
|
||||||
|
public DbSet<CurrencyMaster> CurrencyMaster { get; set; }
|
||||||
|
public DbSet<Industry> Industries { get; set; }
|
||||||
|
public DbSet<Inquiries> Inquiries { get; set; }
|
||||||
|
public DbSet<StatusUpdateLog> StatusUpdateLogs { get; set; }
|
||||||
|
public DbSet<PaymentDetail> PaymentDetails { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Tenant Masters =======================================================
|
||||||
|
public DbSet<Document> Documents { get; set; }
|
||||||
|
public DbSet<MailingList> MailingList { get; set; }
|
||||||
|
public DbSet<MailDetails> MailDetails { get; set; }
|
||||||
|
public DbSet<MailLog> MailLogs { get; set; }
|
||||||
|
public DbSet<OTPDetails> OTPDetails { get; set; }
|
||||||
|
public DbSet<MPINDetails> MPINDetails { get; set; }
|
||||||
|
public DbSet<FCMTokenMapping> FCMTokenMappings { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Tenant =======================================================
|
||||||
public DbSet<Tenant> Tenants { get; set; }
|
public DbSet<Tenant> Tenants { get; set; }
|
||||||
public DbSet<SubscriptionPlan> SubscriptionPlans { get; set; }
|
public DbSet<SubscriptionPlan> SubscriptionPlans { get; set; }
|
||||||
public DbSet<SubscriptionPlanDetails> SubscriptionPlanDetails { get; set; }
|
public DbSet<SubscriptionPlanDetails> SubscriptionPlanDetails { get; set; }
|
||||||
public DbSet<TenantSubscriptions> TenantSubscriptions { get; set; }
|
public DbSet<TenantSubscriptions> TenantSubscriptions { get; set; }
|
||||||
|
public DbSet<TenantEnquire> TenantEnquires { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Employees =======================================================
|
||||||
|
|
||||||
|
#region ======================================================= Masters =======================================================
|
||||||
|
public DbSet<JobRole> JobRoles { get; set; }
|
||||||
|
public DbSet<ApplicationRole> ApplicationRoles { get; set; }
|
||||||
|
public DbSet<RolePermissionMappings> RolePermissionMappings { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
|
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
|
||||||
|
public DbSet<Employee> Employees { get; set; }
|
||||||
|
public DbSet<EmployeeRoleMapping> EmployeeRoleMappings { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Project =======================================================
|
||||||
|
|
||||||
|
#region ======================================================= Masters =======================================================
|
||||||
public DbSet<ServiceMaster> ServiceMasters { get; set; }
|
public DbSet<ServiceMaster> ServiceMasters { get; set; }
|
||||||
public DbSet<ActivityGroupMaster> ActivityGroupMasters { get; set; }
|
public DbSet<ActivityGroupMaster> ActivityGroupMasters { get; set; }
|
||||||
public DbSet<ActivityMaster> ActivityMasters { get; set; }
|
public DbSet<ActivityMaster> ActivityMasters { get; set; }
|
||||||
|
public DbSet<StatusMaster> StatusMasters { get; set; }
|
||||||
|
public DbSet<ActivityCheckList> ActivityCheckLists { get; set; }
|
||||||
|
public DbSet<CheckListMappings> CheckListMappings { get; set; }
|
||||||
|
public DbSet<WorkCategoryMaster> WorkCategoryMasters { get; set; }
|
||||||
|
public DbSet<WorkStatusMaster> WorkStatusMasters { get; set; }
|
||||||
|
public DbSet<GlobalServiceMaster> GlobalServiceMasters { get; set; }
|
||||||
|
public DbSet<GlobalActivityGroupMaster> GlobalActivityGroupMasters { get; set; }
|
||||||
|
public DbSet<GlobalActivityMaster> GlobalActivityMasters { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
public DbSet<Project> Projects { get; set; }
|
public DbSet<Project> Projects { get; set; }
|
||||||
public DbSet<ProjectAllocation> ProjectAllocations { get; set; }
|
public DbSet<ProjectAllocation> ProjectAllocations { get; set; }
|
||||||
public DbSet<StatusMaster> StatusMasters { get; set; }
|
|
||||||
public DbSet<Building> Buildings { get; set; }
|
public DbSet<Building> Buildings { get; set; }
|
||||||
public DbSet<Floor> Floor { get; set; }
|
public DbSet<Floor> Floor { get; set; }
|
||||||
public DbSet<WorkArea> WorkAreas { get; set; }
|
public DbSet<WorkArea> WorkAreas { get; set; }
|
||||||
public DbSet<WorkItem> WorkItems { get; set; }
|
public DbSet<WorkItem> WorkItems { get; set; }
|
||||||
public DbSet<WorkShift> WorkShifts { get; set; }
|
public DbSet<WorkShift> WorkShifts { get; set; }
|
||||||
|
public DbSet<ProjectLevelPermissionMapping> ProjectLevelPermissionMappings { get; set; }
|
||||||
|
public DbSet<ProjectServiceMapping> ProjectServiceMappings { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Task Allocation =======================================================
|
||||||
public DbSet<TaskAllocation> TaskAllocations { get; set; }
|
public DbSet<TaskAllocation> TaskAllocations { get; set; }
|
||||||
public DbSet<TaskComment> TaskComments { get; set; }
|
public DbSet<TaskComment> TaskComments { get; set; }
|
||||||
public DbSet<TaskMembers> TaskMembers { get; set; }
|
public DbSet<TaskMembers> TaskMembers { get; set; }
|
||||||
public DbSet<TaskAttachment> TaskAttachments { get; set; }
|
public DbSet<TaskAttachment> TaskAttachments { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Attendace =======================================================
|
||||||
public DbSet<Attendance> Attendes { get; set; }
|
public DbSet<Attendance> Attendes { get; set; }
|
||||||
public DbSet<AttendanceLog> AttendanceLogs { get; set; }
|
public DbSet<AttendanceLog> AttendanceLogs { get; set; }
|
||||||
public DbSet<Employee> Employees { get; set; }
|
#endregion
|
||||||
public DbSet<EmployeeRoleMapping> EmployeeRoleMappings { get; set; }
|
|
||||||
public DbSet<Module> Modules { get; set; }
|
#region ======================================================= Directory =======================================================
|
||||||
public DbSet<Feature> Features { get; set; }
|
|
||||||
public DbSet<FeaturePermission> FeaturePermissions { get; set; }
|
#region ======================================================= Masters =======================================================
|
||||||
public DbSet<ProjectLevelPermissionMapping> ProjectLevelPermissionMappings { get; set; }
|
public DbSet<Bucket> Buckets { get; set; }
|
||||||
public DbSet<CurrencyMaster> CurrencyMaster { get; set; }
|
public DbSet<ContactTagMaster> ContactTagMasters { get; set; }
|
||||||
public DbSet<ApplicationRole> ApplicationRoles { get; set; }
|
public DbSet<ContactCategoryMaster> ContactCategoryMasters { get; set; }
|
||||||
public DbSet<JobRole> JobRoles { get; set; }
|
#endregion
|
||||||
public DbSet<RolePermissionMappings> RolePermissionMappings { get; set; }
|
|
||||||
public DbSet<Industry> Industries { get; set; }
|
public DbSet<Contact> Contacts { get; set; }
|
||||||
public DbSet<ActivityCheckList> ActivityCheckLists { get; set; }
|
public DbSet<ContactEmail> ContactsEmails { get; set; }
|
||||||
public DbSet<CheckListMappings> CheckListMappings { get; set; }
|
public DbSet<ContactPhone> ContactsPhones { get; set; }
|
||||||
public DbSet<Inquiries> Inquiries { get; set; }
|
public DbSet<ContactNote> ContactNotes { get; set; }
|
||||||
|
public DbSet<ContactTagMapping> ContactTagMappings { get; set; }
|
||||||
|
public DbSet<EmployeeBucketMapping> EmployeeBucketMappings { get; set; }
|
||||||
|
public DbSet<ContactBucketMapping> ContactBucketMappings { get; set; }
|
||||||
|
public DbSet<ContactProjectMapping> ContactProjectMappings { get; set; }
|
||||||
|
public DbSet<DirectoryUpdateLog> DirectoryUpdateLogs { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Finance =======================================================
|
||||||
|
|
||||||
|
#region ======================================================= Masters =======================================================
|
||||||
|
public DbSet<PaymentModeMatser> PaymentModeMatser { get; set; }
|
||||||
|
public DbSet<ExpensesStatusMaster> ExpensesStatusMaster { get; set; }
|
||||||
|
public DbSet<ExpensesTypeMaster> ExpensesTypeMaster { get; set; }
|
||||||
|
public DbSet<ExpenseCategoryMaster> ExpenseCategoryMasters { get; set; }
|
||||||
|
public DbSet<RecurringPaymentStatus> RecurringPaymentStatus { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Expenses =======================================================
|
||||||
|
public DbSet<Expenses> Expenses { get; set; }
|
||||||
|
public DbSet<ExpenseLog> ExpenseLogs { get; set; }
|
||||||
|
public DbSet<BillAttachments> BillAttachments { get; set; }
|
||||||
|
public DbSet<ExpensesReimburse> ExpensesReimburse { get; set; }
|
||||||
|
public DbSet<ExpensesReimburseMapping> ExpensesReimburseMapping { get; set; }
|
||||||
|
public DbSet<StatusPermissionMapping> StatusPermissionMapping { get; set; }
|
||||||
|
public DbSet<ExpensesStatusMapping> ExpensesStatusMapping { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Collection =======================================================
|
||||||
|
public DbSet<Invoice> Invoices { get; set; }
|
||||||
|
public DbSet<InvoiceComment> InvoiceComments { get; set; }
|
||||||
|
public DbSet<InvoiceAttachment> InvoiceAttachments { get; set; }
|
||||||
|
public DbSet<ReceivedInvoicePayment> ReceivedInvoicePayments { get; set; }
|
||||||
|
public DbSet<PaymentAdjustmentHead> PaymentAdjustmentHeads { get; set; }
|
||||||
|
#endregion
|
||||||
|
public DbSet<PaymentRequest> PaymentRequests { get; set; }
|
||||||
|
public DbSet<PaymentRequestAttachment> PaymentRequestAttachments { get; set; }
|
||||||
|
public DbSet<RecurringPayment> RecurringPayments { get; set; }
|
||||||
|
public DbSet<AdvancePaymentTransaction> AdvancePaymentTransactions { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ======================================================= Tickets =======================================================
|
||||||
public DbSet<TicketForum> Tickets { get; set; }
|
public DbSet<TicketForum> Tickets { get; set; }
|
||||||
public DbSet<TicketAttachment> TicketAttachments { get; set; }
|
public DbSet<TicketAttachment> TicketAttachments { get; set; }
|
||||||
public DbSet<TicketComment> TicketComments { get; set; }
|
public DbSet<TicketComment> TicketComments { get; set; }
|
||||||
@ -81,57 +184,10 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
public DbSet<TicketTypeMaster> TicketTypeMasters { get; set; }
|
public DbSet<TicketTypeMaster> TicketTypeMasters { get; set; }
|
||||||
public DbSet<TicketPriorityMaster> TicketPriorityMasters { get; set; }
|
public DbSet<TicketPriorityMaster> TicketPriorityMasters { get; set; }
|
||||||
public DbSet<TicketTagMaster> TicketTagMasters { get; set; }
|
public DbSet<TicketTagMaster> TicketTagMasters { get; set; }
|
||||||
public DbSet<Document> Documents { get; set; }
|
|
||||||
public DbSet<TicketTag> TicketTags { get; set; }
|
public DbSet<TicketTag> TicketTags { get; set; }
|
||||||
public DbSet<WorkCategoryMaster> WorkCategoryMasters { get; set; }
|
#endregion
|
||||||
public DbSet<WorkStatusMaster> WorkStatusMasters { get; set; }
|
|
||||||
public DbSet<Contact> Contacts { get; set; }
|
|
||||||
public DbSet<ContactCategoryMaster> ContactCategoryMasters { get; set; }
|
|
||||||
public DbSet<ContactEmail> ContactsEmails { get; set; }
|
|
||||||
public DbSet<ContactPhone> ContactsPhones { get; set; }
|
|
||||||
public DbSet<ContactNote> ContactNotes { get; set; }
|
|
||||||
public DbSet<Bucket> Buckets { get; set; }
|
|
||||||
public DbSet<ContactTagMaster> ContactTagMasters { get; set; }
|
|
||||||
public DbSet<ContactTagMapping> ContactTagMappings { get; set; }
|
|
||||||
public DbSet<EmployeeBucketMapping> EmployeeBucketMappings { get; set; }
|
|
||||||
public DbSet<ContactBucketMapping> ContactBucketMappings { get; set; }
|
|
||||||
public DbSet<ContactProjectMapping> ContactProjectMappings { get; set; }
|
|
||||||
public DbSet<DirectoryUpdateLog> DirectoryUpdateLogs { get; set; }
|
|
||||||
|
|
||||||
public DbSet<MailingList> MailingList { get; set; }
|
|
||||||
public DbSet<MailDetails> MailDetails { get; set; }
|
|
||||||
public DbSet<MailLog> MailLogs { get; set; }
|
|
||||||
public DbSet<OTPDetails> OTPDetails { get; set; }
|
|
||||||
public DbSet<MPINDetails> MPINDetails { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Expenses> Expenses { get; set; }
|
|
||||||
public DbSet<ExpenseLog> ExpenseLogs { get; set; }
|
|
||||||
public DbSet<ExpensesTypeMaster> ExpensesTypeMaster { get; set; }
|
|
||||||
public DbSet<ExpenseCategoryMaster> ExpenseCategoryMasters { get; set; }
|
|
||||||
public DbSet<PaymentModeMatser> PaymentModeMatser { get; set; }
|
|
||||||
public DbSet<ExpensesStatusMaster> ExpensesStatusMaster { get; set; }
|
|
||||||
public DbSet<BillAttachments> BillAttachments { get; set; }
|
|
||||||
public DbSet<ExpensesReimburse> ExpensesReimburse { get; set; }
|
|
||||||
public DbSet<ExpensesReimburseMapping> ExpensesReimburseMapping { get; set; }
|
|
||||||
public DbSet<StatusPermissionMapping> StatusPermissionMapping { get; set; }
|
|
||||||
public DbSet<ExpensesStatusMapping> ExpensesStatusMapping { get; set; }
|
|
||||||
public DbSet<PaymentRequest> PaymentRequests { get; set; }
|
|
||||||
public DbSet<PaymentRequestAttachment> PaymentRequestAttachments { get; set; }
|
|
||||||
public DbSet<RecurringPayment> RecurringPayments { get; set; }
|
|
||||||
public DbSet<AdvancePaymentTransaction> AdvancePaymentTransactions { get; set; }
|
|
||||||
public DbSet<RecurringPaymentStatus> RecurringPaymentStatus { get; set; }
|
|
||||||
|
|
||||||
public DbSet<StatusUpdateLog> StatusUpdateLogs { get; set; }
|
|
||||||
|
|
||||||
// Collection
|
|
||||||
public DbSet<Invoice> Invoices { get; set; }
|
|
||||||
public DbSet<InvoiceComment> InvoiceComments { get; set; }
|
|
||||||
public DbSet<InvoiceAttachment> InvoiceAttachments { get; set; }
|
|
||||||
public DbSet<ReceivedInvoicePayment> ReceivedInvoicePayments { get; set; }
|
|
||||||
public DbSet<PaymentAdjustmentHead> PaymentAdjustmentHeads { get; set; }
|
|
||||||
|
|
||||||
public DbSet<FCMTokenMapping> FCMTokenMappings { get; set; }
|
|
||||||
|
|
||||||
|
#region ======================================================= Project and Employee Documents =======================================================
|
||||||
public DbSet<EntityTypeMaster> EntityTypeMasters { get; set; }
|
public DbSet<EntityTypeMaster> EntityTypeMasters { get; set; }
|
||||||
public DbSet<DocumentTypeMaster> DocumentTypeMasters { get; set; }
|
public DbSet<DocumentTypeMaster> DocumentTypeMasters { get; set; }
|
||||||
public DbSet<DocumentCategoryMaster> DocumentCategoryMasters { get; set; }
|
public DbSet<DocumentCategoryMaster> DocumentCategoryMasters { get; set; }
|
||||||
@ -139,20 +195,16 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
public DbSet<DocumentAttachment> DocumentAttachments { get; set; }
|
public DbSet<DocumentAttachment> DocumentAttachments { get; set; }
|
||||||
public DbSet<AttachmentVersionMapping> AttachmentVersionMappings { get; set; }
|
public DbSet<AttachmentVersionMapping> AttachmentVersionMappings { get; set; }
|
||||||
public DbSet<AttachmentTagMapping> AttachmentTagMappings { get; set; }
|
public DbSet<AttachmentTagMapping> AttachmentTagMappings { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
public DbSet<GlobalServiceMaster> GlobalServiceMasters { get; set; }
|
#region ======================================================= Organizations =======================================================
|
||||||
public DbSet<GlobalActivityGroupMaster> GlobalActivityGroupMasters { get; set; }
|
|
||||||
public DbSet<GlobalActivityMaster> GlobalActivityMasters { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Organization> Organizations { get; set; }
|
public DbSet<Organization> Organizations { get; set; }
|
||||||
public DbSet<OrgTypeMaster> OrgTypeMasters { get; set; }
|
public DbSet<OrgTypeMaster> OrgTypeMasters { get; set; }
|
||||||
public DbSet<TenantOrgMapping> TenantOrgMappings { get; set; }
|
public DbSet<TenantOrgMapping> TenantOrgMappings { get; set; }
|
||||||
public DbSet<OrgServiceMapping> OrgServiceMappings { get; set; }
|
public DbSet<OrgServiceMapping> OrgServiceMappings { get; set; }
|
||||||
public DbSet<ProjectServiceMapping> ProjectServiceMappings { get; set; }
|
|
||||||
public DbSet<ProjectOrgMapping> ProjectOrgMappings { get; set; }
|
public DbSet<ProjectOrgMapping> ProjectOrgMappings { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
public DbSet<PaymentDetail> PaymentDetails { get; set; }
|
|
||||||
public DbSet<TenantEnquire> TenantEnquires { get; set; }
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace Marco.Pms.Model.MongoDBModels.Expenses
|
|||||||
public CurrencyMaster? Currency { get; set; }
|
public CurrencyMaster? Currency { get; set; }
|
||||||
public double? BaseAmount { get; set; }
|
public double? BaseAmount { get; set; }
|
||||||
public double? TaxAmount { get; set; }
|
public double? TaxAmount { get; set; }
|
||||||
|
public double? TDSPercentage { get; set; }
|
||||||
public string? PaymentRequestUID { get; set; }
|
public string? PaymentRequestUID { get; set; }
|
||||||
public string? ExpenseUId { get; set; }
|
public string? ExpenseUId { get; set; }
|
||||||
public ExpensesStatusMasterMongoDB Status { get; set; } = new ExpensesStatusMasterMongoDB();
|
public ExpensesStatusMasterMongoDB Status { get; set; } = new ExpensesStatusMasterMongoDB();
|
||||||
|
|||||||
@ -21,6 +21,9 @@ namespace Marco.Pms.Model.ViewModels.Expenses
|
|||||||
public string SupplerName { get; set; } = string.Empty;
|
public string SupplerName { get; set; } = string.Empty;
|
||||||
public string? ExpenseUId { get; set; }
|
public string? ExpenseUId { get; set; }
|
||||||
public double Amount { get; set; }
|
public double Amount { get; set; }
|
||||||
|
public double? BaseAmount { get; set; }
|
||||||
|
public double? TaxAmount { get; set; }
|
||||||
|
public double? TDSPercentage { get; set; }
|
||||||
public ExpensesStatusMasterVM? Status { get; set; }
|
public ExpensesStatusMasterVM? Status { get; set; }
|
||||||
public List<ExpensesStatusMasterVM>? NextStatus { get; set; }
|
public List<ExpensesStatusMasterVM>? NextStatus { get; set; }
|
||||||
public bool PreApproved { get; set; } = false;
|
public bool PreApproved { get; set; } = false;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace Marco.Pms.Model.ViewModels.Expenses
|
|||||||
public double Amount { get; set; }
|
public double Amount { get; set; }
|
||||||
public double? BaseAmount { get; set; }
|
public double? BaseAmount { get; set; }
|
||||||
public double? TaxAmount { get; set; }
|
public double? TaxAmount { get; set; }
|
||||||
|
public double? TDSPercentage { get; set; }
|
||||||
public DateTime DueDate { get; set; }
|
public DateTime DueDate { get; set; }
|
||||||
public BasicProjectVM? Project { get; set; }
|
public BasicProjectVM? Project { get; set; }
|
||||||
public BasicRecurringPaymentVM? RecurringPayment { get; set; }
|
public BasicRecurringPaymentVM? RecurringPayment { get; set; }
|
||||||
|
|||||||
@ -839,15 +839,22 @@ namespace Marco.Pms.Services.Service
|
|||||||
$"The sum of the base amount and tax amount ({totalAmount}) does not match the expected expense amount ({expense.Amount}).",
|
$"The sum of the base amount and tax amount ({totalAmount}) does not match the expected expense amount ({expense.Amount}).",
|
||||||
400);
|
400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var result = ValidateTdsPercentage(model.TDSPercentage);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
expense.ProcessedById = loggedInEmployee.Id;
|
expense.ProcessedById = loggedInEmployee.Id;
|
||||||
expense.BaseAmount = model.BaseAmount;
|
expense.BaseAmount = model.BaseAmount;
|
||||||
expense.TaxAmount = model.TaxAmount;
|
expense.TaxAmount = model.TaxAmount;
|
||||||
|
expense.TDSPercentage = model.TDSPercentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Add Reimbursement if applicable
|
// 7. Add Reimbursement if applicable
|
||||||
if (model.StatusId == Processed)
|
if (model.StatusId == Processed)
|
||||||
{
|
{
|
||||||
expense.TDSPercentage = model.TDSPercentage;
|
|
||||||
var reimbursement = new ExpensesReimburse
|
var reimbursement = new ExpensesReimburse
|
||||||
{
|
{
|
||||||
ReimburseTransactionId = model.ReimburseTransactionId!,
|
ReimburseTransactionId = model.ReimburseTransactionId!,
|
||||||
@ -1938,6 +1945,13 @@ namespace Marco.Pms.Services.Service
|
|||||||
$"The sum of the base amount and tax amount ({totalAmount}) does not match the expected payment request amount ({paymentRequest.Amount}).",
|
$"The sum of the base amount and tax amount ({totalAmount}) does not match the expected payment request amount ({paymentRequest.Amount}).",
|
||||||
400);
|
400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var result = ValidateTdsPercentage(model.TDSPercentage);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
paymentRequest.PaidAt = model.PaidAt;
|
paymentRequest.PaidAt = model.PaidAt;
|
||||||
paymentRequest.PaidById = model.PaidById;
|
paymentRequest.PaidById = model.PaidById;
|
||||||
paymentRequest.PaidTransactionId = model.PaidTransactionId;
|
paymentRequest.PaidTransactionId = model.PaidTransactionId;
|
||||||
@ -3745,77 +3759,107 @@ namespace Marco.Pms.Services.Service
|
|||||||
await Task.WhenAll(attachmentTask, documentsTask);
|
await Task.WhenAll(attachmentTask, documentsTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if recurring payments are applicable based on frequency, iteration count, and date logic.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="numberOfIteration">Maximum allowed payment iterations.</param>
|
||||||
|
/// <param name="frequency">Frequency of recurring payments (e.g., Monthly, Quarterly).</param>
|
||||||
|
/// <param name="strikeDate">The starting date for recurring payments.</param>
|
||||||
|
/// <param name="latestPRGeneratedAt">The date of the latest payment receipt, if any.</param>
|
||||||
|
/// <returns>True if recurring payments are applicable; otherwise, false.</returns>
|
||||||
private static bool IsRecurringApplicable(int numberOfIteration, PLAN_FREQUENCY frequency, DateTime strikeDate, DateTime? latestPRGeneratedAt)
|
private static bool IsRecurringApplicable(int numberOfIteration, PLAN_FREQUENCY frequency, DateTime strikeDate, DateTime? latestPRGeneratedAt)
|
||||||
{
|
{
|
||||||
List<DateTime> dates = new List<DateTime>();
|
// Validate input parameters
|
||||||
DateTime currentDate = strikeDate;
|
if (numberOfIteration <= 0)
|
||||||
DateTime endDate = DateTime.UtcNow.Date;
|
|
||||||
|
|
||||||
switch (frequency)
|
|
||||||
{
|
{
|
||||||
case PLAN_FREQUENCY.MONTHLY:
|
return false;
|
||||||
while (currentDate <= endDate)
|
|
||||||
{
|
|
||||||
dates.Add(currentDate);
|
|
||||||
currentDate = currentDate.AddMonths(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PLAN_FREQUENCY.QUARTERLY:
|
|
||||||
while (currentDate <= endDate)
|
|
||||||
{
|
|
||||||
dates.Add(currentDate);
|
|
||||||
currentDate = currentDate.AddMonths(3);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PLAN_FREQUENCY.HALF_YEARLY:
|
|
||||||
while (currentDate <= endDate)
|
|
||||||
{
|
|
||||||
dates.Add(currentDate);
|
|
||||||
currentDate = currentDate.AddMonths(6);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PLAN_FREQUENCY.YEARLY:
|
|
||||||
while (currentDate <= endDate)
|
|
||||||
{
|
|
||||||
dates.Add(currentDate);
|
|
||||||
currentDate = currentDate.AddYears(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PLAN_FREQUENCY.DAILY:
|
|
||||||
while (currentDate <= endDate)
|
|
||||||
{
|
|
||||||
dates.Add(currentDate);
|
|
||||||
currentDate = currentDate.AddDays(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PLAN_FREQUENCY.WEEKLY:
|
|
||||||
while (currentDate <= endDate)
|
|
||||||
{
|
|
||||||
dates.Add(currentDate);
|
|
||||||
currentDate = currentDate.AddDays(7);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure strikeDate is in a consistent timezone (UTC or local as per your business logic)
|
||||||
|
var currentDate = strikeDate.Date;
|
||||||
|
var endDate = DateTime.UtcNow.Date;
|
||||||
|
|
||||||
|
// List to store generated dates for validation
|
||||||
|
var dates = new List<DateTime>();
|
||||||
|
|
||||||
|
// Define increment logic for each frequency
|
||||||
|
Func<DateTime, DateTime> incrementFunc = frequency switch
|
||||||
|
{
|
||||||
|
PLAN_FREQUENCY.MONTHLY => d => d.AddMonths(1),
|
||||||
|
PLAN_FREQUENCY.QUARTERLY => d => d.AddMonths(3),
|
||||||
|
PLAN_FREQUENCY.HALF_YEARLY => d => d.AddMonths(6),
|
||||||
|
PLAN_FREQUENCY.YEARLY => d => d.AddYears(1),
|
||||||
|
PLAN_FREQUENCY.DAILY => d => d.AddDays(1),
|
||||||
|
PLAN_FREQUENCY.WEEKLY => d => d.AddDays(7),
|
||||||
|
_ => d => d.AddDays(1)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Return false if frequency is not supported
|
||||||
|
if (incrementFunc == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate dates based on frequency until endDate
|
||||||
|
while (currentDate <= endDate)
|
||||||
|
{
|
||||||
|
dates.Add(currentDate);
|
||||||
|
currentDate = incrementFunc(currentDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation: Must have at least one date and not exceed iteration count
|
||||||
if (!dates.Any() || dates.Count > numberOfIteration)
|
if (!dates.Any() || dates.Count > numberOfIteration)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validation: Last generated date must match endDate
|
||||||
if (dates.Last() != endDate)
|
if (dates.Last() != endDate)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (latestPRGeneratedAt.HasValue && latestPRGeneratedAt.Value == endDate)
|
// Validation: Latest payment receipt should not be on endDate
|
||||||
|
if (latestPRGeneratedAt.HasValue && latestPRGeneratedAt.Value.Date == endDate)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates the TDS Percentage in the provided model.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The input model containing TDS Percentage.</param>
|
||||||
|
/// <returns>Returns an error response if validation fails; otherwise, null.</returns>
|
||||||
|
private ApiResponse<object>? ValidateTdsPercentage(double? TDSPercentage)
|
||||||
|
{
|
||||||
|
// Check if TDSPercentage is present in the model
|
||||||
|
if (!TDSPercentage.HasValue)
|
||||||
|
{
|
||||||
|
return null; // No validation needed if TDSPercentage is not provided
|
||||||
|
}
|
||||||
|
|
||||||
|
var tdsValue = TDSPercentage.Value;
|
||||||
|
|
||||||
|
// Validate TDS Percentage range: must be between 0 and 100 inclusive
|
||||||
|
if (tdsValue < 0 || tdsValue > 100)
|
||||||
|
{
|
||||||
|
// Log a warning with structured logging for traceability
|
||||||
|
_logger.LogWarning("TDS Percentage validation failed. Provided value: {TdsValue} is outside the valid range (0 - 100).", tdsValue);
|
||||||
|
|
||||||
|
// Return a consistent and clear error response with HTTP status 400
|
||||||
|
return ApiResponse<object>.ErrorResponse(
|
||||||
|
"Invalid TDS Percentage value. Allowed range is 0 to 100 inclusive.",
|
||||||
|
"TDS Percentage value out of range.",
|
||||||
|
400);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // Validation successful, no error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user