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));
}
[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");
}
}
}

View File

@@ -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..." });

File diff suppressed because one or more lines are too long

View File

@@ -20,12 +20,17 @@ namespace Back.Services
_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
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
//-----------------------
@@ -37,7 +42,7 @@ namespace Back.Services
//.Include(inc => inc.pattern)
.Select(s => new InvoiceDTO()
{
IsDeleted=s.IsDeleted,
PatternID = s.PatternID,
PatternTitle = s.pattern.Title,
CustomerID = s.CustomerID,
@@ -92,7 +97,7 @@ namespace Back.Services
{
#region AdvancedSearch
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)
invok = invok.Where(w => w.ID == itemSerch.InvoiceID);
@@ -105,6 +110,9 @@ namespace Back.Services
if (itemSerch.Title != null)
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)
// invok = invok.Where(ExMethod.GetFunc<Customer>(item.Param, item.Value));
@@ -118,7 +126,7 @@ namespace Back.Services
//.Include(inc => inc.pattern)
.Select(s => new InvoiceGridDTO()
{
CustomerID = s.CustomerID,
CustomerName = s.Customer.FullName,
ID = s.ID,
@@ -129,7 +137,7 @@ namespace Back.Services
tdis = s.tdis,
tvam = s.tvam,
Udate = s.Udate.ShamciToFormatShamci(),
BillReference = s.BillReference
})
.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();
}
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)
{
@@ -147,16 +160,34 @@ namespace Back.Services
{
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
{
var item = await _invoiceRepo.AddAsync(invoice);
return item.ID;
try
{
var item = await _invoiceRepo.AddAsync(invoice);
return item.ID;
}
catch (Exception ex )
{
return -1;
}
}
return -1;
}
else
{
var item = await _invoiceRepo.AddAsync(invoice);
return item.ID;
try
{
var item = await _invoiceRepo.AddAsync(invoice);
return item.ID;
}
catch (Exception ex)
{
return -1;
}
}
}
@@ -172,6 +203,7 @@ namespace Back.Services
{
return await _invoiceRepo
.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted)
.Include(inc=>inc.invoiceDetails)
.FirstOrDefaultAsync();
}
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)
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)]
[Display(Name = "مجموع صورتحساب")]
public decimal? tbill { get; set; }
[Display(Name = "صورتحساب مرجع")]
public int? BillReference { get; set; }
}
public class InvoiceDTO
{
@@ -76,6 +77,7 @@ namespace Shared.DTOs
[Display(Name = "مجموع صورتحساب")]
public decimal? tbill { get; set; }
public int? BillReference { get; set; }
public bool IsDeleted { get; set; }
public ICollection<InvoiceItemDTO> items { get; set; }=new List<InvoiceItemDTO>();
public ICollection<InvoicePaymentDTO> payments { get; set; } = new List<InvoicePaymentDTO>();
// public ICollection<InvoiceStatusDto> Invoicestatuschanges { get; set; }

View File

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

View File

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

View File

@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Stimulsoft.Reports.Blazor" Version="2024.2.5" />
<PackageReference Include="Blazor.Bootstrap" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
<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 {
[Parameter] public int InvoiceID { get; set; }
[Parameter] public bool IsDeleted { get; set; }
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
private Modal modal = default!;
@@ -61,14 +62,18 @@
}
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("InvoiceID", InvoiceID);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
parameters.Add("itemDTO", args.Item);
parameters.Add("InvoiceID", InvoiceID);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
}
}
public async Task CallBack(ActionInResultComponent result)

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">
<input @bind-value="itemsearch.InvoiceID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text">
</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">
<select @bind="ItemSearchInvoicetype" class="form-control" aria-label="Default select example">
<option value="100" style="color: #b5b5b5" selected>نوع صورتحساب...</option>

View File

