This commit is contained in:
mmrbnjd
2024-05-30 15:08:36 +03:30
parent 85a72bc1ad
commit 579ccf78d6
15 changed files with 1182 additions and 179 deletions

View File

@@ -38,14 +38,15 @@ namespace Back.Controllers
return Ok(await _servInvoice.GetInvoices(user.RolUsers.First().CompanyID, itemSerch)); return Ok(await _servInvoice.GetInvoices(user.RolUsers.First().CompanyID, itemSerch));
} }
[HttpGet("Get/{ID}")] [HttpGet("Get/{ID}/{loaddelete}")]
public async Task<ActionResult<InvoiceDTO>?> GetAll(int ID) public async Task<ActionResult<InvoiceDTO?>> GetAll(int ID,bool loaddelete)
{ {
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value; var UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); 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")] [HttpPost("Add")]
@@ -179,8 +180,7 @@ namespace Back.Controllers
//----Check TaxPayer //----Check TaxPayer
if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice)) if (await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(invoice))
return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"+'\n'+ return BadRequest(new List<string> { "این صورتحساب به سازمان ارسال شده"});
"برای حذف ،صورتحساب را ابطال بزنید"});
//else if (invoice.invoiceType != InvoiceType.Bidding //else if (invoice.invoiceType != InvoiceType.Bidding
// && invoice.invoiceType != InvoiceType.Sale) // && invoice.invoiceType != InvoiceType.Sale)
//{ //{
@@ -192,7 +192,7 @@ namespace Back.Controllers
return Ok(await _servInvoice.DeleteInvoice(invoice)); return Ok(await _servInvoice.DeleteInvoice(invoice));
} }
[HttpPost("ChangeInvoiceType/{InvoiceID}")]// ok [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 //-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); 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); Invoice? Invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, InvoiceID);
if (Invoice == null) return NotFound(); 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); var sent = await _servTaxPayer.ExistSuccessfulorSendorpendingInvoice(Invoice);
Invoice.LastChangeUserID = Convert.ToInt32(UserID); Invoice.LastChangeUserID = Convert.ToInt32(UserID);
if (Invoice.invoiceType == InvoiceType.Bidding) if (Invoice.invoiceType == InvoiceType.Bidding)
{ {
switch (invoiceType) switch (invoiceType)
{ {
case InvoiceType.Sale: case 1:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Sale));
case InvoiceType.CANCEL: case 3:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
//case 0:
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
default: 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 (Invoice.invoiceType == InvoiceType.Sale)
{ {
if (sent) //if (sent)
{ //{
switch (invoiceType) switch (invoiceType)
{ {
case InvoiceType.Cancellation: //case 0:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
case InvoiceType.Repair: case 3:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
case 2:
await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Repair, false);
var result = await _servInvoice.AddInvoice(new Invoice() var result = await _servInvoice.AddInvoice(new Invoice()
{ {
Title = Invoice.Title, Title = Invoice.Title,
Des = Invoice.Des, Des = Invoice.Des,
invoiceType = invoiceType, invoiceType = InvoiceType.Repair,
CustomerID = Invoice.CustomerID, CustomerID = Invoice.CustomerID,
CompanyID = Invoice.CompanyID, CompanyID = Invoice.CompanyID,
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
@@ -243,19 +248,27 @@ namespace Back.Controllers
LastChangeUserID = Convert.ToInt32(UserID), LastChangeUserID = Convert.ToInt32(UserID),
BillReference = Invoice.ID, BillReference = Invoice.ID,
IsDeleted = false, 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); }, false);
if (result > 0) if (result > 0)
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,result)); return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,result));
break; break;
case InvoiceType.BackFrmSale: case 4:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.BackFrmSale, false);
var result1 = await _servInvoice.AddInvoice(new Invoice() var result1 = await _servInvoice.AddInvoice(new Invoice()
{ {
Title = Invoice.Title, Title = Invoice.Title,
Des = Invoice.Des, Des = Invoice.Des,
invoiceType = invoiceType, invoiceType = InvoiceType.BackFrmSale,
CustomerID = Invoice.CustomerID, CustomerID = Invoice.CustomerID,
CompanyID = Invoice.CompanyID, CompanyID = Invoice.CompanyID,
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
@@ -263,75 +276,83 @@ namespace Back.Controllers
LastChangeUserID = Convert.ToInt32(UserID), LastChangeUserID = Convert.ToInt32(UserID),
BillReference = Invoice.ID, BillReference = Invoice.ID,
IsDeleted = false, 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); }, false);
if (result1 > 0) if (result1 > 0)
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result1)); return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result1));
break; break;
default: default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
} }
} //}
else //else
{ //{
switch (invoiceType) // switch (invoiceType)
{ // {
case InvoiceType.CANCEL: // case 0:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
default: // 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.Cancellation) //if (Invoice.invoiceType == InvoiceType.Cancellation)
{ //{
if (!sent) // if (!sent)
{ // {
switch (invoiceType) // switch (invoiceType)
{ // {
//case InvoiceType.Sale: // //case InvoiceType.Sale:
// return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); // // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
case InvoiceType.CANCEL: // case 0:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
default: // default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" }); // return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
} // }
} // }
else return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); // else return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
} //}
if (Invoice.invoiceType == InvoiceType.Repair) 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) switch (invoiceType)
{ {
case InvoiceType.CANCEL: case 3:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
default: case 4:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" }); await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.BackFrmSale, false);
}
}
else
{
switch (invoiceType)
{
case InvoiceType.Cancellation:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType));
case InvoiceType.BackFrmSale:
await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
var result2 = await _servInvoice.AddInvoice(new Invoice() var result2 = await _servInvoice.AddInvoice(new Invoice()
{ {
Title = Invoice.Title, Title = Invoice.Title,
Des = Invoice.Des, Des = Invoice.Des,
invoiceType = invoiceType, invoiceType = InvoiceType.BackFrmSale,
CustomerID = Invoice.CustomerID, CustomerID = Invoice.CustomerID,
CompanyID = Invoice.CompanyID, CompanyID = Invoice.CompanyID,
InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
@@ -339,61 +360,71 @@ namespace Back.Controllers
LastChangeUserID = Convert.ToInt32(UserID), LastChangeUserID = Convert.ToInt32(UserID),
BillReference = Invoice.ID, BillReference = Invoice.ID,
IsDeleted = false, 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); }, false);
if (result2 > 0) if (result2 > 0)
return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result2)); return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result2));
break; break;
default: 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 (Invoice.invoiceType == InvoiceType.BackFrmSale)
{ {
if (!sent) // if (!sent)
{ // {
switch (invoiceType) switch (invoiceType)
{ {
case InvoiceType.CANCEL: //case 0:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.CANCEL));
case 3:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
default: default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست" }); return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست" });
} }
} // }
else //else
{ //{
switch (invoiceType) // switch (invoiceType)
{ // {
case InvoiceType.Cancellation: // case 3:
return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, InvoiceType.Cancellation));
//case InvoiceType.Repair: // //case InvoiceType.Repair:
// await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); // // await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false);
// return Ok(await _servInvoice.AddInvoice(new Invoice() // // return Ok(await _servInvoice.AddInvoice(new Invoice()
// { // // {
// Title = Invoice.Title, // // Title = Invoice.Title,
// Des = Invoice.Des, // // Des = Invoice.Des,
// invoiceType = invoiceType, // // invoiceType = invoiceType,
// CustomerID = Invoice.CustomerID, // // CustomerID = Invoice.CustomerID,
// CompanyID = Invoice.CompanyID, // // CompanyID = Invoice.CompanyID,
// InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), // // InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""),
// InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""), // // InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""),
// LastChangeUserID = Convert.ToInt32(UserID), // // LastChangeUserID = Convert.ToInt32(UserID),
// BillReference = Invoice.ID, // // BillReference = Invoice.ID,
// IsDeleted = false, // // IsDeleted = false,
// PatternID = Invoice.PatternID // // PatternID = Invoice.PatternID
// }, false)); // // }, false));
default: // default:
return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); // return BadRequest(new List<string> { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {((InvoiceType)invoiceType).GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" });
} // }
} //}
} }
@@ -405,5 +436,12 @@ namespace Back.Controllers
{ {
return Ok(await _servTaxPayer.GetPatterns()); 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");
}
} }
} }

View File

@@ -74,10 +74,6 @@ namespace Back.Controllers
var UserID = claim.Value; var UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID)); 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 //-----Get invoice
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, model.invoiceID); 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..." }); 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); var invoiceitem=await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, model.invoiceID, model.item.ID.Value);
if (invoiceitem == null) if (invoiceitem == null)
return BadRequest(new List<string> { "invoice Item notFound..." }); return BadRequest(new List<string> { "invoice Item notFound..." });

File diff suppressed because one or more lines are too long

View File

@@ -20,12 +20,17 @@ namespace Back.Services
_checkPermission = checkPermission; _checkPermission = checkPermission;
} }
public async Task<InvoiceDTO> GetInvoice(int CompanyID, int ID) public async Task<InvoiceDTO?> GetInvoice(int CompanyID, int ID, bool notloaddelete = true)
{ {
#region AdvancedSearch #region AdvancedSearch
var invok = _invoiceRepo var invok = _invoiceRepo
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && w.ID == ID); .Get(w => w.CompanyID == CompanyID && w.ID == ID);
if (notloaddelete)
{
invok = invok
.Where(w => !w.IsDeleted);
}
#endregion #endregion
//----------------------- //-----------------------
@@ -37,7 +42,7 @@ namespace Back.Services
//.Include(inc => inc.pattern) //.Include(inc => inc.pattern)
.Select(s => new InvoiceDTO() .Select(s => new InvoiceDTO()
{ {
IsDeleted=s.IsDeleted,
PatternID = s.PatternID, PatternID = s.PatternID,
PatternTitle = s.pattern.Title, PatternTitle = s.pattern.Title,
CustomerID = s.CustomerID, CustomerID = s.CustomerID,
@@ -92,7 +97,7 @@ namespace Back.Services
{ {
#region AdvancedSearch #region AdvancedSearch
var invok = _invoiceRepo var invok = _invoiceRepo
.Get(w => w.CompanyID == CompanyID && !w.IsDeleted && !w.BillReference.HasValue); .Get(w => w.CompanyID == CompanyID && !w.IsDeleted/* && !w.BillReference.HasValue*/);
if (itemSerch.InvoiceID != null) if (itemSerch.InvoiceID != null)
invok = invok.Where(w => w.ID == itemSerch.InvoiceID); invok = invok.Where(w => w.ID == itemSerch.InvoiceID);
@@ -105,6 +110,9 @@ namespace Back.Services
if (itemSerch.Title != null) if (itemSerch.Title != null)
invok = invok.Where(w => w.Title.Contains(itemSerch.Title)); invok = invok.Where(w => w.Title.Contains(itemSerch.Title));
if (itemSerch.refInvoiceID != null)
invok = invok.Where(w => w.BillReference==itemSerch.refInvoiceID);
//foreach (InputObj item in inputObjs) //foreach (InputObj item in inputObjs)
// invok = invok.Where(ExMethod.GetFunc<Customer>(item.Param, item.Value)); // invok = invok.Where(ExMethod.GetFunc<Customer>(item.Param, item.Value));
@@ -129,7 +137,7 @@ namespace Back.Services
tdis = s.tdis, tdis = s.tdis,
tvam = s.tvam, tvam = s.tvam,
Udate = s.Udate.ShamciToFormatShamci(), Udate = s.Udate.ShamciToFormatShamci(),
BillReference = s.BillReference
}) })
.Paging(itemSerch.PageIndex, itemSerch.PageSize); .Paging(itemSerch.PageIndex, itemSerch.PageSize);
} }
@@ -137,6 +145,11 @@ 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> checkFatherInvoiceByInvoiceID(int CompanyID, int InvoiceID)
{
return await _invoiceRepo.Get(w => w.BillReference == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
} }
public async Task<int> AddInvoice(Invoice invoice, bool calculate = true) public async Task<int> AddInvoice(Invoice invoice, bool calculate = true)
{ {
@@ -147,16 +160,34 @@ namespace Back.Services
{ {
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1")) if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
{ {
var item = await _invoiceRepo.AddAsync(invoice); try
return item.ID; {
var item = await _invoiceRepo.AddAsync(invoice);
return item.ID;
}
catch (Exception ex )
{
return -1;
}
} }
return -1; return -1;
} }
else else
{ {
var item = await _invoiceRepo.AddAsync(invoice); try
return item.ID; {
var item = await _invoiceRepo.AddAsync(invoice);
return item.ID;
}
catch (Exception ex)
{
return -1;
}
} }
} }
@@ -172,6 +203,7 @@ namespace Back.Services
{ {
return await _invoiceRepo return await _invoiceRepo
.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted) .Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted)
.Include(inc=>inc.invoiceDetails)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
} }
public async Task<bool> DeleteInvoice(Invoice item) public async Task<bool> DeleteInvoice(Invoice item)

