﻿CREATE TABLE [dbo].[QuoteList] (
    [QuoteType]    CHAR (1)        CONSTRAINT [DF_QuoteList_QuoteType] DEFAULT ('Q') NOT NULL,
    [CodQuote]     BIGINT          NOT NULL,
    [QuoteRev]     INT             CONSTRAINT [DF_QuoteList_QuoteRev] DEFAULT ((0)) NOT NULL,
    [IdxQState]    INT             CONSTRAINT [DF_QuoteList_State] DEFAULT ((0)) NOT NULL,
    [CodClient]    NVARCHAR (50)   NOT NULL,
    [CodItem]      NVARCHAR (50)   CONSTRAINT [DF_QuoteList_CodItem] DEFAULT ('') NOT NULL,
    [CodItemGroup] NVARCHAR (50)   CONSTRAINT [DF_QuoteList_CodItemGroup] DEFAULT ('') NOT NULL,
    [RawMat]       NVARCHAR (50)   NOT NULL,
    [UnitWeight]   DECIMAL (9, 3)  CONSTRAINT [DF_QuoteList_UnitWeight] DEFAULT ((0)) NOT NULL,
    [BatchQty]     INT             CONSTRAINT [DF_QuoteList_BathQty] DEFAULT ((0)) NOT NULL,
    [CodInco]      NVARCHAR (5)    NOT NULL,
    [KeyAM]        AS              ((case when [QuoteType]='S' then [CodItemGroup] else [CodItem] end+'-')+[RawMat]),
    [Note]         NVARCHAR (2500) CONSTRAINT [DF_QuoteList_Note] DEFAULT ('') NOT NULL,
    [PriceOff]     DECIMAL (9, 6)  CONSTRAINT [DF_QuoteList_OrdPrice1] DEFAULT ((0)) NOT NULL,
    [OrdDate]      SMALLDATETIME   NULL,
    [OrdNum]       NVARCHAR (50)   CONSTRAINT [DF_QuoteList_OrdNum] DEFAULT ((0)) NOT NULL,
    [OrdRow]       NVARCHAR (50)   CONSTRAINT [DF_QuoteList_OrdRow] DEFAULT ((0)) NOT NULL,
    [OrdPrice]     DECIMAL (9, 6)  CONSTRAINT [DF_QuoteList_PriceOff1] DEFAULT ((0)) NOT NULL,
    [OrdQty]       INT             CONSTRAINT [DF_QuoteList_OrderQty] DEFAULT ((0)) NOT NULL,
    [valid]        BIT             CONSTRAINT [DF_QuoteList_valid] DEFAULT ((1)) NOT NULL,
    [errorScore]   INT             CONSTRAINT [DF_QuoteList_errorScore] DEFAULT ((0)) NOT NULL,
    [UserCreaz]    NVARCHAR (50)   CONSTRAINT [DF_QuoteList_UserCreaz] DEFAULT ('') NOT NULL,
    [DataCreaz]    DATETIME        CONSTRAINT [DF_QuoteList_DataCreaz] DEFAULT (getdate()) NOT NULL,
    [UserMod]      NVARCHAR (50)   CONSTRAINT [DF_QuoteList_UserMod] DEFAULT ('') NOT NULL,
    [DataMod]      DATETIME        CONSTRAINT [DF_QuoteList_DataMod] DEFAULT (getdate()) NOT NULL,
    CONSTRAINT [PK_QuoteList_1] PRIMARY KEY CLUSTERED ([QuoteType] ASC, [CodQuote] ASC, [QuoteRev] ASC) WITH (FILLFACTOR = 90)
);






GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'tipo di preventivo: Q = quote, S = simulation', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'QuoteType';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'numero nel formato yyMMddnnnn dove nnn è incrementale giornaliero', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'CodQuote';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'codice cliente', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'CodClient';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'codice articolo', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'CodItem';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'classe raggruppamento (es complessità disegno)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'CodItemGroup';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'codice MP', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'RawMat';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'peso espresso come g/m (grammi / metro)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'UnitWeight';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Quantità lotto kg', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'BatchQty';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Codice Incoterms', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'CodInco';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Prezzo Offerto', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'PriceOff';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'data dell''ordine', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'OrdDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'numero ordine', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'OrdNum';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'riga ordine', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'OrdRow';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Prezzo finale ordine', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'OrdPrice';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Stato offerta: 0 = D raft, 1 = C ompleted / in approvazione, 2 = A pprouved, 3 = R eleased', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'IdxQState';




GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'punteggio complessivo errori in procedure di calcolo', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'QuoteList', @level2type = N'COLUMN', @level2name = N'errorScore';

