Scripts to transition database to new version.

Changed inventory and product entities to split Vat and Service Tax and IsScTaxable.
Added MessageBox on startup to inform about Debug Mode.
Updated ProductForm for the change.
Work still needs to be done on Thermal Printing where the hack for VAT on Food and VAT on Liqour is still there.
Now No Service Tax on Delivery Works as promised.
This commit is contained in:
unknown
2012-04-08 17:58:15 +05:30
parent 964d0a78bf
commit 2d1030abf6
20 changed files with 519 additions and 145 deletions

View File

@ -0,0 +1,85 @@
BEGIN TRANSACTION
GO
ALTER TABLE dbo.Entities_Inventories
DROP CONSTRAINT FK53E4F7FE3F88CAB6
GO
ALTER TABLE dbo.Entities_Inventories
DROP CONSTRAINT FK53E4F7FEDB70F42
GO
CREATE TABLE dbo.Tmp_Entities_Inventories
(
InventoryID int NOT NULL IDENTITY (1, 1),
Quantity decimal(19, 5) NOT NULL,
Price decimal(19, 5) NOT NULL,
FullPrice decimal(19, 5) NOT NULL,
ServiceTax decimal(19, 5) NOT NULL,
Vat decimal(19, 5) NOT NULL,
Discount decimal(19, 5) NOT NULL,
ServiceCharge decimal(19, 5) NOT NULL,
IsScTaxable bit NOT NULL,
Amount AS CASE WHEN IsScTaxable = 1 THEN Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTax + Vat) ELSE Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTax + Vat) END,
KotID int NULL,
ProductID int NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT dbo.Tmp_Entities_Inventories ON
GO
IF EXISTS(SELECT * FROM dbo.Entities_Inventories)
EXEC('INSERT INTO dbo.Tmp_Entities_Inventories (InventoryID, Quantity, Price, FullPrice, ServiceTax, Vat, Discount, ServiceCharge, IsScTaxable, KotID, ProductID)
SELECT InventoryID, Quantity, Price, FullPrice, 0, Tax, Discount, ServiceCharge, 1, KotID, ProductID FROM dbo.Entities_Inventories WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_Entities_Inventories OFF
GO
ALTER TABLE dbo.Entities_InventoryModifiers
DROP CONSTRAINT FK695304F8BA29671A
GO
DROP TABLE dbo.Entities_Inventories
GO
EXECUTE sp_rename N'dbo.Tmp_Entities_Inventories', N'Entities_Inventories', 'OBJECT'
GO
ALTER TABLE dbo.Entities_Inventories ADD CONSTRAINT
PK__Entities_Inventories PRIMARY KEY CLUSTERED
(
InventoryID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX IX_Entities_Inventories ON dbo.Entities_Inventories
(
KotID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.Entities_Inventories ADD CONSTRAINT
FK53E4F7FEDB70F42 FOREIGN KEY
(
KotID
) REFERENCES dbo.Entities_Kots
(
KotID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Entities_Inventories ADD CONSTRAINT
FK53E4F7FE3F88CAB6 FOREIGN KEY
(
ProductID
) REFERENCES dbo.Entities_Products
(
ProductID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Entities_InventoryModifiers ADD CONSTRAINT
FK695304F8BA29671A FOREIGN KEY
(
InventoryID
) REFERENCES dbo.Entities_Inventories
(
InventoryID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
COMMIT

View File

@ -0,0 +1,40 @@
select distinct vat from entities_inventories
select * from entities_taxes
update entities_inventories set issctaxable = 0, servicetax = 0, vat = 0
where vat = 0.00000
update entities_inventories set issctaxable = 1, servicetax = 0, vat = 0.13125
where vat = 0.13125
update entities_inventories set issctaxable = 1, servicetax = 0, vat = 0.26250
where vat = 0.26250
update entities_inventories set issctaxable = 0, servicetax = 0.03708, vat = 0.13125
where vat = 0.15303
update entities_inventories set issctaxable = 0, servicetax = 0.03708, vat = 0.1575
where vat = 0.17690
update entities_inventories set issctaxable = 0, servicetax = 0.0309, vat = 0.13125
where vat = 0.14741
update entities_inventories set issctaxable = 0, servicetax = 0.0309, vat = 0.2625
where vat = 0.26673
update entities_inventories set issctaxable = 0, servicetax = 0.03, vat = 0.13125
where vat = 0.14659
update entities_inventories set issctaxable = 0, servicetax = 0.03, vat = 0.2625
where vat = 0.26591
UPDATE Entities_Taxes SET Name = 'VAT on Food 12.5%', Rate = .13125 WHERE TaxID = 1
UPDATE Entities_Taxes SET Name = 'VAT on Liquor 15%', Rate = .1575 WHERE TaxID = 2
UPDATE Entities_Taxes SET Name = 'Cental Govt. ST 12%', Rate = 0.03708 WHERE TaxID = 3
UPDATE Entities_Taxes SET Name = 'Tax Paid / Free', Rate = 0 WHERE TaxID = 4

View File

@ -0,0 +1,102 @@
BEGIN TRANSACTION
GO
ALTER TABLE dbo.Entities_Products
DROP CONSTRAINT FK66E1235A95976D16
GO
ALTER TABLE dbo.Entities_Products
DROP CONSTRAINT FK66E1235AEB4DC236
GO
CREATE TABLE dbo.Tmp_Entities_Products
(
ProductID int NOT NULL IDENTITY (1, 1),
Code int NULL,
Name nvarchar(100) NOT NULL,
Units nvarchar(20) NOT NULL,
ServiceCharge decimal(19, 5) NOT NULL,
IsScTaxable bit NOT NULL,
Price decimal(19, 5) NOT NULL,
FullPrice decimal(19, 5) NOT NULL,
Discontinued bit NOT NULL,
SortOrder int NULL,
ProductGroupID int NOT NULL,
ServiceTaxID int NOT NULL,
VatID int NOT NULL,
BaseCode int NOT NULL,
Quantity decimal(19, 5) NOT NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT dbo.Tmp_Entities_Products ON
GO
IF EXISTS(SELECT * FROM dbo.Entities_Products)
EXEC('INSERT INTO dbo.Tmp_Entities_Products (ProductID, Code, Name, Units, ServiceCharge, IsScTaxable, Price, FullPrice, Discontinued, SortOrder, ProductGroupID, ServiceTaxID, VatID, BaseCode, Quantity)
SELECT ProductID, Code, Name, Units, ServiceCharge, 0, Price, FullPrice, Discontinued, SortOrder, ProductGroupID, CASE WHEN TaxID = 4 THEN 4 ELSE 3 END, TaxID, BaseCode, Quantity FROM dbo.Entities_Products WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_Entities_Products OFF
GO
ALTER TABLE dbo.Entities_Inventories
DROP CONSTRAINT FK53E4F7FE3F88CAB6
GO
DROP TABLE dbo.Entities_Products
GO
EXECUTE sp_rename N'dbo.Tmp_Entities_Products', N'Entities_Products', 'OBJECT'
GO
ALTER TABLE dbo.Entities_Products ADD CONSTRAINT
PK__Entities_Product__737017C0 PRIMARY KEY CLUSTERED
(
ProductID
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.Entities_Products ADD CONSTRAINT
IX_Entities_Products_Name UNIQUE NONCLUSTERED
(
Name,
Units
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE dbo.Entities_Products ADD CONSTRAINT
FK66E1235AEB4DC236 FOREIGN KEY
(
VatID
) REFERENCES dbo.Entities_Taxes
(
TaxID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Entities_Products ADD CONSTRAINT
FK66E1235A95976D16 FOREIGN KEY
(
ProductGroupID
) REFERENCES dbo.Entities_ProductGroups
(
ProductGroupID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Entities_Products ADD CONSTRAINT
FK_Entities_Products_Entities_Taxes FOREIGN KEY
(
ServiceTaxID
) REFERENCES dbo.Entities_Taxes
(
TaxID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
ALTER TABLE dbo.Entities_Inventories ADD CONSTRAINT
FK53E4F7FE3F88CAB6 FOREIGN KEY
(
ProductID
) REFERENCES dbo.Entities_Products
(
ProductID
) ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
COMMIT