View File

@@ -23,6 +23,10 @@ namespace Back.Validations
else if (!servInvoice.ExistInvoiceByInvoiceID(model.Item1,model.Item2.ID.Value ).Result) else if (!servInvoice.ExistInvoiceByInvoiceID(model.Item1,model.Item2.ID.Value ).Result)
context.AddFailure("ضورتحساب یافت نشد"); context.AddFailure("ضورتحساب یافت نشد");
else if (servInvoice.checkFatherInvoiceByInvoiceID(model.Item1, model.Item2.ID.Value).Result)
context.AddFailure("این صورتحساب، مرجع چند صورتحساب دیگر می باشد " +'\n'+
"ابتدا آن هارا حذف کنید");
}); });
}); });

View File

@@ -42,7 +42,8 @@ namespace Shared.DTOs
[MaxLength(18)] [MaxLength(18)]
[Display(Name = "مجموع صورتحساب")] [Display(Name = "مجموع صورتحساب")]
public decimal? tbill { get; set; } public decimal? tbill { get; set; }
[Display(Name = "صورتحساب مرجع")]
public int? BillReference { get; set; }
} }
public class InvoiceDTO public class InvoiceDTO
{ {
@@ -76,6 +77,7 @@ namespace Shared.DTOs
[Display(Name = "مجموع صورتحساب")] [Display(Name = "مجموع صورتحساب")]
public decimal? tbill { get; set; } public decimal? tbill { get; set; }
public int? BillReference { get; set; } public int? BillReference { get; set; }
public bool IsDeleted { get; set; }
public ICollection<InvoiceItemDTO> items { get; set; }=new List<InvoiceItemDTO>(); public ICollection<InvoiceItemDTO> items { get; set; }=new List<InvoiceItemDTO>();
public ICollection<InvoicePaymentDTO> payments { get; set; } = new List<InvoicePaymentDTO>(); public ICollection<InvoicePaymentDTO> payments { get; set; } = new List<InvoicePaymentDTO>();
// public ICollection<InvoiceStatusDto> Invoicestatuschanges { get; set; } // public ICollection<InvoiceStatusDto> Invoicestatuschanges { get; set; }

View File

@@ -10,6 +10,7 @@ namespace Shared.DTOs.Serch
{ {
public string? Title { get; set; }// public string? Title { get; set; }//
public int? InvoiceID { get; set; }// public int? InvoiceID { get; set; }//
public int? refInvoiceID { get; set; }//
public int? CustomerID { get; set; } public int? CustomerID { get; set; }
public InvoiceType? invoiceType { get; set; }// public InvoiceType? invoiceType { get; set; }//
public int PageIndex { get; set; } = 1; public int PageIndex { get; set; } = 1;

View File

@@ -10,8 +10,8 @@ namespace Shared.DTOs
//Factor=11, //Factor=11,
//[Display(Name = "قطعی")] //[Display(Name = "قطعی")]
//Final=12, //Final=12,
[Display(Name = "لغو")] //[Display(Name = "لغو")]
CANCEL = 0, //CANCEL = 0,
[Display(Name = "فروش")] [Display(Name = "فروش")]
Sale=1, Sale=1,
[Display(Name = "ابطالی")] [Display(Name = "ابطالی")]

View File

@@ -9,6 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Stimulsoft.Reports.Blazor" Version="2024.2.5" />
<PackageReference Include="Blazor.Bootstrap" Version="2.2.0" /> <PackageReference Include="Blazor.Bootstrap" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" />

View File

@@ -0,0 +1,7 @@
@inherits LayoutComponentBase
<div class="main">
<div class="content px-4">
@Body
</div>
</div>

View File

@@ -49,6 +49,7 @@
@code { @code {
[Parameter] public int InvoiceID { get; set; } [Parameter] public int InvoiceID { get; set; }
[Parameter] public bool IsDeleted { get; set; }
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; } [Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; } [Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
private Modal modal = default!; private Modal modal = default!;
@@ -61,13 +62,17 @@
} }
private async Task OnRowClick(GridRowEventArgs<InvoiceItemDTO> args) private async Task OnRowClick(GridRowEventArgs<InvoiceItemDTO> args)
{ {
var parameters = new Dictionary<string, object>(); if (!IsDeleted)
{
var parameters = new Dictionary<string, object>();
parameters.Add("itemDTO", args.Item); parameters.Add("itemDTO", args.Item);
parameters.Add("InvoiceID", InvoiceID); parameters.Add("InvoiceID", InvoiceID);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack)); parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters); await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
}
} }

View File

@@ -0,0 +1,28 @@
<PageTitle>صورتحساب</PageTitle>
@using Front.Services
@using Stimulsoft.Base
@using Stimulsoft.Report
@using Stimulsoft.Report.Blazor
@inject HttpClientController hc;
@layout EmptyLayout
@page "/InvoiceReport/{InvoiceID:int}"
<StiBlazorViewer Report="@Report" />
@code {
private StiReport Report;
[Parameter] public int InvoiceID { get; set; }
protected async override Task OnParametersSetAsync()
{
//Create empty report object
this.Report = new StiReport();
//Load report template
var reportBytes = await hc._hc.GetByteArrayAsync("Invoice/GetReport");
this.Report.Load(reportBytes);
await base.OnParametersSetAsync();
}
}

View File

@@ -22,6 +22,9 @@
<div class="col-md-1"> <div class="col-md-1">
<input @bind-value="itemsearch.InvoiceID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text"> <input @bind-value="itemsearch.InvoiceID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text">
</div> </div>
<div class="col-md-2">
<input @bind-value="itemsearch.refInvoiceID" placeholder="شناسه مرجع" style="text-align:center;" class="form-control" type="text">
</div>
<div class="col-md-2"> <div class="col-md-2">
<select @bind="ItemSearchInvoicetype" class="form-control" aria-label="Default select example"> <select @bind="ItemSearchInvoicetype" class="form-control" aria-label="Default select example">
<option value="100" style="color: #b5b5b5" selected>نوع صورتحساب...</option> <option value="100" style="color: #b5b5b5" selected>نوع صورتحساب...</option>

View File

@@ -1,6 +1,8 @@
@using Front.Services @using Front.Services
@using Shared.DTOs @using Shared.DTOs
@using Shared @using Shared
@inject HttpClientController hc; @inject HttpClientController hc;
@layout PanelLayout @layout PanelLayout
@inject Fixedvalues fv; @inject Fixedvalues fv;
@@ -10,6 +12,15 @@
<Preload LoadingText="در حال بارگذاری..." /> <Preload LoadingText="در حال بارگذاری..." />
<ConfirmDialog @ref="dialog" /> <ConfirmDialog @ref="dialog" />
<Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" /> <Toasts AutoHide="true" Delay="6000" class="p-3" Messages="messages" Placement="ToastsPlacement.TopRight" />
@if (invoice.IsDeleted)
{
<h1 style="color:red">این صورتحساب حذف شده و در دسترس نمی باشد</h1>
<br />
<hr class="hr" />
}
<form> <form>
@* alert *@ @* alert *@
<div class="row"> <div class="row">
@@ -19,7 +30,7 @@
</Alert> </Alert>
</div> </div>
@if (InvoiceID == 0 || InvoiceID == null ? false : true) @if (InvoiceID == 0 || InvoiceID == null ? false : true && !invoice.IsDeleted)
{ {
<div class="row g-3"> <div class="row g-3">
@@ -27,31 +38,31 @@
@switch (invoice.invoiceType) @switch (invoice.invoiceType)
{ {
case(InvoiceType.Bidding): case(InvoiceType.Bidding):
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Sale)" id="cut"><span>فاکتور</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Sale)" id="cut"><span>فاکتور</span></Button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.CANCEL)" id="sred1"><span>لغو</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred1"><span>ابطال</span></Button>
break; break;
case (InvoiceType.Sale): case (InvoiceType.Sale):
<button class="button" @onclick="() => ChangeStatus(InvoiceType.BackFrmSale)" id="copy"><span>برگشت فروش</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.BackFrmSale)" id="copy"><span>برگشت فروش</span></Button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Repair)" id="paste"><span>اصلاح</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Repair)" id="paste"><span>اصلاح</span></Button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
<button class="button" id="sred1" @onclick="() => ChangeStatus(InvoiceType.CANCEL)"><span>لغو</span></button> @* <Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button> *@
break; break;
case (InvoiceType.BackFrmSale): case (InvoiceType.BackFrmSale):
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.CANCEL)" id="sred1"><span>لغو</span></button> @* <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
break; break;
case (InvoiceType.Repair): case (InvoiceType.Repair):
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button> <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.CANCEL)" id="sred1"><span>لغو</span></button> @* <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
<button class="button" id="copy" @onclick="() => ChangeStatus(InvoiceType.BackFrmSale)"><span>برگشت فروش</span></button> <Button class="button" style="color:white;" id="copy" @onclick="() => ChangeStatus((int)InvoiceType.BackFrmSale)"><span>برگشت فروش</span></Button>
break; break;
case (InvoiceType.Cancellation): @* case (InvoiceType.Cancellation):
<button class="button" id="sred1" @onclick="() => ChangeStatus(InvoiceType.CANCEL)"><span>لغو</span></button> <Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button>
break; break; *@
} }
@@ -163,7 +174,7 @@
<InputText style=" text-align: center;" @bind-Value="invoice.InvoiceDate" type="text" class="form-control" id="inputInvoiceDate" placeholder="تاریخ" /> <InputText style=" text-align: center;" @bind-Value="invoice.InvoiceDate" type="text" class="form-control" id="inputInvoiceDate" placeholder="تاریخ" />
</div> </div>
</div> </div>
@if (InvoiceID == 0 || InvoiceID == null ? false : true) @if (InvoiceID == 0 || InvoiceID == null ? false : true )
{ {
<br /> <hr class="hr" /> <br /> <hr class="hr" />
<div class="row g-3"> <div class="row g-3">
@@ -174,15 +185,18 @@
<div class="form-group col-md-11"> <div class="form-group col-md-11">
@if (InvoiceID.HasValue && invoice.items.Count > 0) @if (InvoiceID.HasValue && invoice.items.Count > 0)
{ {
<LGridInvoiceItem InvoiceID="InvoiceID.Value" OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" /> <LGridInvoiceItem IsDeleted="invoice.IsDeleted" InvoiceID="InvoiceID.Value" OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
} }
</div> </div>
<div class="form-group col-md-1"> <div class="form-group col-md-1">
@if (!invoice.IsDeleted)
{
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
+
</Button>
}
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
+
</Button>
</div> </div>
</div> </div>
@@ -236,35 +250,46 @@
<InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly /> <InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly />
</div> </div>
@* @if (invoice.BillReference.HasValue)
{
<div class="row g-3">
<Button Color="ButtonColor.Link"><NavLink href="InvoiceDetails/@invoice.BillReference.Value">صورتحساب مرجع</NavLink></Button>
</div>
} *@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<br /> <br />
@if (InvoiceID == 0 || InvoiceID == null) @if (!invoice.IsDeleted)
{ {
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button"> @if (InvoiceID == 0 || InvoiceID == null)
جدید {
</Button> <Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
} جدید
else </Button>
{ }
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button"> else
ثبت تغییرات {
</Button> <Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button"> ثبت تغییرات
حذف </Button>
</Button> <Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
حذف
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowReport" Type="ButtonType.Button">
چاپ
</Button>
}
} }
</div> </div>
</div> </div>
<br />
<div class="row g-3">
@if (invoice.BillReference.HasValue)
{
<div class="row g-3">
@{
string Prefence = "InvoiceDetails/" + invoice.BillReference.Value.ToString();
}
<Button Color="ButtonColor.Link"><NavLink href="@Prefence">صورتحساب مرجع</NavLink></Button>
</div>
}
</div>
</form> </form>
@@ -272,6 +297,7 @@
@code { @code {
List<ToastMessage> messages = new List<ToastMessage>(); List<ToastMessage> messages = new List<ToastMessage>();
private ConfirmDialog dialog = default!; private ConfirmDialog dialog = default!;
private Modal modal = default!; private Modal modal = default!;
@@ -288,6 +314,7 @@
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
invoice = new InvoiceDTO(); invoice = new InvoiceDTO();
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -344,15 +371,17 @@
} }
private async Task ChangeStatus(InvoiceType type) private async Task ChangeStatus(int type)
{ {
var rsp = await hc.Post<InvoiceType>($"Invoice/ChangeInvoiceType/{InvoiceID}",type);
var rsp = await hc.Post($"Invoice/ChangeInvoiceType/{InvoiceID}?invoiceType={type}");
if (rsp.IsSuccessStatusCode) if (rsp.IsSuccessStatusCode)
{ {
var resinvoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>(); var resinvoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
if (resinvoice!=null) if (resinvoice!=null)
{ {
invoice = resinvoice; invoice = resinvoice;
InvoiceID = resinvoice.ID;
ShowSuccessAlert("تغییر وضعیت با موفقیت انجام شد"); ShowSuccessAlert("تغییر وضعیت با موفقیت انجام شد");
} }
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
@@ -365,17 +394,30 @@
} }
private async Task ShowReport()
{
if (InvoiceID.HasValue)
{
hc._nav.NavigateTo($"InvoiceReport/{InvoiceID}");
}
}
private async Task LoadData() private async Task LoadData()
{ {
PreloadService.Show(SpinnerColor.Dark); PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}"); var rsp = await hc.Get($"Invoice/Get/{InvoiceID}/{true}");
if (rsp.IsSuccessStatusCode) if (rsp.IsSuccessStatusCode)
{ {
invoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>(); invoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
}
else if(rsp.StatusCode==System.Net.HttpStatusCode.BadRequest)
{
ShowDangerAlert("صورتحساب مرجع یافت نشد");
} }
else else
hc._nav.NavigateTo("/Panel"); {
ShowDangerAlert("خطایی در بارگذاری");
}
PreloadService.Hide(); PreloadService.Hide();
} }
public async Task CallBack(ActionInResultComponent result) public async Task CallBack(ActionInResultComponent result)

View File

@@ -38,6 +38,15 @@ namespace Front.Services
_nav.NavigateTo("/Sign-in/unon"); _nav.NavigateTo("/Sign-in/unon");
return request; return request;
} }
public async Task<HttpResponseMessage> Post(string route)
{
var jsonString = "{\"appid\":1,\"platformid\":1,\"rating\":3}";
var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
var request = await _hc.PostAsync(route, httpContent);
if (request.StatusCode == System.Net.HttpStatusCode.Unauthorized)
_nav.NavigateTo("/Sign-in/unon");
return request;
}
public async Task<HttpResponseMessage> Put<T>(string route, T mode) public async Task<HttpResponseMessage> Put<T>(string route, T mode)
{ {
var request = await _hc.PutAsJsonAsync(route, mode); var request = await _hc.PutAsJsonAsync(route, mode);