31 lines
1.4 KiB
Transact-SQL
31 lines
1.4 KiB
Transact-SQL
-- One-time install step: change log for products created and costs changed
|
|
-- by the invoice parser. Read by the Changes page.
|
|
-- Run as a login with CREATE TABLE rights on posbdat (not the app's limited login).
|
|
-- Safe to re-run: the table is only created when missing.
|
|
USE posbdat;
|
|
GO
|
|
|
|
IF OBJECT_ID('dbo.InvoiceProductChanges', 'U') IS NULL
|
|
BEGIN
|
|
CREATE TABLE dbo.InvoiceProductChanges (
|
|
ChangeID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
|
|
ChangeDate datetime NOT NULL DEFAULT GETDATE(),
|
|
ChangeType varchar(10) NOT NULL, -- NEW = product created, COST = cost change
|
|
UPC varchar(13) NOT NULL,
|
|
Description varchar(30) NULL,
|
|
Vendor varchar(20) NULL,
|
|
InvoiceNumber varchar(100) NULL,
|
|
PONumber varchar(12) NULL, -- NULL for NEW: the PO is assigned at save
|
|
BatchNo varchar(25) NULL,
|
|
OldCost decimal(12,4) NULL,
|
|
NewCost decimal(12,4) NULL,
|
|
Retail decimal(12,4) NULL,
|
|
Pack decimal(12,2) NULL,
|
|
EmpNo int NULL
|
|
);
|
|
CREATE INDEX IX_InvoiceProductChanges_ChangeDate ON dbo.InvoiceProductChanges (ChangeDate);
|
|
END
|
|
GO
|
|
|
|
-- The app's login needs to write and read it. Replace <app_login> and run.
|
|
-- GRANT SELECT, INSERT ON dbo.InvoiceProductChanges TO [<app_login>];
|