narsil/Sql/Service Tax Change/1. New Tax For Pets.sql
unknown 2d1030abf6 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.
2012-04-08 17:58:15 +05:30

86 lines
2.5 KiB
Transact-SQL

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