CreateReport
This commit is contained in:
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http.HttpResults;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Shared.DTOs;
|
using Shared.DTOs;
|
||||||
using Shared.DTOs.Serch;
|
using Shared.DTOs.Serch;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Back.Controllers
|
namespace Back.Controllers
|
||||||
{
|
{
|
||||||
@@ -441,11 +442,30 @@ namespace Back.Controllers
|
|||||||
return Ok(await _servTaxPayer.GetPatterns());
|
return Ok(await _servTaxPayer.GetPatterns());
|
||||||
}
|
}
|
||||||
[HttpGet("GetReport/{InvoiceID}")]
|
[HttpGet("GetReport/{InvoiceID}")]
|
||||||
public IActionResult GetReport(int InvoiceID)
|
public async Task<ActionResult<string>> GetReport(int InvoiceID)
|
||||||
{
|
{
|
||||||
var reportPath = $"Reports\\invoice.mrt";
|
string output = "";
|
||||||
var bytes = System.IO.File.ReadAllBytes(reportPath);
|
//-----GetUserAndCompany
|
||||||
return new FileContentResult(bytes, "application/xml");
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
var UserID = claim.Value;
|
||||||
|
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||||
|
|
||||||
|
var CompanyID= user?.RolUsers.First().CompanyID;
|
||||||
|
|
||||||
|
if (await _servInvoice.ExistInvoiceByInvoiceID(CompanyID.Value, InvoiceID))
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
// Start the child process.
|
||||||
|
Process p = new Process();
|
||||||
|
// Redirect the output stream of the child process.
|
||||||
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
p.StartInfo.RedirectStandardOutput = true;
|
||||||
|
p.StartInfo.FileName = "C:\\CreateReport\\CreateReport.exe";
|
||||||
|
p.StartInfo.Arguments = $"{CompanyID} {InvoiceID}";
|
||||||
|
p.Start();
|
||||||
|
output = p.StandardOutput.ReadToEnd();
|
||||||
|
p.WaitForExit();
|
||||||
|
return Ok(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
@using Front.Services
|
@using Front.Services
|
||||||
@using Shared.DTOs
|
@using Shared.DTOs
|
||||||
@using Shared
|
@using Shared
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
@inject HttpClientController hc;
|
@inject HttpClientController hc;
|
||||||
@layout PanelLayout
|
@layout PanelLayout
|
||||||
@@ -22,20 +22,20 @@
|
|||||||
<hr class="hr" />
|
<hr class="hr" />
|
||||||
}
|
}
|
||||||
<form>
|
<form>
|
||||||
@if (InvoiceID.HasValue)
|
@if (InvoiceID.HasValue)
|
||||||
{
|
{
|
||||||
<h4 class="fw-bold py-3 mb-4">
|
<h4 class="fw-bold py-3 mb-4">
|
||||||
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> @invoice?.Title
|
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> @invoice?.Title
|
||||||
</h4>
|
</h4>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<h4 class="fw-bold py-3 mb-4">
|
<h4 class="fw-bold py-3 mb-4">
|
||||||
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> جدید
|
<span class="text-muted fw-light">سرویس ها / صورتحساب /</span> جدید
|
||||||
</h4>
|
</h4>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@* alert *@
|
@* alert *@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||||
@@ -47,11 +47,11 @@
|
|||||||
@if (InvoiceID == 0 || InvoiceID == null ? false : true && !invoice.IsDeleted)
|
@if (InvoiceID == 0 || InvoiceID == null ? false : true && !invoice.IsDeleted)
|
||||||
{
|
{
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
|
|
||||||
<div class="multi-button">
|
<div class="multi-button">
|
||||||
@switch (invoice.invoiceType)
|
@switch (invoice.invoiceType)
|
||||||
{
|
{
|
||||||
case(InvoiceType.Bidding):
|
case (InvoiceType.Bidding):
|
||||||
<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.Sale)" id="cut"><span>فاکتور</span></Button>
|
||||||
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred1"><span>ابطال</span></Button>
|
<Button class="button" style="color:white;" @onclick="() => ChangeStatus((int)InvoiceType.Cancellation)" id="sred1"><span>ابطال</span></Button>
|
||||||
break;
|
break;
|
||||||
@@ -65,32 +65,32 @@
|
|||||||
|
|
||||||
case (InvoiceType.BackFrmSale):
|
case (InvoiceType.BackFrmSale):
|
||||||
<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.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;" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)" id="sred1"><span>لغو</span></Button> *@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (InvoiceType.Repair):
|
case (InvoiceType.Repair):
|
||||||
<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.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;" @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>
|
<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" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button>
|
<Button class="button" style="color:white;" id="sred1" @onclick="() => ChangeStatus((int)InvoiceType.CANCEL)"><span>لغو</span></Button>
|
||||||
break; *@
|
break; *@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
@if (invoice.InvoiceSendTaxs.Count>0)
|
@if (invoice.InvoiceSendTaxs.Count > 0)
|
||||||
{
|
{
|
||||||
if (invoice.InvoiceSendTaxs.Any(a=>a.InvoiceType==invoice.invoiceType
|
if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
|
||||||
&& a.SentStatus==SentStatus.Send))
|
&& a.SentStatus == SentStatus.Send))
|
||||||
{
|
{
|
||||||
SendInvoice = false;
|
SendInvoice = false;
|
||||||
<h6 >این صورتحساب با این وضعیت به سامانه مودیان ارسال شده ،برای اطلاع از وضعیت لطفا تعیین وضعیت کنید</h6>
|
<h6>این صورتحساب با این وضعیت به سامانه مودیان ارسال شده ،برای اطلاع از وضعیت لطفا تعیین وضعیت کنید</h6>
|
||||||
}
|
}
|
||||||
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
|
else if (invoice.InvoiceSendTaxs.Any(a => a.InvoiceType == invoice.invoiceType
|
||||||
&& a.SentStatus == SentStatus.Successful))
|
&& a.SentStatus == SentStatus.Successful))
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
&& (a.SentStatus == SentStatus.pending || a.SentStatus == SentStatus.IN_PROGRESS)))
|
&& (a.SentStatus == SentStatus.pending || a.SentStatus == SentStatus.IN_PROGRESS)))
|
||||||
{
|
{
|
||||||
SendInvoice = false;
|
SendInvoice = false;
|
||||||
<h6 >
|
<h6>
|
||||||
این صورتحساب با این وضعیت به سامانه مودیان ارسال و در حال بررسی می باشد
|
این صورتحساب با این وضعیت به سامانه مودیان ارسال و در حال بررسی می باشد
|
||||||
</h6>
|
</h6>
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
&& (a.SentStatus == SentStatus.NOT_FOUND || a.SentStatus == SentStatus.Unknown)))
|
&& (a.SentStatus == SentStatus.NOT_FOUND || a.SentStatus == SentStatus.Unknown)))
|
||||||
{
|
{
|
||||||
SendInvoice = false;
|
SendInvoice = false;
|
||||||
<h6 >
|
<h6>
|
||||||
این صورتحساب با این وضعیت به سامانه مودیان ارسال شده ولی وضعیت آن مشخص نیست
|
این صورتحساب با این وضعیت به سامانه مودیان ارسال شده ولی وضعیت آن مشخص نیست
|
||||||
</h6>
|
</h6>
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else SendInvoice = true;
|
else SendInvoice = true;
|
||||||
|
|
||||||
<hr class="hr" />
|
<hr class="hr" />
|
||||||
}
|
}
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
@@ -234,7 +234,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">
|
||||||
@@ -256,7 +256,7 @@
|
|||||||
+
|
+
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -284,8 +284,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<hr class="hr" />
|
<hr class="hr" />
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
@@ -311,8 +311,8 @@
|
|||||||
<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>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<br />
|
<br />
|
||||||
@if (!invoice.IsDeleted)
|
@if (!invoice.IsDeleted)
|
||||||
@@ -331,13 +331,13 @@
|
|||||||
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
|
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="ShowConfirmationDeleteAsync" Type="ButtonType.Button">
|
||||||
حذف
|
حذف
|
||||||
</Button>
|
</Button>
|
||||||
@* <Button class="mt-3" Color="ButtonColor.Primary" @onclick="ShowReport" Type="ButtonType.Button">
|
<Button class="mt-3" Color="ButtonColor.Primary" @onclick="ShowReport" Type="ButtonType.Button">
|
||||||
چاپ
|
چاپ
|
||||||
</Button> *@
|
</Button>
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@if (invoice.invoiceType != InvoiceType.Bidding && SendInvoice)
|
@if (invoice.invoiceType != InvoiceType.Bidding && SendInvoice)
|
||||||
{
|
{
|
||||||
@@ -348,19 +348,19 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
@if (invoice.BillReference.HasValue)
|
@if (invoice.BillReference.HasValue)
|
||||||
{
|
{
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
@{
|
@{
|
||||||
string Prefence = "InvoiceDetails/" + invoice.BillReference.Value.ToString();
|
string Prefence = "InvoiceDetails/" + invoice.BillReference.Value.ToString();
|
||||||
}
|
}
|
||||||
<Button Color="ButtonColor.Link"><NavLink href="@Prefence">صورتحساب مرجع</NavLink></Button>
|
<Button Color="ButtonColor.Link"><NavLink href="@Prefence">صورتحساب مرجع</NavLink></Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@@ -450,7 +450,7 @@
|
|||||||
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;
|
InvoiceID = resinvoice.ID;
|
||||||
@@ -470,16 +470,24 @@
|
|||||||
{
|
{
|
||||||
if (InvoiceID.HasValue)
|
if (InvoiceID.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
hc._nav.NavigateTo($"TaxPayerInvoiceItem/{InvoiceID}");
|
hc._nav.NavigateTo($"TaxPayerInvoiceItem/{InvoiceID}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task ShowReport()
|
private async Task ShowReport()
|
||||||
{
|
{
|
||||||
if (InvoiceID.HasValue)
|
var rsp = await hc.Get($"Invoice/GetReport/{InvoiceID}");
|
||||||
|
if (rsp.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
fv.invoice = invoice;
|
var str = await rsp.Content.ReadFromJsonAsync<string>();
|
||||||
hc._nav.NavigateTo($"InvoiceReport/{InvoiceID}");
|
if (string.IsNullOrEmpty(str))
|
||||||
|
ShowDangerAlert("خطایی در ساخت فاکتور");
|
||||||
|
else
|
||||||
|
await DownloadFileFromStream(str, $"{InvoiceID}.pdf");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDangerAlert("خطایی در ساخت فاکتور");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task LoadData()
|
private async Task LoadData()
|
||||||
@@ -488,13 +496,13 @@
|
|||||||
var rsp = await hc.Get($"Invoice/Get/{InvoiceID}/{true}");
|
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)
|
else if (rsp.StatusCode == System.Net.HttpStatusCode.BadRequest)
|
||||||
{
|
{
|
||||||
ShowDangerAlert("صورتحساب مرجع یافت نشد");
|
ShowDangerAlert("صورتحساب مرجع یافت نشد");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -739,4 +747,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//for download
|
||||||
|
private Stream GetFileStream(byte[] bytes)
|
||||||
|
{
|
||||||
|
var fileStream = new MemoryStream(bytes);
|
||||||
|
|
||||||
|
return fileStream;
|
||||||
|
}
|
||||||
|
private async Task DownloadFileFromStream(string Base64, string FileName)
|
||||||
|
{
|
||||||
|
byte[] bytes = System.Convert.FromBase64String(Base64);
|
||||||
|
|
||||||
|
var fileStream = GetFileStream(bytes);
|
||||||
|
// var fileName = "log.bin";
|
||||||
|
|
||||||
|
using var streamRef = new DotNetStreamReference(stream: fileStream);
|
||||||
|
|
||||||
|
await JS.InvokeVoidAsync("downloadFileFromStream", FileName, streamRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<script>
|
||||||
|
window.downloadFileFromStream = async (fileName, contentStreamReference) => {
|
||||||
|
const arrayBuffer = await contentStreamReference.arrayBuffer();
|
||||||
|
const blob = new Blob([arrayBuffer]);
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const anchorElement = document.createElement('a');
|
||||||
|
anchorElement.href = url;
|
||||||
|
anchorElement.download = fileName ?? '';
|
||||||
|
anchorElement.click();
|
||||||
|
anchorElement.remove();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
}
|
}
|
Reference in New Issue
Block a user