invoice
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Service">
|
<Reference Include="Service">
|
||||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ namespace Back.Controllers
|
|||||||
private readonly servInvoice _servInvoice;
|
private readonly servInvoice _servInvoice;
|
||||||
private readonly servUser _servUser;
|
private readonly servUser _servUser;
|
||||||
private readonly AddOrUpdateInvoiceValidation _validationInvoice;
|
private readonly AddOrUpdateInvoiceValidation _validationInvoice;
|
||||||
public InvoiceController(servInvoice servInvoice, servUser servUser, AddOrUpdateInvoiceValidation validationInvoice)
|
private readonly servTaxPayer _servTaxPayer;
|
||||||
|
public InvoiceController(servInvoice servInvoice, servUser servUser, AddOrUpdateInvoiceValidation validationInvoice, servTaxPayer servTaxPayer)
|
||||||
{
|
{
|
||||||
_servInvoice = servInvoice;
|
_servInvoice = servInvoice;
|
||||||
_servUser = servUser;
|
_servUser = servUser;
|
||||||
_validationInvoice = validationInvoice;
|
_validationInvoice = validationInvoice;
|
||||||
|
_servTaxPayer = servTaxPayer;
|
||||||
|
|
||||||
}
|
}
|
||||||
[HttpPost("GetAll")]
|
[HttpPost("GetAll")]
|
||||||
@@ -33,8 +35,8 @@ namespace Back.Controllers
|
|||||||
return Ok(await _servInvoice.GetInvoices(user.RolUsers.First().CompanyID, itemSerch));
|
return Ok(await _servInvoice.GetInvoices(user.RolUsers.First().CompanyID, itemSerch));
|
||||||
|
|
||||||
}
|
}
|
||||||
[HttpPost("AddORUpdateInvoice/{CompanyID}")]//ok
|
[HttpPost("Add")]
|
||||||
public async Task<ActionResult<int>> AddORUpdateInvoice(int CompanyID, [FromBody] NUInvoiceDTO item)
|
public async Task<ActionResult<int>> Add([FromBody] NUInvoiceDTO item)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(item);
|
return BadRequest(item);
|
||||||
@@ -66,7 +68,7 @@ namespace Back.Controllers
|
|||||||
Des = item.Des,
|
Des = item.Des,
|
||||||
invoiceType = InvoiceType.Bidding,
|
invoiceType = InvoiceType.Bidding,
|
||||||
CustomerID = item.CustomerID,
|
CustomerID = item.CustomerID,
|
||||||
CompanyID = CompanyID,
|
CompanyID = user.RolUsers.First().CompanyID,
|
||||||
InvoicIssueDate = item.InvoicIssueDate.Replace("/", ""),
|
InvoicIssueDate = item.InvoicIssueDate.Replace("/", ""),
|
||||||
InvoiceDate = item.InvoicIssueDate.Replace("/", ""),
|
InvoiceDate = item.InvoicIssueDate.Replace("/", ""),
|
||||||
LastChangeUserID = Convert.ToInt32(UserID),
|
LastChangeUserID = Convert.ToInt32(UserID),
|
||||||
@@ -77,6 +79,267 @@ namespace Back.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
[HttpPut("Update")]
|
||||||
|
public async Task<ActionResult<int>> Update([FromBody] NUInvoiceDTO item)
|
||||||
|
{
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(item);
|
||||||
|
|
||||||
|
//-----GetUserAndCompany
|
||||||
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
var UserID = claim.Value;
|
||||||
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||||
|
|
||||||
|
//-----Validaton
|
||||||
|
var resultValidationmodel = await _validationInvoice.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, item, eActionValidation.update));
|
||||||
|
if (!resultValidationmodel.IsValid)
|
||||||
|
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||||
|
|
||||||
|
//-----Get invoice
|
||||||
|
Invoice invoice =await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID,item.ID.Value);
|
||||||
|
if (invoice == null)
|
||||||
|
return BadRequest(new List<string> { "invoice notFound..." });
|
||||||
|
|
||||||
|
if (invoice.PatternID != item.PatternID || invoice.CustomerID != item.CustomerID
|
||||||
|
|| invoice.InvoicIssueDate != item.InvoicIssueDate || invoice.InvoiceDate != item.InvoiceDate)
|
||||||
|
{
|
||||||
|
//----Check TaxPayer
|
||||||
|
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice))
|
||||||
|
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||||
|
"برای ویرایش ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----change invoice
|
||||||
|
invoice.Title = item.Title;
|
||||||
|
invoice.PatternID = item.PatternID;
|
||||||
|
invoice.CustomerID = item.CustomerID;
|
||||||
|
invoice.InvoicIssueDate = item.InvoicIssueDate;
|
||||||
|
invoice.InvoiceDate = item.InvoiceDate;
|
||||||
|
invoice.Des = item.Des;
|
||||||
|
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||||
|
|
||||||
|
return Ok(await _servInvoice.UpdateInvoice(invoice));
|
||||||
|
}
|
||||||
|
[HttpDelete("Delete/{ID}")]
|
||||||
|
public async Task<ActionResult<bool>> Delete(int ID)
|
||||||
|
{
|
||||||
|
//-----GetUserAndCompany
|
||||||
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
var UserID = claim.Value;
|
||||||
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||||
|
|
||||||
|
//-----Get invoice
|
||||||
|
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID,ID);
|
||||||
|
if (invoice == null)
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||||
|
//----Update and sendResult
|
||||||
|
return Ok(await _servInvoice.DeleteInvoice(invoice));
|
||||||
|
}
|
||||||
|
[HttpPost("ChangeInvoiceType/{InvoiceID}")]// ok
|
||||||
|
public async Task<ActionResult<int>> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType)
|
||||||
|
{
|
||||||
|
//-----GetUserAndCompany
|
||||||
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
var UserID = claim.Value;
|
||||||
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||||
|
|
||||||
|
Invoice? Invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID,InvoiceID);
|
||||||
|
if (Invoice == null) return NotFound();
|
||||||
|
|
||||||
|
if (Invoice.invoiceType == InvoiceType.CANCEL) return BadRequest(new List<string> { "این صورتحساب لغو شده" });
|
||||||
|
var sent = await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(Invoice);
|
||||||
|
Invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||||
|
if (Invoice.invoiceType == InvoiceType.Bidding)
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.Sale:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
case InvoiceType.CANCEL:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Invoice.invoiceType == InvoiceType.Sale)
|
||||||
|
{
|
||||||
|
if (sent)
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.Cancellation:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
case InvoiceType.Repair:
|
||||||
|
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||||
|
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
Title = Invoice.Title,
|
||||||
|
Des = Invoice.Des,
|
||||||
|
invoiceType = invoiceType,
|
||||||
|
CustomerID = Invoice.CustomerID,
|
||||||
|
CompanyID = Invoice.CompanyID,
|
||||||
|
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
LastChangeUserID = Convert.ToInt32(UserID),
|
||||||
|
BillReference = Invoice.ID,
|
||||||
|
IsDeleted = false,
|
||||||
|
PatternID = Invoice.PatternID
|
||||||
|
}, false));
|
||||||
|
|
||||||
|
case InvoiceType.BackFrmSale:
|
||||||
|
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||||
|
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
Title = Invoice.Title,
|
||||||
|
Des = Invoice.Des,
|
||||||
|
invoiceType = invoiceType,
|
||||||
|
CustomerID = Invoice.CustomerID,
|
||||||
|
CompanyID = Invoice.CompanyID,
|
||||||
|
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
LastChangeUserID = Convert.ToInt32(UserID),
|
||||||
|
BillReference = Invoice.ID,
|
||||||
|
IsDeleted = false,
|
||||||
|
PatternID = Invoice.PatternID
|
||||||
|
}, false));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.CANCEL:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Invoice.invoiceType == InvoiceType.Cancellation)
|
||||||
|
{
|
||||||
|
if (!sent)
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.Sale:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
case InvoiceType.CANCEL:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||||
|
}
|
||||||
|
if (Invoice.invoiceType == InvoiceType.Repair)
|
||||||
|
{
|
||||||
|
if (!sent)
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.CANCEL:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.Cancellation:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
case InvoiceType.BackFrmSale:
|
||||||
|
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||||
|
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
Title = Invoice.Title,
|
||||||
|
Des = Invoice.Des,
|
||||||
|
invoiceType = invoiceType,
|
||||||
|
CustomerID = Invoice.CustomerID,
|
||||||
|
CompanyID = Invoice.CompanyID,
|
||||||
|
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
LastChangeUserID = Convert.ToInt32(UserID),
|
||||||
|
BillReference = Invoice.ID,
|
||||||
|
IsDeleted = false,
|
||||||
|
PatternID = Invoice.PatternID
|
||||||
|
}, false));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||||
|
{
|
||||||
|
if (!sent)
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.CANCEL:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (invoiceType)
|
||||||
|
{
|
||||||
|
case InvoiceType.Cancellation:
|
||||||
|
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||||
|
|
||||||
|
case InvoiceType.Repair:
|
||||||
|
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||||
|
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
Title = Invoice.Title,
|
||||||
|
Des = Invoice.Des,
|
||||||
|
invoiceType = invoiceType,
|
||||||
|
CustomerID = Invoice.CustomerID,
|
||||||
|
CompanyID = Invoice.CompanyID,
|
||||||
|
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||||
|
LastChangeUserID = Convert.ToInt32(UserID),
|
||||||
|
BillReference = Invoice.ID,
|
||||||
|
IsDeleted = false,
|
||||||
|
PatternID = Invoice.PatternID
|
||||||
|
}, false));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return NoContent();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,15 @@ namespace Back.Services
|
|||||||
private readonly IAsyncRepository<Invoice> _invoiceRepo;
|
private readonly IAsyncRepository<Invoice> _invoiceRepo;
|
||||||
private readonly IAsyncRepository<InvoiceItem> _invoiceItemRepo;
|
private readonly IAsyncRepository<InvoiceItem> _invoiceItemRepo;
|
||||||
private readonly IAsyncRepository<InvoicePayment> _invoicePaymentRepo;
|
private readonly IAsyncRepository<InvoicePayment> _invoicePaymentRepo;
|
||||||
|
private readonly IAsyncRepository<InvoiceStatusChang> _invoiceStatusChangPaymentRepo;
|
||||||
private readonly CheckPermission _checkPermission;
|
private readonly CheckPermission _checkPermission;
|
||||||
public servInvoice(IAsyncRepository<Invoice> invoiceRepo
|
public servInvoice(IAsyncRepository<Invoice> invoiceRepo
|
||||||
, IAsyncRepository<InvoiceItem> invoiceItemRepo
|
, IAsyncRepository<InvoiceItem> invoiceItemRepo
|
||||||
, IAsyncRepository<InvoicePayment> invoicePaymentRepo, CheckPermission checkPermission)
|
, IAsyncRepository<InvoicePayment> invoicePaymentRepo
|
||||||
|
, CheckPermission checkPermission
|
||||||
|
, IAsyncRepository<InvoiceStatusChang> invoiceStatusChangPaymentRepo)
|
||||||
{
|
{
|
||||||
|
_invoiceStatusChangPaymentRepo= invoiceStatusChangPaymentRepo;
|
||||||
_invoiceItemRepo = invoiceItemRepo;
|
_invoiceItemRepo = invoiceItemRepo;
|
||||||
_invoiceRepo = invoiceRepo;
|
_invoiceRepo = invoiceRepo;
|
||||||
_invoicePaymentRepo = invoicePaymentRepo;
|
_invoicePaymentRepo = invoicePaymentRepo;
|
||||||
@@ -101,15 +105,117 @@ namespace Back.Services
|
|||||||
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task<bool> AddInvoice(Invoice invoice)
|
public async Task<bool> AddInvoice(Invoice invoice, bool calculate = true)
|
||||||
{
|
{
|
||||||
invoice.Cdate = DateTime.Now.ConvertMiladiToShamsi();
|
invoice.Cdate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
invoice.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
invoice.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
invoice.PreparedtoSendtoTax = false;
|
invoice.PreparedtoSendtoTax = false;
|
||||||
|
if (calculate)
|
||||||
|
{
|
||||||
|
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
|
||||||
|
return await _invoiceRepo.AddBoolResultAsync(invoice);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return await _invoiceRepo.AddBoolResultAsync(invoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task<bool> UpdateInvoice(Invoice invoice)
|
||||||
|
{
|
||||||
|
invoice.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
|
invoice.PreparedtoSendtoTax = false;
|
||||||
|
|
||||||
|
|
||||||
|
return await _invoiceRepo.UpdateAsync(invoice);
|
||||||
|
}
|
||||||
|
public async Task<Invoice?> GetInvoiceByInvoiceID(int CompanyID, int InvoiceID)
|
||||||
|
{
|
||||||
|
return await _invoiceRepo
|
||||||
|
.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
public async Task<bool> DeleteInvoice(Invoice item)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
|
item.IsDeleted = true;
|
||||||
|
return await _invoiceRepo.UpdateAsync(item);
|
||||||
|
//SysLog log = new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/DeleteCustomer",
|
||||||
|
// Value = JsonConvert.SerializeObject(item.ID),
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "User"
|
||||||
|
//};
|
||||||
|
//_contextMongodb.InsertItem(log);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//SysLog log = new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/DeleteCustomer",
|
||||||
|
// Value = ex.Message,
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "catch"
|
||||||
|
//};
|
||||||
|
//_contextMongodb.InsertItem(log);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<bool> ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true)
|
||||||
|
{
|
||||||
|
string old = invoiceitem.invoiceType.GetEnumDisplayName();
|
||||||
|
invoiceitem.invoiceType = item;
|
||||||
|
invoiceitem.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
|
invoiceitem.PreparedtoSendtoTax = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _invoiceStatusChangPaymentRepo.AddBoolResultAsync(new InvoiceStatusChang()
|
||||||
|
{
|
||||||
|
InvoiceID = invoiceitem.ID,
|
||||||
|
ToStatus = item.GetEnumDisplayName(),
|
||||||
|
FromStatus = old,
|
||||||
|
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
UserID = invoiceitem.LastChangeUserID
|
||||||
|
});
|
||||||
|
if(action)
|
||||||
|
return await _invoiceRepo.UpdateAsync(invoiceitem);
|
||||||
|
else return true;
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/ChangeInvoiceType",
|
||||||
|
// Value = $"From {old} to {item.ToString()}",
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "User"
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//_contextMongodb.InsertItem(new SysLog()
|
||||||
|
//{
|
||||||
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||||
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||||
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/ChangeInvoiceType",
|
||||||
|
// Value = $"From {old} to {item.ToString()}" + '\n' + ex.Message,
|
||||||
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||||
|
// Type = "catch"
|
||||||
|
//});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
|
|
||||||
return await _invoiceRepo.AddBoolResultAsync(invoice);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ namespace Back.Services
|
|||||||
{
|
{
|
||||||
return await _repoSentTax.Get(w => w.invoice.CompanyID == CompanyID && (w.SentStatus == SentStatus.Successful || w.SentStatus == SentStatus.Send || w.SentStatus == SentStatus.pending)).AnyAsync();
|
return await _repoSentTax.Get(w => w.invoice.CompanyID == CompanyID && (w.SentStatus == SentStatus.Successful || w.SentStatus == SentStatus.Send || w.SentStatus == SentStatus.pending)).AnyAsync();
|
||||||
}
|
}
|
||||||
|
public async Task<bool> ExistSuccessfulorSendorpendingInvoice(Invoice invoice)
|
||||||
|
{
|
||||||
|
return _repoSentTax.Get(w => w.InvoiceType == invoice.invoiceType && w.InvoiceID == invoice.ID &&
|
||||||
|
(w.SentStatus == SentStatus.Successful || w.SentStatus == SentStatus.Send || w.SentStatus == SentStatus.pending)).Any();
|
||||||
|
}
|
||||||
public async Task<bool> CheckingTheCompanyKeyInformation(int CompanyID, string UniqeMemory, string PrivateKey, string EconomicCode)
|
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)
|
return await _repoSentTax.Get(w => (w.invoice.company.UniqeMemory == UniqeMemory || w.invoice.company.PrivateKey == PrivateKey || w.invoice.company.EconomicCode == EconomicCode)
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
|
|||||||
}) ;
|
}) ;
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
|
||||||
|
|
||||||
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
|
||||||
|
|
||||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user