@@ -1,6 +1,8 @@
@using Front.Services
@using Shared.DTOs
@using Shared
@inject HttpClientController hc;
@layout PanelLayout
@inject Fixedvalues fv;
@@ -10,6 +12,15 @@
<Preload LoadingText="در حال بارگذاری..." />
<ConfirmDialog @ref="dialog" />
<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>
@* alert *@
<div class="row">
@@ -19,7 +30,7 @@
</Alert>
</div>
@if (InvoiceID == 0 || InvoiceID == null ? false : true)
@if (InvoiceID == 0 || InvoiceID == null ? false : true && !invoice.IsDeleted)
{
<div class="row g-3">
@@ -27,31 +38,31 @@
@switch (invoice.invoiceType)
{
case(InvoiceType.Bidding):
<button class="button" @onclick="() => ChangeStatus(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.Sale)" id="cut"><span>فاکتور</span></Button>
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred1"><span>ابطال</span></Button>
break;
case (InvoiceType.Sale):
<button class="button" @onclick="() => ChangeStatus(InvoiceType.BackFrmSale)" id="copy"><span>برگشت فروش</span></button>
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Repair)" id="paste"><span>اصلاح</span></button>
<button class="button" @onclick="() => ChangeStatus(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;" @onclick="() => ChangeStatus((int)InvoiceType.BackFrmSale)" id="copy"><span>برگشت فروش</span></Button>
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Repair)" id="paste"><span>اصلاح</span></Button>
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
@* <Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button> *@
break;
case (InvoiceType.BackFrmSale):
<button class="button" @onclick="() => ChangeStatus(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.Cancellation)" id="sred"><span>ابطال</span></Button>
@* <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
break;
case (InvoiceType.Repair):
<button class="button" @onclick="() => ChangeStatus(InvoiceType.Cancellation)" id="sred"><span>ابطال</span></button>
<button class="button" @onclick="() => ChangeStatus(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;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred"><span>ابطال</span></Button>
@* <Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
<Button class="button" style="color:white;" id="copy" @onclick="() => ChangeStatus((int)InvoiceType.BackFrmSale)"><span>برگشت فروش</span></Button>
break;
case (InvoiceType.Cancellation):
<button class="button" id="sred1" @onclick="() => ChangeStatus(InvoiceType.CANCEL)"><span>لغو</span></button>
break;
@* case (InvoiceType.Cancellation):
<Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button>
break; *@
}
@@ -163,7 +174,7 @@
<InputText style=" text-align: center;" @bind-Value="invoice.InvoiceDate" type="text" class="form-control" id="inputInvoiceDate" placeholder="تاریخ" />
</div>
</div>
@if (InvoiceID == 0 || InvoiceID == null ? false : true)
@if (InvoiceID == 0 || InvoiceID == null ? false : true )
{
<br /> <hr class="hr" />
<div class="row g-3">
@@ -174,15 +185,18 @@
<div class="form-group col-md-11">
@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 class="form-group col-md-1">
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
+
</Button>
@if (!invoice.IsDeleted)
{
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
+
</Button>
}
</div>
</div>
@@ -236,35 +250,46 @@
<InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly />
</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">
<br />
@if (InvoiceID == 0 || InvoiceID == null)
@if (!invoice.IsDeleted)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
جدید
</Button>
}
else
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
ثبت تغییرات
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
حذف
</Button>
@if (InvoiceID == 0 || InvoiceID == null)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
جدید
</Button>
}
else
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.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>
<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>
@@ -272,6 +297,7 @@
@code {
List<ToastMessage> messages = new List<ToastMessage>();
private ConfirmDialog dialog = default!;
private Modal modal = default!;
@@ -285,9 +311,10 @@
public List<ForCustomerSearch>? Cus { get; set; }
public List<IdName<int>>? Patterns { get; set; }
public InvoiceDTO? invoice { get; set; }
protected override async Task OnInitializedAsync()
{
invoice = new InvoiceDTO();
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)
{
var resinvoice = await rsp.Content.ReadFromJsonAsync<InvoiceDTO>();
if (resinvoice!=null)
{
invoice = resinvoice;
InvoiceID = resinvoice.ID;
ShowSuccessAlert("تغییر وضعیت با موفقیت انجام شد");
}
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
@@ -362,20 +391,33 @@
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
private async Task ShowReport()
{
if (InvoiceID.HasValue)
{
hc._nav.NavigateTo($"InvoiceReport/{InvoiceID}");
}
}
private async Task LoadData()
{
PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}");
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}/{true}");
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
hc._nav.NavigateTo("/Panel");
{
ShowDangerAlert("خطایی در بارگذاری");
}
PreloadService.Hide();
}
public async Task CallBack(ActionInResultComponent result)

View File

@@ -38,6 +38,15 @@ namespace Front.Services
_nav.NavigateTo("/Sign-in/unon");
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)
{
var request = await _hc.PutAsJsonAsync(route, mode);