commit
This commit is contained in:
parent
4b36f5e995
commit
535b5f4732
BIN
.vs/OSS/v16/.suo
BIN
.vs/OSS/v16/.suo
Binary file not shown.
|
|
@ -21,6 +21,7 @@ using System.Data.Entity.Migrations;
|
||||||
using System.Web.WebPages;
|
using System.Web.WebPages;
|
||||||
using System.Data.Entity.Validation;
|
using System.Data.Entity.Validation;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
namespace OSS.Controllers
|
namespace OSS.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -2266,14 +2267,22 @@ namespace OSS.Controllers
|
||||||
return RedirectToAction("Payment");
|
return RedirectToAction("Payment");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if additional invoice already exists in tblInvoice
|
long? existingInvoiceId = null;
|
||||||
var existingInvoiceId = myContext.Database.SqlQuery<long?>(
|
try
|
||||||
|
{
|
||||||
|
existingInvoiceId = myContext.Database.SqlQuery<long?>(
|
||||||
"SELECT TOP 1 InvoiceID FROM tblInvoice WHERE ApplicationCode = @p0 AND SubServiceName LIKE 'Additional_Amount%' ORDER BY InvoiceID DESC",
|
"SELECT TOP 1 InvoiceID FROM tblInvoice WHERE ApplicationCode = @p0 AND SubServiceName LIKE 'Additional_Amount%' ORDER BY InvoiceID DESC",
|
||||||
code).FirstOrDefault();
|
code).FirstOrDefault();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Continue to create new invoice
|
||||||
|
}
|
||||||
|
|
||||||
if (existingInvoiceId.HasValue)
|
if (existingInvoiceId.HasValue)
|
||||||
{
|
{
|
||||||
// Get the existing invoice details
|
try
|
||||||
|
{
|
||||||
var invoiceDetails = myContext.Database.SqlQuery<dynamic>(
|
var invoiceDetails = myContext.Database.SqlQuery<dynamic>(
|
||||||
"SELECT Amount, Currency FROM tblInvoice WHERE InvoiceID = @p0",
|
"SELECT Amount, Currency FROM tblInvoice WHERE InvoiceID = @p0",
|
||||||
existingInvoiceId.Value).FirstOrDefault();
|
existingInvoiceId.Value).FirstOrDefault();
|
||||||
|
|
@ -2286,42 +2295,57 @@ namespace OSS.Controllers
|
||||||
Session["AmountinWords"] = CurrencyUtils.ToWords(Convert.ToDecimal(invoiceDetails.Amount)) + " " + currency;
|
Session["AmountinWords"] = CurrencyUtils.ToWords(Convert.ToDecimal(invoiceDetails.Amount)) + " " + currency;
|
||||||
}
|
}
|
||||||
ViewBag.HideAdditionalButton = true;
|
ViewBag.HideAdditionalButton = true;
|
||||||
|
ViewBag.HideInvoiceGrid = true;
|
||||||
TempData["HidePaidInvoices"] = true;
|
TempData["HidePaidInvoices"] = true;
|
||||||
TempData["AdditionalContext"] = true;
|
TempData["AdditionalContext"] = true;
|
||||||
return View("Payment");
|
return View("Payment");
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TempData["PaymentError"] = "Error retrieving existing invoice: " + ex.Message;
|
||||||
|
EnsurePaymentSessionDefaults("TZS");
|
||||||
|
return RedirectToAction("Payment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate BillItemRefNo (using timestamp and project code)
|
|
||||||
string billItemRefNo = "BILL-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + code;
|
string billItemRefNo = "BILL-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + code;
|
||||||
|
|
||||||
// Determine ServiceTypeID (default to 1, adjust if needed based on business logic)
|
|
||||||
int serviceTypeID = 1;
|
int serviceTypeID = 1;
|
||||||
|
|
||||||
// Insert directly into tblInvoice using the parent application details
|
|
||||||
string sql = @"
|
string sql = @"
|
||||||
INSERT INTO [dbo].[tblInvoice]
|
INSERT INTO [dbo].[tblInvoice]
|
||||||
([FullName],[PhoneNo],[GFSCode],[BillItemRefNo],[SubServiceName],[Amount],FrontUserId,ApplicationID,StartDate,Expiredate,ServiceTypeID,ApplicationCode,[Currency],[TIN_No])
|
([FullName],[PhoneNo],[GFSCode],[BillItemRefNo],[SubServiceName],[Amount],FrontUserId,ApplicationID,StartDate,Expiredate,ServiceTypeID,ApplicationCode,[Currency],[TIN_No])
|
||||||
VALUES
|
VALUES
|
||||||
(@FullName,@PhoneNo,@GFSCode,@BillItemRefNo,@SubServiceName,@Amount,@FrontUserId,@ApplicationID,GETDATE(),DATEADD(day,30,GETDATE()),@ServiceTypeID,@ApplicationCode,@Currency,@TIN_No)";
|
(@FullName,@PhoneNo,@GFSCode,@BillItemRefNo,@SubServiceName,@Amount,@FrontUserId,@ApplicationID,GETDATE(),DATEADD(day,30,GETDATE()),@ServiceTypeID,@ApplicationCode,@Currency,@TIN_No)";
|
||||||
|
|
||||||
int rowsAffected = myContext.Database.ExecuteSqlCommand(sql,
|
try
|
||||||
new SqlParameter("@FullName", (object)parentApplication.FullName ?? DBNull.Value),
|
{
|
||||||
new SqlParameter("@PhoneNo", (object)parentApplication.MobileNo ?? DBNull.Value),
|
var parameters = new SqlParameter[]
|
||||||
new SqlParameter("@GFSCode", (object)gfsCode ?? DBNull.Value),
|
{
|
||||||
new SqlParameter("@BillItemRefNo", (object)billItemRefNo ?? DBNull.Value),
|
new SqlParameter("@FullName", SqlDbType.NVarChar, -1) { Value = (object)parentApplication.FullName ?? DBNull.Value },
|
||||||
new SqlParameter("@SubServiceName", (object)"Additional_Amount" ?? DBNull.Value),
|
new SqlParameter("@PhoneNo", SqlDbType.NVarChar, -1) { Value = (object)parentApplication.MobileNo ?? DBNull.Value },
|
||||||
new SqlParameter("@Amount", addAmount),
|
new SqlParameter("@GFSCode", SqlDbType.NVarChar, 50) { Value = (object)gfsCode ?? DBNull.Value },
|
||||||
new SqlParameter("@FrontUserId", (object)username ?? DBNull.Value),
|
new SqlParameter("@BillItemRefNo", SqlDbType.NVarChar, 50) { Value = (object)billItemRefNo ?? DBNull.Value },
|
||||||
new SqlParameter("@ApplicationID", (object)parentApplication.ApplicationID ?? DBNull.Value),
|
new SqlParameter("@SubServiceName", SqlDbType.VarChar, -1) { Value = "Additional_Amount" },
|
||||||
new SqlParameter("@ServiceTypeID", serviceTypeID),
|
new SqlParameter("@Amount", SqlDbType.Decimal) { Value = addAmount, Precision = 18, Scale = 2 },
|
||||||
new SqlParameter("@ApplicationCode", (object)code ?? DBNull.Value),
|
new SqlParameter("@FrontUserId", SqlDbType.BigInt) { Value = DBNull.Value },
|
||||||
new SqlParameter("@Currency", "TZS"),
|
new SqlParameter("@ApplicationID", SqlDbType.BigInt) { Value = parentApplication.ApplicationID },
|
||||||
new SqlParameter("@TIN_No", (object)parentApplication.CompanyTIN ?? DBNull.Value)
|
new SqlParameter("@ServiceTypeID", SqlDbType.BigInt) { Value = (long)serviceTypeID },
|
||||||
);
|
new SqlParameter("@ApplicationCode", SqlDbType.NVarChar, -1) { Value = (object)code ?? DBNull.Value },
|
||||||
|
new SqlParameter("@Currency", SqlDbType.VarChar, 10) { Value = "TZS" },
|
||||||
|
new SqlParameter("@TIN_No", SqlDbType.NVarChar, -1) { Value = (object)parentApplication.CompanyTIN ?? DBNull.Value }
|
||||||
|
};
|
||||||
|
|
||||||
|
int rowsAffected = myContext.Database.ExecuteSqlCommand(sql, parameters);
|
||||||
if (rowsAffected <= 0)
|
if (rowsAffected <= 0)
|
||||||
{
|
{
|
||||||
TempData["PaymentError"] = "Could not create additional payment invoice in tblInvoice.";
|
TempData["PaymentError"] = "Could not create additional payment invoice.";
|
||||||
|
EnsurePaymentSessionDefaults("TZS");
|
||||||
|
return RedirectToAction("Payment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TempData["PaymentError"] = "Error creating additional payment invoice: " + ex.Message;
|
||||||
EnsurePaymentSessionDefaults("TZS");
|
EnsurePaymentSessionDefaults("TZS");
|
||||||
return RedirectToAction("Payment");
|
return RedirectToAction("Payment");
|
||||||
}
|
}
|
||||||
|
|
@ -2332,13 +2356,14 @@ namespace OSS.Controllers
|
||||||
|
|
||||||
// In Additional Payment context: hide the "Pay Additional Amount" button and hide previous paid invoices
|
// In Additional Payment context: hide the "Pay Additional Amount" button and hide previous paid invoices
|
||||||
ViewBag.HideAdditionalButton = true;
|
ViewBag.HideAdditionalButton = true;
|
||||||
|
ViewBag.HideInvoiceGrid = true;
|
||||||
TempData["HidePaidInvoices"] = true;
|
TempData["HidePaidInvoices"] = true;
|
||||||
TempData["AdditionalContext"] = true;
|
TempData["AdditionalContext"] = true;
|
||||||
return View("Payment");
|
return View("Payment");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
TempData["PaymentError"] = "Error creating additional payment invoice. " + ex.Message;
|
TempData["PaymentError"] = "Error creating additional payment invoice: " + ex.Message;
|
||||||
EnsurePaymentSessionDefaults("TZS");
|
EnsurePaymentSessionDefaults("TZS");
|
||||||
return RedirectToAction("Payment");
|
return RedirectToAction("Payment");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,12 @@
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
|
||||||
|
bool hideInvoiceGrid = false;
|
||||||
|
if (ViewBag.HideInvoiceGrid != null)
|
||||||
|
{
|
||||||
|
bool.TryParse(ViewBag.HideInvoiceGrid.ToString(), out hideInvoiceGrid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<link href="~/Content/assets/css/tables/table-basic.css" rel="stylesheet" type="text/css" />
|
<link href="~/Content/assets/css/tables/table-basic.css" rel="stylesheet" type="text/css" />
|
||||||
|
|
@ -82,6 +88,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
@if (!hideInvoiceGrid)
|
||||||
|
{
|
||||||
<h6 class="text-primary"> Invoice Details</h6>
|
<h6 class="text-primary"> Invoice Details</h6>
|
||||||
@(Html.DevExtreme().DataGrid<OSS.Models.ApplicationManager>()
|
@(Html.DevExtreme().DataGrid<OSS.Models.ApplicationManager>()
|
||||||
.ID("invoiceGrid")
|
.ID("invoiceGrid")
|
||||||
|
|
@ -140,6 +148,7 @@ columns.AddFor(m => m.CompanyEmail).Caption("Company Email").Visible(true).Allow
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -178,7 +187,7 @@ columns.AddFor(m => m.CompanyEmail).Caption("Company Email").Visible(true).Allow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@if (TempData["HidePaidInvoices"] != null)
|
@if (TempData["HidePaidInvoices"] != null && !hideInvoiceGrid)
|
||||||
{
|
{
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
@ -190,7 +199,7 @@ columns.AddFor(m => m.CompanyEmail).Caption("Company Email").Visible(true).Allow
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (TempData["AdditionalContext"] != null)
|
@if (TempData["AdditionalContext"] != null && !hideInvoiceGrid)
|
||||||
{
|
{
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,6 @@
|
||||||
<label for="validationCustom05" class="text-black">Currency</label>
|
<label for="validationCustom05" class="text-black">Currency</label>
|
||||||
@Html.DropDownListFor(m => m.Currency, new List<SelectListItem> {
|
@Html.DropDownListFor(m => m.Currency, new List<SelectListItem> {
|
||||||
//new SelectListItem{ Text="List of allowed currency", Value = "", Selected= true},
|
//new SelectListItem{ Text="List of allowed currency", Value = "", Selected= true},
|
||||||
new SelectListItem{ Text="Select Allowed Currency", Value = "", Selected= true},
|
|
||||||
new SelectListItem{ Text="TZS", Value = "TZS" },
|
new SelectListItem{ Text="TZS", Value = "TZS" },
|
||||||
// new SelectListItem{ Text="USD", Value = "USD" },
|
// new SelectListItem{ Text="USD", Value = "USD" },
|
||||||
}, new { @class = "selectpicker form-control", @id = "Currency", @required = "true" })
|
}, new { @class = "selectpicker form-control", @id = "Currency", @required = "true" })
|
||||||
|
|
|
||||||
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.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue