diff --git a/.vs/OSS/v16/.suo b/.vs/OSS/v16/.suo index 23923bd..0e76559 100644 Binary files a/.vs/OSS/v16/.suo and b/.vs/OSS/v16/.suo differ diff --git a/Add_Application_Fixed.sql b/Add_Application_Fixed.sql new file mode 100644 index 0000000..34e9503 --- /dev/null +++ b/Add_Application_Fixed.sql @@ -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 + diff --git a/Controllers/NewCOIController.cs b/Controllers/NewCOIController.cs index 964d067..0ed4e2e 100644 --- a/Controllers/NewCOIController.cs +++ b/Controllers/NewCOIController.cs @@ -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; diff --git a/ReceiptGepg.Designer.cs b/ReceiptGepg.Designer.cs index 7f6eaef..3cb98d3 100644 --- a/ReceiptGepg.Designer.cs +++ b/ReceiptGepg.Designer.cs @@ -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[] { diff --git a/Views/NewCOI/Payment.cshtml b/Views/NewCOI/Payment.cshtml index f3c678c..99ba31a 100644 --- a/Views/NewCOI/Payment.cshtml +++ b/Views/NewCOI/Payment.cshtml @@ -51,7 +51,7 @@
- Print invoice + Print invoice
diff --git a/bin/OSS.dll b/bin/OSS.dll index 2a94470..003e637 100644 Binary files a/bin/OSS.dll and b/bin/OSS.dll differ diff --git a/bin/OSS.pdb b/bin/OSS.pdb index ec57a35..99205a4 100644 Binary files a/bin/OSS.pdb and b/bin/OSS.pdb differ diff --git a/obj/Debug/OSS.csproj.GenerateResource.cache b/obj/Debug/OSS.csproj.GenerateResource.cache index 06c67a5..4a52df0 100644 Binary files a/obj/Debug/OSS.csproj.GenerateResource.cache and b/obj/Debug/OSS.csproj.GenerateResource.cache differ diff --git a/obj/Debug/OSS.dll b/obj/Debug/OSS.dll index 2a94470..003e637 100644 Binary files a/obj/Debug/OSS.dll and b/obj/Debug/OSS.dll differ diff --git a/obj/Debug/OSS.pdb b/obj/Debug/OSS.pdb index ec57a35..99205a4 100644 Binary files a/obj/Debug/OSS.pdb and b/obj/Debug/OSS.pdb differ