...
This commit is contained in:
@@ -48,7 +48,7 @@ namespace Back.Controllers
|
||||
[HttpPost("Add")]
|
||||
public async Task<ActionResult<int>> Add([FromBody] NUInvoiceDTO item)
|
||||
{
|
||||
if(string.IsNullOrEmpty(item.InvoiceDate))
|
||||
if (string.IsNullOrEmpty(item.InvoiceDate))
|
||||
item.InvoiceDate = DateTime.Now.ConvertMiladiToShamsi();
|
||||
|
||||
if (string.IsNullOrEmpty(item.InvoicIssueDate))
|
||||
@@ -114,7 +114,7 @@ namespace Back.Controllers
|
||||
return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList());
|
||||
|
||||
//-----Get invoice
|
||||
Invoice invoice =await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID,item.ID.Value);
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, item.ID.Value);
|
||||
if (invoice == null)
|
||||
return BadRequest(new List<string> { "invoice notFound..." });
|
||||
|
||||
@@ -124,11 +124,17 @@ namespace Back.Controllers
|
||||
//----Check TaxPayer
|
||||
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice))
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"برای ویرایش ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
|
||||
else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
&& invoice.invoiceType != InvoiceType.Sale)
|
||||
"برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
|
||||
else if (invoice.invoiceType != InvoiceType.BackFrmSale)
|
||||
{
|
||||
return BadRequest(new List<string> { $"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود" });
|
||||
return BadRequest(new List<string>
|
||||
{ "صورتحساب در وضعیت برگشت از فروش نمی تواند ویرایش شود" });
|
||||
}
|
||||
else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
&& invoice.invoiceType != InvoiceType.Sale && invoice.invoiceType != InvoiceType.Repair)
|
||||
{
|
||||
return BadRequest(new List<string> { $"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود"+'\n'+
|
||||
$"فقط در حالت پیش نویس ، فاکتور و اصلاح (که به سازمان ارسال نشده باشد) میتوان سند را ویرایش کرد" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +146,7 @@ namespace Back.Controllers
|
||||
|
||||
invoice.PatternID = item.PatternID;
|
||||
|
||||
if(item.CustomerID > 0)
|
||||
if (item.CustomerID > 0)
|
||||
invoice.CustomerID = item.CustomerID;
|
||||
|
||||
if (!string.IsNullOrEmpty(item.InvoicIssueDate))
|
||||
@@ -163,7 +169,7 @@ namespace Back.Controllers
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
//-----Get invoice
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID,ID);
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, ID);
|
||||
if (invoice == null)
|
||||
return NotFound();
|
||||
|
||||
@@ -171,12 +177,12 @@ namespace Back.Controllers
|
||||
//----Check TaxPayer
|
||||
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice))
|
||||
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"برای ویرایش ،صورتحساب را ابطال/اصلاح یا برگشت بزنید"});
|
||||
else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
&& invoice.invoiceType != InvoiceType.Sale)
|
||||
{
|
||||
return BadRequest(new List<string> { $"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود" });
|
||||
}
|
||||
"برای حذف ،صورتحساب را ابطال بزنید"});
|
||||
//else if (invoice.invoiceType != InvoiceType.Bidding
|
||||
// && invoice.invoiceType != InvoiceType.Sale)
|
||||
//{
|
||||
// return BadRequest(new List<string> { $"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود" });
|
||||
//}
|
||||
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
//----Update and sendResult
|
||||
@@ -190,7 +196,7 @@ namespace Back.Controllers
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
|
||||
Invoice? Invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID,InvoiceID);
|
||||
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> { "این صورتحساب لغو شده" });
|
||||
|
@@ -86,12 +86,20 @@ namespace Back.Controllers
|
||||
if (invoiceitem == null)
|
||||
return BadRequest(new List<string> { "invoice Item notFound..." });
|
||||
|
||||
if (invoice.invoiceType==InvoiceType.BackFrmSale && invoiceitem.am < model.am)
|
||||
return BadRequest(new List<string> { "در حالت برگشت از فروش تعداد آیتم فقط میتواند کاهشی باشد" });
|
||||
|
||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||
|
||||
if (invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
invoiceitem.am = model.am;
|
||||
else
|
||||
{
|
||||
invoiceitem.am = model.am;
|
||||
invoiceitem.fee = model.fee;
|
||||
invoiceitem.dis = model.dis;
|
||||
invoiceitem.CODID = model.CODID;
|
||||
}
|
||||
|
||||
if (await _servInvoice.UpdateInvoice(invoice))
|
||||
return Ok(await _servInvoiceItem.Update(invoiceitem));
|
||||
@@ -101,7 +109,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[HttpDelete("DeleteItem/{invoiceID}/{invoiceItemID}")]
|
||||
public async Task<ActionResult> UpdateItem([FromRoute] int invoiceID, [FromRoute] int invoiceItemID)
|
||||
public async Task<ActionResult> DeleteItem([FromRoute] int invoiceID, [FromRoute] int invoiceItemID)
|
||||
{
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
|
@@ -10,6 +10,10 @@ namespace Back.Validations
|
||||
{
|
||||
public AUInvoiceItemValidation(servInvoice servInvoice,ServCOD servCOD, servTaxPayer servTaxPayer, servInvoiceItem servInvoiceItem)
|
||||
{
|
||||
When(m => m.Item4 == eActionValidation.delete || m.Item4 == eActionValidation.add, () =>
|
||||
{
|
||||
|
||||
});
|
||||
When(m => m.Item4 == eActionValidation.update, () =>
|
||||
{
|
||||
RuleFor(r => r)
|
||||
@@ -65,15 +69,21 @@ namespace Back.Validations
|
||||
var invoice = servInvoice.GetInvoiceByInvoiceID(model.Item1,model.Item2).Result;
|
||||
if (invoice==null)
|
||||
context.AddFailure("صورتحساب یافت نشد");
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
if ( servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice).Result)
|
||||
context.AddFailure("این صورتحساب به سازمان ارسال شده"+'\n'+
|
||||
"برای تغییر ،صورتحساب را ابطال/اصلاح یا برگشت بزنید");
|
||||
else if ((model.Item4 == eActionValidation.add || model.Item4 == eActionValidation.delete)
|
||||
&& invoice.invoiceType == InvoiceType.BackFrmSale)
|
||||
context.AddFailure("آیتم های صورتحساب در وضعیت برگشت از فروش نمی تواند اضافه یا کم شود");
|
||||
else if(invoice.invoiceType!=InvoiceType.Bidding
|
||||
&& invoice.invoiceType != InvoiceType.Sale)
|
||||
&& invoice.invoiceType != InvoiceType.Sale && invoice.invoiceType != InvoiceType.Repair)
|
||||
{
|
||||
context.AddFailure($"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود");
|
||||
context.AddFailure($"صورتحساب در حالت {invoice.invoiceType.GetEnumDisplayName()} نمی تواند ویرایش شود" +'\n'+
|
||||
$"فقط در حالت پیش نویس ، فاکتور و اصلاح (که به سازمان ارسال نشده باشد) میتوان سند را ویرایش کرد");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user