Files
moadiran/Back/Services/servTaxPayer.cs

60 lines
2.7 KiB
C#
Raw Normal View History

2024-05-01 15:42:21 +03:30
using Shared.DTOs;
2024-04-30 16:40:05 +03:30
using Back.Data.Contracts;
using Back.Data.Models;
using Microsoft.EntityFrameworkCore;
2024-05-31 00:24:45 +03:30
using Back.Common;
2024-04-30 16:40:05 +03:30
namespace Back.Services
{
public class servTaxPayer
{
private readonly IAsyncRepository<SentTax> _repoSentTax;
2024-05-16 23:40:32 +03:30
private readonly IAsyncRepository<Pattern> _repoPattern;
2024-05-31 00:24:45 +03:30
private readonly IAsyncRepository<Invoice> _invoiceRepo;
public servTaxPayer(IAsyncRepository<SentTax> repoSentTax, IAsyncRepository<Pattern> repoPattern
, IAsyncRepository<Invoice> invoiceRepo)
2024-04-30 16:40:05 +03:30
{
_repoSentTax = repoSentTax;
2024-05-16 23:40:32 +03:30
_repoPattern = repoPattern;
2024-05-31 00:24:45 +03:30
_invoiceRepo = invoiceRepo;
2024-04-30 16:40:05 +03:30
}
public async Task<bool> ExistSuccessfulorSendorpendingInvoiceinCompanyID(int CompanyID)
{
return await _repoSentTax.Get(w => w.invoice.CompanyID == CompanyID && (w.SentStatus == SentStatus.Successful || w.SentStatus == SentStatus.Send || w.SentStatus == SentStatus.pending)).AnyAsync();
}
2024-05-13 16:50:26 +03:30
public async Task<bool> ExistSuccessfulorSendorpendingInvoice(Invoice invoice)
{
2024-05-25 21:30:11 +03:30
return _repoSentTax.Get(w => w.InvoiceType == invoice.invoiceType && w.InvoiceID == invoice.ID &&
2024-05-13 16:50:26 +03:30
(w.SentStatus == SentStatus.Successful || w.SentStatus == SentStatus.Send || w.SentStatus == SentStatus.pending)).Any();
}
2024-04-30 16:40:05 +03:30
public async Task<bool> CheckingTheCompanyKeyInformation(int CompanyID, string UniqeMemory, string PrivateKey, string EconomicCode)
{
return await _repoSentTax.Get(w => (w.invoice.company.UniqeMemory == UniqeMemory || w.invoice.company.PrivateKey == PrivateKey || w.invoice.company.EconomicCode == EconomicCode)
&& (w.SentStatus == SentStatus.Successful || w.SentStatus == SentStatus.Send || w.SentStatus == SentStatus.pending)
&& w.invoice.CompanyID != CompanyID).AnyAsync();
}
2024-05-16 23:40:32 +03:30
public async Task<List<IdName<int>>> GetPatterns()
{
return await _repoPattern.Get(w=>w.Status).Select(s => new IdName<int> { ID = s.ID, Title = s.Title }).ToListAsync();
2024-04-30 16:40:05 +03:30
2024-05-16 23:40:32 +03:30
}
2024-05-31 00:24:45 +03:30
public async Task<Invoice?> GetInvoice(int CompanyID, int ID)
{
#region AdvancedSearch
var invok = _invoiceRepo
.Get(w => w.CompanyID == CompanyID && w.ID == ID && !w.IsDeleted);
#endregion
//-----------------------
return await invok
2024-05-31 00:59:38 +03:30
.Include(inc => inc.invoice)
2024-05-31 00:24:45 +03:30
.Include(inc => inc.invoiceDetails)
.ThenInclude(inc => inc.cODItem)
.ThenInclude(inc => inc.CODUnit)
.FirstOrDefaultAsync();
}
2024-04-30 16:40:05 +03:30
}
}