This commit is contained in:
mustafa.juma 2025-11-20 22:42:58 +03:00
parent 535b5f4732
commit f0fd9c882f
10 changed files with 163 additions and 22 deletions

Binary file not shown.

141
Add_Application_Fixed.sql Normal file
View File

@ -0,0 +1,141 @@
USE [LotusDB1]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Add_Application]
@CompanyName [nvarchar](max),
@ProjectName [nvarchar](max),
@CompanyTIN [nvarchar](128),
@ProjectCode [nvarchar](max),
@EvaluationStatus [nvarchar](max),
@MobileNo [nvarchar](max),
@Station [nvarchar](max),
@StartDate [datetime2](7),
@CreatedDate [datetime2](7),
@Expiredate [datetime2](7),
@Amount [decimal](18, 2),
@ControlNo [nvarchar](max),
@UpdatedDate [datetime2](7),
@PaymentStatus [nvarchar](max),
@CompanyEmail [nvarchar](128),
@ReceiptNo [nvarchar](max),
@PayedDate [datetime2](7),
@CertificateNo [nvarchar](max),
@ServiceName [nvarchar](max),
@Comments [nvarchar](max),
@FullName [nvarchar](max),
@InvoiceID bigint,
@GePGComment [nvarchar](max),
@Currency [nvarchar](max)
AS
BEGIN
SET NOCOUNT ON;
INSERT [dbo].[ApplicationManagers]([CompanyName], [ProjectName], [CompanyTIN], [ProjectCode], [EvaluationStatus], [MobileNo], [Station], [StartDate], [CreatedDate], [Expiredate], [Amount], [ControlNo], [UpdatedDate], [PaymentStatus], [CompanyEmail], [ReceiptNo], [PayedDate], [CertificateNo], [ServiceName],[Comments],[FullName],[InvoiceID],[GePGComment],[Currency])
VALUES (@CompanyName, @ProjectName, @CompanyTIN, @ProjectCode, @EvaluationStatus, @MobileNo, @Station, @StartDate, @CreatedDate, @Expiredate, @Amount, @ControlNo, @UpdatedDate, @PaymentStatus, @CompanyEmail, @ReceiptNo, @PayedDate, @CertificateNo, @ServiceName,@Comments,@FullName,@InvoiceID,@GePGComment,@Currency)
DECLARE @ApplicationID bigint
SELECT @ApplicationID = [ApplicationID]
FROM [dbo].[ApplicationManagers]
WHERE @@ROWCOUNT > 0 AND [ApplicationID] = scope_identity()
SELECT t0.[ApplicationID]
FROM [dbo].[ApplicationManagers] AS t0
WHERE @@ROWCOUNT > 0 AND t0.[ApplicationID] = @ApplicationID
-- Find full name of informant
DECLARE @ServiceTypeID bigint
DECLARE @FrontUserId bigint
SET @FrontUserId = (SELECT InvestorID FROM InvestorProfileExternals WHERE CompanyEmail=@CompanyEmail)
SET @FullName = (SELECT FirstName + ' ' + COALESCE(MiddleName, '') + ' ' + LastName FROM InvestorProfileExternals WHERE CompanyEmail = @CompanyEmail)
-- SET Service TypeID
IF(@ServiceName='New' AND @Currency='USD')
SET @ServiceTypeID = 1
ELSE IF(@ServiceName='Amendment' AND @Currency='USD')
SET @ServiceTypeID = 2
ELSE IF(@ServiceName='Expansion' AND @Currency='USD')
SET @ServiceTypeID = 3
ELSE IF(@ServiceName='Extension' AND @Currency='USD')
SET @ServiceTypeID = 4
ELSE IF(@ServiceName='New' AND @Currency='TZS')
SET @ServiceTypeID = 5
ELSE IF(@ServiceName='Amendment' AND @Currency='TZS')
SET @ServiceTypeID = 6
ELSE IF(@ServiceName='Expansion' AND @Currency='TZS')
SET @ServiceTypeID = 7
ELSE IF(@ServiceName='Extension' AND @Currency='TZS')
SET @ServiceTypeID = 8
ELSE IF(@ServiceName='New_Foreign' AND @Currency='TZS')
SET @ServiceTypeID = 9
ELSE IF(@ServiceName='Expansion_Foreign' AND @Currency='TZS')
SET @ServiceTypeID = 10
ELSE
SET @ServiceTypeID = 11
-- Generate Billcode
DECLARE @MaxID AS varchar(max)
SELECT @MaxID=MAX([InvoiceID]) FROM [dbo].[tblInvoice] WHERE Year([StartDate]) = Year(Getdate()) AND month([StartDate]) = month(Getdate())
DECLARE @BillCode varchar(max)
DECLARE @invoiceNo varchar(max)
DECLARE @Year nvarchar(max)
DECLARE @Month nvarchar(max)
DECLARE @Yrmth nvarchar(max)
SELECT @Year = Year(getdate())
SELECT @Month = Month(getdate())
SET @Yrmth = @Year + @Month
SET @invoiceNo = (COALESCE(@MaxID,0)+1)
SET @BillCode = @Yrmth + @invoiceNo
-- Find GFSCode from tblService - determine correct ServiceName based on ownership
DECLARE @GFSCode nvarchar(50)
DECLARE @TypeofOwnership nvarchar(max)
DECLARE @ServiceNameForLookup nvarchar(max) = @ServiceName
-- Get ownership from ProjectProfilesExternal to determine correct ServiceName for lookup
SELECT @TypeofOwnership = TypeofOwnership
FROM ProjectProfilesExternal
WHERE ProjectCode = @ProjectCode
-- Adjust ServiceName for lookup if foreign/mixed ownership and TZS currency
IF (@TypeofOwnership IS NOT NULL AND @TypeofOwnership <> 'Local' AND @Currency = 'TZS')
BEGIN
IF (@ServiceName = 'New')
SET @ServiceNameForLookup = 'New_Foreign'
ELSE IF (@ServiceName = 'Expansion')
SET @ServiceNameForLookup = 'Expansion_Foreign'
END
-- Get GFSCode from tblService using the correct ServiceName
SELECT @GFSCode = GFSCode
FROM [dbo].[tblService]
WHERE ServiceName = @ServiceNameForLookup AND [Currency] = @Currency AND Status = '1'
-- Use default GFSCode if not found
IF (@GFSCode IS NULL OR @GFSCode = '')
SET @GFSCode = '142201370002'
-- Insert into tblInvoice using @Amount (already calculated correctly in C#) instead of querying tblService for Fee
-- This ensures ApplicationManagers.Amount matches tblInvoice.Amount
INSERT INTO [dbo].[tblInvoice] ([FullName],[PhoneNo],[GFSCode],[BillItemRefNo],[SubServiceName],[Amount],FrontUserId,ApplicationID,StartDate,Expiredate,ServiceTypeID,ApplicationCode,[Currency],[TIN_No])
VALUES (@FullName,@MobileNo,@GFSCode,@BillCode,@ServiceName,@Amount,@FrontUserId,@ApplicationID,getdate(),getdate()+30,@ServiceTypeID,@ProjectCode,@Currency,@CompanyTIN)
-- Update ApplicationManagers with FullName and InvoiceID
DECLARE @NewInvoiceID bigint
SELECT @NewInvoiceID = InvoiceID
FROM tblInvoice
WHERE ApplicationCode = @ProjectCode AND ApplicationID = @ApplicationID
ORDER BY InvoiceID DESC
UPDATE ApplicationManagers
SET FullName = @FullName, InvoiceID = @NewInvoiceID
WHERE ProjectCode = @ProjectCode AND ApplicationID = @ApplicationID
END
GO

View File

@ -2309,7 +2309,7 @@ namespace OSS.Controllers
}
string billItemRefNo = "BILL-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + code;
int serviceTypeID = 1;
int serviceTypeID = 11;
string sql = @"
INSERT INTO [dbo].[tblInvoice]
@ -2539,7 +2539,7 @@ namespace OSS.Controllers
if (checkData != null)
{
string priceStr = checkData.ToString();
string priceStr = checkData.Amount.ToString();
priceStr = priceStr.Contains(".") ? priceStr.TrimEnd('0').TrimEnd('.') : priceStr;
Session["CompanyTIN"] = checkData.CompanyTIN;

View File

@ -30,10 +30,10 @@
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ReceiptGepg));
DevExpress.DataAccess.Sql.StoredProcQuery storedProcQuery2 = new DevExpress.DataAccess.Sql.StoredProcQuery();
DevExpress.DataAccess.Sql.QueryParameter queryParameter2 = new DevExpress.DataAccess.Sql.QueryParameter();
DevExpress.DataAccess.Sql.StoredProcQuery storedProcQuery1 = new DevExpress.DataAccess.Sql.StoredProcQuery();
DevExpress.DataAccess.Sql.QueryParameter queryParameter1 = new DevExpress.DataAccess.Sql.QueryParameter();
DevExpress.DataAccess.Sql.StoredProcQuery storedProcQuery2 = new DevExpress.DataAccess.Sql.StoredProcQuery();
DevExpress.DataAccess.Sql.QueryParameter queryParameter2 = new DevExpress.DataAccess.Sql.QueryParameter();
this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
this.xrLabel5 = new DevExpress.XtraReports.UI.XRLabel();
this.xrLabel4 = new DevExpress.XtraReports.UI.XRLabel();
@ -71,11 +71,11 @@
this.xrLabel18 = new DevExpress.XtraReports.UI.XRLabel();
this.xrLabel17 = new DevExpress.XtraReports.UI.XRLabel();
this.xrLabel16 = new DevExpress.XtraReports.UI.XRLabel();
this.sqlDataSource2 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);
this.sqlDataSource1 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);
this.InvoiceID = new DevExpress.XtraReports.Parameters.Parameter();
this.xrLabel31 = new DevExpress.XtraReports.UI.XRLabel();
this.ReportFooter = new DevExpress.XtraReports.UI.ReportFooterBand();
this.sqlDataSource2 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
@ -141,14 +141,14 @@
this.xrLabel3.Multiline = true;
this.xrLabel3.Name = "xrLabel3";
this.xrLabel3.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrLabel3.SizeF = new System.Drawing.SizeF(287.5F, 22.99999F);
this.xrLabel3.SizeF = new System.Drawing.SizeF(435.6942F, 22.99999F);
this.xrLabel3.StylePriority.UseBackColor = false;
this.xrLabel3.StylePriority.UseBorderColor = false;
this.xrLabel3.StylePriority.UseBorderDashStyle = false;
this.xrLabel3.StylePriority.UseBorders = false;
this.xrLabel3.StylePriority.UseFont = false;
this.xrLabel3.StylePriority.UseTextAlignment = false;
this.xrLabel3.Text = " Tanzania Investment Centre";
this.xrLabel3.Text = "Tanzania Investment and Special Economic Zones Authority (TISEZA)";
this.xrLabel3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopJustify;
//
// xrLabel2
@ -526,6 +526,20 @@
this.xrLabel16.Text = "xrLabel6";
this.xrLabel16.TextFormatString = "{0:0.00}";
//
// sqlDataSource2
//
this.sqlDataSource2.ConnectionName = "OSSDBConnectionString";
this.sqlDataSource2.Name = "sqlDataSource2";
storedProcQuery1.Name = "Get_Invoice_Profile";
queryParameter1.Name = "@InvoiceID";
queryParameter1.Type = typeof(DevExpress.DataAccess.Expression);
queryParameter1.Value = new DevExpress.DataAccess.Expression("?InvoiceID", typeof(long));
storedProcQuery1.Parameters.Add(queryParameter1);
storedProcQuery1.StoredProcName = "Get_Invoice_Profile";
this.sqlDataSource2.Queries.AddRange(new DevExpress.DataAccess.Sql.SqlQuery[] {
storedProcQuery1});
this.sqlDataSource2.ResultSchemaSerializable = resources.GetString("sqlDataSource2.ResultSchemaSerializable");
//
// sqlDataSource1
//
this.sqlDataSource1.ConnectionName = "OSSDBConnectionString";
@ -570,20 +584,6 @@
this.ReportFooter.HeightF = 41.58329F;
this.ReportFooter.Name = "ReportFooter";
//
// sqlDataSource2
//
this.sqlDataSource2.ConnectionName = "OSSDBConnectionString";
this.sqlDataSource2.Name = "sqlDataSource2";
storedProcQuery1.Name = "Get_Invoice_Profile";
queryParameter1.Name = "@InvoiceID";
queryParameter1.Type = typeof(DevExpress.DataAccess.Expression);
queryParameter1.Value = new DevExpress.DataAccess.Expression("?InvoiceID", typeof(long));
storedProcQuery1.Parameters.Add(queryParameter1);
storedProcQuery1.StoredProcName = "Get_Invoice_Profile";
this.sqlDataSource2.Queries.AddRange(new DevExpress.DataAccess.Sql.SqlQuery[] {
storedProcQuery1});
this.sqlDataSource2.ResultSchemaSerializable = resources.GetString("sqlDataSource2.ResultSchemaSerializable");
//
// ReceiptGepg
//
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {

View File

@ -51,7 +51,7 @@
<div class="col-md-12">
<div class="col-md-4">
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24" fill="none" stroke="#417505" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 2 18 2 18 9"></polyline><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path><rect x="6" y="14" width="12" height="8"></rect></svg> <a class="btn btn-default btn-lg mt-2 " href="#" target="_blank">Print invoice </a>
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24" fill="none" stroke="#417505" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 2 18 2 18 9"></polyline><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path><rect x="6" y="14" width="12" height="8"></rect></svg> <a class="btn btn-default btn-lg mt-2 " href="@Url.Action("Regenerate", "NewCOI", new { Id = Session["ProjectCode"] })" target="_blank">Print invoice </a>
</div>
</div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.