...
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Service">
|
||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Back.Services;
|
||||
using Back.Validations;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Serch;
|
||||
@@ -38,7 +39,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[HttpGet("Get/{ID}")]
|
||||
public async Task<ActionResult<InvoiceGridDTO>?> GetAll(int ID)
|
||||
public async Task<ActionResult<InvoiceDTO>?> GetAll(int ID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
@@ -191,7 +192,7 @@ namespace Back.Controllers
|
||||
return Ok(await _servInvoice.DeleteInvoice(invoice));
|
||||
}
|
||||
[HttpPost("ChangeInvoiceType/{InvoiceID}")]// ok
|
||||
public async Task<ActionResult<int>> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType)
|
||||
public async Task<ActionResult<InvoiceDTO>> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -229,7 +230,7 @@ namespace Back.Controllers
|
||||
|
||||
case InvoiceType.Repair:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||
var result = await _servInvoice.AddInvoice(new Invoice()
|
||||
{
|
||||
|
||||
Title = Invoice.Title,
|
||||
@@ -243,11 +244,13 @@ namespace Back.Controllers
|
||||
BillReference = Invoice.ID,
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID
|
||||
}, false));
|
||||
|
||||
}, false);
|
||||
if (result > 0)
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,result));
|
||||
break;
|
||||
case InvoiceType.BackFrmSale:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||
var result1 = await _servInvoice.AddInvoice(new Invoice()
|
||||
{
|
||||
|
||||
Title = Invoice.Title,
|
||||
@@ -261,7 +264,10 @@ namespace Back.Controllers
|
||||
BillReference = Invoice.ID,
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID
|
||||
}, false));
|
||||
}, false);
|
||||
if (result1 > 0)
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result1));
|
||||
break;
|
||||
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
@@ -286,8 +292,8 @@ namespace Back.Controllers
|
||||
{
|
||||
switch (invoiceType)
|
||||
{
|
||||
case InvoiceType.Sale:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
//case InvoiceType.Sale:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
|
||||
case InvoiceType.CANCEL:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
@@ -320,7 +326,7 @@ namespace Back.Controllers
|
||||
|
||||
case InvoiceType.BackFrmSale:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||
return Ok(await _servInvoice.AddInvoice(new Invoice()
|
||||
var result2 = await _servInvoice.AddInvoice(new Invoice()
|
||||
{
|
||||
|
||||
Title = Invoice.Title,
|
||||
@@ -334,7 +340,10 @@ namespace Back.Controllers
|
||||
BillReference = Invoice.ID,
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID
|
||||
}, false));
|
||||
}, false);
|
||||
if (result2 > 0)
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result2));
|
||||
break;
|
||||
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
@@ -362,23 +371,23 @@ namespace Back.Controllers
|
||||
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()
|
||||
{
|
||||
//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));
|
||||
// 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()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Back.Services
|
||||
{
|
||||
#region AdvancedSearch
|
||||
var invok = _invoiceRepo
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted);
|
||||
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && !w.BillReference.HasValue);
|
||||
|
||||
if (itemSerch.InvoiceID != null)
|
||||
invok = invok.Where(w => w.ID == itemSerch.InvoiceID);
|
||||
@@ -209,7 +209,7 @@ namespace Back.Services
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true)
|
||||
public async Task<InvoiceDTO?> ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true)
|
||||
{
|
||||
string old = invoiceitem.invoiceType.GetEnumDisplayName();
|
||||
invoiceitem.invoiceType = item;
|
||||
@@ -226,8 +226,19 @@ namespace Back.Services
|
||||
UserID = invoiceitem.LastChangeUserID
|
||||
});
|
||||
if (action)
|
||||
return await _invoiceRepo.UpdateAsync(invoiceitem);
|
||||
else return true;
|
||||
{
|
||||
var result = await _invoiceRepo.UpdateAsync(invoiceitem);
|
||||
if (result)
|
||||
{
|
||||
return await GetInvoice(invoiceitem.CompanyID.Value, invoiceitem.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
else return await GetInvoice(invoiceitem.CompanyID.Value, invoiceitem.ID);
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
@@ -249,7 +260,7 @@ namespace Back.Services
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//});
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user