commit
This commit is contained in:
parent
f0fd9c882f
commit
27a8a71744
BIN
.vs/OSS/v16/.suo
BIN
.vs/OSS/v16/.suo
Binary file not shown.
|
|
@ -116,6 +116,45 @@ namespace OSS.Controllers
|
||||||
{
|
{
|
||||||
return Request.CreateResponse(DataSourceLoader.Load(myContext.ApplicationManagers.Where(t => t.CompanyEmail == Username && t.EvaluationStatus=="Approved").OrderByDescending(t => t.CreatedDate), loadOptions));
|
return Request.CreateResponse(DataSourceLoader.Load(myContext.ApplicationManagers.Where(t => t.CompanyEmail == Username && t.EvaluationStatus=="Approved").OrderByDescending(t => t.CreatedDate), loadOptions));
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public HttpResponseMessage GetInvoicesByApplicationCode(DataSourceLoadOptions loadOptions, string ProjectCode)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ProjectCode))
|
||||||
|
{
|
||||||
|
return Request.CreateResponse(DataSourceLoader.Load(new List<InvoiceDisplay>(), loadOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query invoices directly from tblInvoice using ApplicationCode (ProjectCode)
|
||||||
|
var invoices = myContext.Database.SqlQuery<InvoiceDisplay>(
|
||||||
|
"SELECT InvoiceID, SubServiceName, Amount, Currency, StartDate, Expiredate, BillItemRefNo, ControlNo, PaymentStatus, ApplicationCode FROM tblInvoice WHERE ApplicationCode = @p0 ORDER BY InvoiceID DESC",
|
||||||
|
new System.Data.SqlClient.SqlParameter("@p0", ProjectCode)).ToList();
|
||||||
|
|
||||||
|
// Convert to anonymous objects for DevExtreme (with null-safe defaults)
|
||||||
|
var invoiceList = invoices.Select(i => new
|
||||||
|
{
|
||||||
|
InvoiceID = i.InvoiceID,
|
||||||
|
SubServiceName = i.SubServiceName ?? "",
|
||||||
|
Amount = i.Amount ?? 0m,
|
||||||
|
Currency = i.Currency ?? "",
|
||||||
|
StartDate = i.StartDate,
|
||||||
|
Expiredate = i.Expiredate,
|
||||||
|
BillItemRefNo = i.BillItemRefNo ?? "",
|
||||||
|
ControlNo = i.ControlNo ?? "",
|
||||||
|
PaymentStatus = i.PaymentStatus ?? false,
|
||||||
|
ApplicationCode = i.ApplicationCode ?? ""
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return Request.CreateResponse(DataSourceLoader.Load(invoiceList, loadOptions));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Log error and return empty list to prevent 500 error
|
||||||
|
System.Diagnostics.Debug.WriteLine("Error loading invoices: " + ex.Message);
|
||||||
|
return Request.CreateResponse(DataSourceLoader.Load(new List<InvoiceDisplay>(), loadOptions));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|
|
||||||
|
|
@ -4076,6 +4076,37 @@ namespace OSS.Controllers
|
||||||
Session["ProjectCode"] = Id;
|
Session["ProjectCode"] = Id;
|
||||||
return RedirectToAction("DisplayPDF");
|
return RedirectToAction("DisplayPDF");
|
||||||
}
|
}
|
||||||
|
public ActionResult DownloadInvoice(long? invoiceId)
|
||||||
|
{
|
||||||
|
if (!invoiceId.HasValue)
|
||||||
|
{
|
||||||
|
TempData["PaymentError"] = "Invoice ID is required.";
|
||||||
|
return RedirectToAction("ApplicationStatus");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get invoice from tblInvoice to get ApplicationCode
|
||||||
|
var invoice = myContext.Database.SqlQuery<dynamic>(
|
||||||
|
"SELECT InvoiceID, ApplicationCode, ApplicationID FROM tblInvoice WHERE InvoiceID = @p0",
|
||||||
|
invoiceId.Value).FirstOrDefault();
|
||||||
|
|
||||||
|
if (invoice == null)
|
||||||
|
{
|
||||||
|
TempData["PaymentError"] = "Invoice not found.";
|
||||||
|
return RedirectToAction("ApplicationStatus");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set ProjectCode in session and redirect to DisplayPDF
|
||||||
|
Session["ProjectCode"] = invoice.ApplicationCode;
|
||||||
|
return RedirectToAction("DisplayPDF");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TempData["PaymentError"] = "Error loading invoice: " + ex.Message;
|
||||||
|
return RedirectToAction("ApplicationStatus");
|
||||||
|
}
|
||||||
|
}
|
||||||
public ActionResult RegenerateTransfer(string Id)
|
public ActionResult RegenerateTransfer(string Id)
|
||||||
{
|
{
|
||||||
Session["ProjectCode"] = Id;
|
Session["ProjectCode"] = Id;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
namespace OSS.Models
|
||||||
|
{
|
||||||
|
public class InvoiceDisplay
|
||||||
|
{
|
||||||
|
public long? InvoiceID { get; set; }
|
||||||
|
public string SubServiceName { get; set; }
|
||||||
|
public decimal? Amount { get; set; }
|
||||||
|
public string Currency { get; set; }
|
||||||
|
public DateTime? StartDate { get; set; }
|
||||||
|
public DateTime? Expiredate { get; set; }
|
||||||
|
public string BillItemRefNo { get; set; }
|
||||||
|
public string ControlNo { get; set; }
|
||||||
|
public bool? PaymentStatus { get; set; }
|
||||||
|
public string ApplicationCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1127,6 +1127,7 @@
|
||||||
<Compile Include="Models\GepgControlNumber.cs" />
|
<Compile Include="Models\GepgControlNumber.cs" />
|
||||||
<Compile Include="Models\gepgCtrlno.cs" />
|
<Compile Include="Models\gepgCtrlno.cs" />
|
||||||
<Compile Include="Models\GetBillViewModel.cs" />
|
<Compile Include="Models\GetBillViewModel.cs" />
|
||||||
|
<Compile Include="Models\InvoiceDisplay.cs" />
|
||||||
<Compile Include="Models\InvestorProfileExternal.cs" />
|
<Compile Include="Models\InvestorProfileExternal.cs" />
|
||||||
<Compile Include="Models\ApplicationManager.cs" />
|
<Compile Include="Models\ApplicationManager.cs" />
|
||||||
<Compile Include="Models\ProjectProfile.cs" />
|
<Compile Include="Models\ProjectProfile.cs" />
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
<a class="btn btn-primary btn-lg mt-2 " href="/NewCOI/">Go back</a>
|
<a class="btn btn-primary btn-lg mt-2 " href="/NewCOI/">Go back</a>
|
||||||
@if (!string.IsNullOrEmpty(projCode))
|
@if (!string.IsNullOrEmpty(projCode))
|
||||||
{
|
{
|
||||||
<a class="btn btn-warning btn-lg mt-2" href="@Url.Action("AdditionalPayment","NewCOI", new { projectCode = projCode })">Pay Additional Amount</a>
|
<a class="btn btn-danger btn-lg mt-2" href="@Url.Action("AdditionalPayment","NewCOI", new { projectCode = projCode })">Pay Additional Amount</a>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -171,6 +171,65 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
|
||||||
|
<div class="widget-content widget-content-area br-6">
|
||||||
|
<h6 class="text-primary">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right-circle"><circle cx="12" cy="12" r="10"></circle><polyline points="12 16 16 12 12 8"></polyline><line x1="8" y1="12" x2="16" y2="12"></line></svg> Invoice List
|
||||||
|
</h6>
|
||||||
|
<hr class="text-primary" />
|
||||||
|
@(Html.DevExtreme().DataGrid<dynamic>()
|
||||||
|
.ID("invoiceListGrid")
|
||||||
|
.DataSource(ds => ds.WebApi()
|
||||||
|
.RouteName("CompanyProfile")
|
||||||
|
.LoadAction("GetInvoicesByApplicationCode")
|
||||||
|
.Key("InvoiceID")
|
||||||
|
.LoadParams(new { ProjectCode = (Session["ProjectCode"] as string ?? string.Empty) })
|
||||||
|
)
|
||||||
|
.RemoteOperations(true)
|
||||||
|
.AllowColumnResizing(true)
|
||||||
|
.ShowRowLines(true)
|
||||||
|
.Columns(columns =>
|
||||||
|
{
|
||||||
|
columns.Add().DataField("InvoiceID").Caption("Invoice ID").Visible(true);
|
||||||
|
columns.Add().DataField("SubServiceName").Caption("Service Name").Visible(true);
|
||||||
|
columns.Add().DataField("Amount").Caption("Amount").Visible(true).Format(Format.Currency);
|
||||||
|
columns.Add().DataField("Currency").Caption("Currency").Visible(true);
|
||||||
|
columns.Add().DataField("StartDate").Caption("Start Date").Visible(true).DataType(GridColumnDataType.Date).Format(Format.ShortDate);
|
||||||
|
columns.Add().DataField("Expiredate").Caption("Expiry Date").Visible(true).DataType(GridColumnDataType.Date).Format(Format.ShortDate);
|
||||||
|
columns.Add().DataField("BillItemRefNo").Caption("Bill Ref No").Visible(true);
|
||||||
|
columns.Add().DataField("ControlNo").Caption("Control No").Visible(true);
|
||||||
|
columns.Add().DataField("PaymentStatus").Caption("Payment Status").Visible(true).CellTemplate(@<text>
|
||||||
|
<% if(data.PaymentStatus == true)
|
||||||
|
{%>
|
||||||
|
<span class="badge badge-success">Paid</span>
|
||||||
|
<% }
|
||||||
|
else
|
||||||
|
{%>
|
||||||
|
<span class="badge badge-warning">Pending</span>
|
||||||
|
<% }
|
||||||
|
%>
|
||||||
|
</text>);
|
||||||
|
columns.Add().Caption("Download").Width(150).CellTemplate(@<text>
|
||||||
|
<% if(data.InvoiceID != null)
|
||||||
|
{%>
|
||||||
|
<a href="@Url.Action("DownloadInvoice", "NewCOI")?invoiceId=<%= data.InvoiceID %>" target="_blank" class="btn btn-outline-primary btn-sm">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg> Download
|
||||||
|
</a>
|
||||||
|
<% }
|
||||||
|
%>
|
||||||
|
</text>);
|
||||||
|
})
|
||||||
|
.SearchPanel(f => f.Visible(true)
|
||||||
|
.SearchVisibleColumnsOnly(true)
|
||||||
|
.HighlightSearchText(true)
|
||||||
|
)
|
||||||
|
.Paging(p => p.PageSize(10))
|
||||||
|
.HeaderFilter(f => f.Visible(true))
|
||||||
|
)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
BIN
bin/OSS.dll
BIN
bin/OSS.dll
Binary file not shown.
BIN
bin/OSS.pdb
BIN
bin/OSS.pdb
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
4e75d7d6e094f6c475400ea8de131765d1699b19
|
c5563d2d9f3011f09d695d963bd339d6e2693d8d
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue