...
This commit is contained in:
@@ -38,14 +38,15 @@ namespace Back.Controllers
|
||||
return Ok(await _servInvoice.GetInvoices(user.RolUsers.First().CompanyID, itemSerch));
|
||||
|
||||
}
|
||||
[HttpGet("Get/{ID}")]
|
||||
public async Task<ActionResult<InvoiceDTO>?> GetAll(int ID)
|
||||
[HttpGet("Get/{ID}/{loaddelete}")]
|
||||
public async Task<ActionResult<InvoiceDTO?>> GetAll(int ID,bool loaddelete)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var result = await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, ID,!loaddelete);
|
||||
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, ID));
|
||||
return result==null ? BadRequest() : Ok(result);
|
||||
|
||||
}
|
||||
[HttpPost("Add")]
|
||||
@@ -179,8 +180,7 @@ namespace Back.Controllers
|
||||
|
||||
//----Check TaxPayer
|
||||
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice))
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"برای حذف ،صورتحساب را ابطال بزنید"});
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"});
|
||||
//else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
// && invoice.invoiceType != InvoiceType.Sale)
|
||||
//{
|
||||
@@ -192,7 +192,7 @@ namespace Back.Controllers
|
||||
return Ok(await _servInvoice.DeleteInvoice(invoice));
|
||||
}
|
||||
[HttpPost("ChangeInvoiceType/{InvoiceID}")]// ok
|
||||
public async Task<ActionResult<InvoiceDTO>> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType)
|
||||
public async Task<ActionResult<InvoiceDTO>> ChangeInvoiceType(int InvoiceID, int invoiceType)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -202,40 +202,45 @@ namespace Back.Controllers
|
||||
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> { "این صورتحساب لغو شده" });
|
||||
if (Invoice.invoiceType == InvoiceType.Cancellation) 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 1:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Sale));
|
||||
|
||||
case InvoiceType.CANCEL:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
case 3:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
//case 0:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
|
||||
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
}
|
||||
}
|
||||
if (Invoice.invoiceType == InvoiceType.Sale)
|
||||
{
|
||||
if (sent)
|
||||
{
|
||||
//if (sent)
|
||||
//{
|
||||
switch (invoiceType)
|
||||
{
|
||||
case InvoiceType.Cancellation:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
//case 0:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
|
||||
|
||||
case InvoiceType.Repair:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||
case 3:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
|
||||
case 2:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Repair, false);
|
||||
var result = await _servInvoice.AddInvoice(new Invoice()
|
||||
{
|
||||
|
||||
Title = Invoice.Title,
|
||||
Des = Invoice.Des,
|
||||
invoiceType = invoiceType,
|
||||
invoiceType = InvoiceType.Repair,
|
||||
CustomerID = Invoice.CustomerID,
|
||||
CompanyID = Invoice.CompanyID,
|
||||
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||
@@ -243,19 +248,27 @@ namespace Back.Controllers
|
||||
LastChangeUserID = Convert.ToInt32(UserID),
|
||||
BillReference = Invoice.ID,
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID
|
||||
PatternID = Invoice.PatternID,
|
||||
invoiceDetails=Invoice.invoiceDetails.Select(s=>new InvoiceItem
|
||||
{
|
||||
CODID=s.CODID,
|
||||
am=s.am,
|
||||
fee=s.fee,
|
||||
dis=s.dis,
|
||||
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result > 0)
|
||||
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,result));
|
||||
break;
|
||||
case InvoiceType.BackFrmSale:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
|
||||
case 4:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.BackFrmSale, false);
|
||||
var result1 = await _servInvoice.AddInvoice(new Invoice()
|
||||
{
|
||||
|
||||
Title = Invoice.Title,
|
||||
Des = Invoice.Des,
|
||||
invoiceType = invoiceType,
|
||||
invoiceType = InvoiceType.BackFrmSale,
|
||||
CustomerID = Invoice.CustomerID,
|
||||
CompanyID = Invoice.CompanyID,
|
||||
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||
@@ -263,75 +276,83 @@ namespace Back.Controllers
|
||||
LastChangeUserID = Convert.ToInt32(UserID),
|
||||
BillReference = Invoice.ID,
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID
|
||||
PatternID = Invoice.PatternID,
|
||||
invoiceDetails = Invoice.invoiceDetails.Select(s => new InvoiceItem
|
||||
{
|
||||
CODID = s.CODID,
|
||||
am = s.am,
|
||||
fee = s.fee,
|
||||
dis = s.dis,
|
||||
|
||||
}).ToList()
|
||||
}, 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()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (invoiceType)
|
||||
{
|
||||
case InvoiceType.CANCEL:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// switch (invoiceType)
|
||||
// {
|
||||
// case 0:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
|
||||
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
}
|
||||
// default:
|
||||
// return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
}
|
||||
if (Invoice.invoiceType == InvoiceType.Cancellation)
|
||||
{
|
||||
if (!sent)
|
||||
{
|
||||
switch (invoiceType)
|
||||
{
|
||||
//case InvoiceType.Sale:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
//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));
|
||||
// case 0:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
|
||||
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
}
|
||||
}
|
||||
else return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
}
|
||||
// default:
|
||||
// return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
// }
|
||||
// }
|
||||
// else return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
//}
|
||||
if (Invoice.invoiceType == InvoiceType.Repair)
|
||||
{
|
||||
if (!sent)
|
||||
{
|
||||
//if (!sent)
|
||||
//{
|
||||
// switch (invoiceType)
|
||||
// {
|
||||
// case 0:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
|
||||
|
||||
// default:
|
||||
// return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
switch (invoiceType)
|
||||
{
|
||||
case InvoiceType.CANCEL:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
case 3:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
|
||||
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);
|
||||
case 4:
|
||||
await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.BackFrmSale, false);
|
||||
var result2 = await _servInvoice.AddInvoice(new Invoice()
|
||||
{
|
||||
|
||||
Title = Invoice.Title,
|
||||
Des = Invoice.Des,
|
||||
invoiceType = invoiceType,
|
||||
invoiceType = InvoiceType.BackFrmSale,
|
||||
CustomerID = Invoice.CustomerID,
|
||||
CompanyID = Invoice.CompanyID,
|
||||
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
|
||||
@@ -339,61 +360,71 @@ namespace Back.Controllers
|
||||
LastChangeUserID = Convert.ToInt32(UserID),
|
||||
BillReference = Invoice.ID,
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID
|
||||
PatternID = Invoice.PatternID,
|
||||
invoiceDetails=Invoice.invoiceDetails.Select(s => new InvoiceItem
|
||||
{
|
||||
CODID = s.CODID,
|
||||
am = s.am,
|
||||
fee = s.fee,
|
||||
dis = s.dis,
|
||||
|
||||
}).ToList()
|
||||
}, 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()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
if (Invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
{
|
||||
if (!sent)
|
||||
{
|
||||
// if (!sent)
|
||||
// {
|
||||
switch (invoiceType)
|
||||
{
|
||||
case InvoiceType.CANCEL:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
//case 0:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
|
||||
|
||||
case 3:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
default:
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (invoiceType)
|
||||
{
|
||||
case InvoiceType.Cancellation:
|
||||
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
|
||||
// }
|
||||
//else
|
||||
//{
|
||||
// switch (invoiceType)
|
||||
// {
|
||||
// case 3:
|
||||
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
|
||||
|
||||
//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()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
// default:
|
||||
// return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -405,5 +436,12 @@ namespace Back.Controllers
|
||||
{
|
||||
return Ok(await _servTaxPayer.GetPatterns());
|
||||
}
|
||||
[HttpGet("GetReport")]
|
||||
public IActionResult GetReport()
|
||||
{
|
||||
var reportPath = $"Reports\\TwoSimpleLists.mrt";
|
||||
var bytes = System.IO.File.ReadAllBytes(reportPath);
|
||||
return new FileContentResult(bytes, "application/xml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,10 +74,6 @@ namespace Back.Controllers
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.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, model.invoiceID);
|
||||
@@ -85,6 +81,23 @@ namespace Back.Controllers
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
|
||||
|
||||
//-----Validaton
|
||||
var resultValidationmodel = await _validationInvoiceItem.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, model.invoiceID, model.item, eActionValidation.update));
|
||||
if (!resultValidationmodel.IsValid)
|
||||
{
|
||||
if (invoice.invoiceType != InvoiceType.BackFrmSale || (invoice.invoiceType != InvoiceType.BackFrmSale
|
||||
&& resultValidationmodel.Errors.Count > 1))
|
||||
{
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var invoiceitem=await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, model.invoiceID, model.item.ID.Value);
|
||||
if (invoiceitem == null)
|
||||
return BadRequest(new List<string> { "invoice Item notFound..." });
|
||||
|
Reference in New Issue
Block a user