sozsoft-platform/configs/seeds/sql/object/Prc_T_MaterialRequestPlanLine.sql
2026-10-14 22:26:03 +03:00

40 lines
2.2 KiB
Transact-SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Planla diyaloğunun taslak karşılama planı: talep kaleminin onaylanmamış dağıtımı (iç transfer: kaynak konum, satınalma: tedarikçi) ve
-- miktarı. İç transferde lot/seri takipli ürünün satırı lotu da taşır (LotNo; takipsiz üründe boş). Onay (Prc_P_MaterialRequestPlanConfirm) satırları teklif talebine ya da iç transfere çevirir ve siler.
IF OBJECT_ID(N'[dbo].[Prc_T_MaterialRequestPlanLine]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Prc_T_MaterialRequestPlanLine]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[MaterialRequestItemId] uniqueidentifier NOT NULL,
[PlanMethod] nvarchar(16) NOT NULL,
[SupplierId] uniqueidentifier NULL,
[SourceLocationId] uniqueidentifier NULL,
[LotNo] nvarchar(64) NOT NULL DEFAULT '',
[Quantity] decimal(18, 4) NOT NULL DEFAULT 0,
[CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(),
[CreatorId] uniqueidentifier NULL,
[LastModificationTime] datetime2 NULL,
[LastModifierId] uniqueidentifier NULL,
[IsDeleted] bit NOT NULL DEFAULT 0,
[DeletionTime] datetime2 NULL,
[DeleterId] uniqueidentifier NULL,
CONSTRAINT [PK_Prc_T_MaterialRequestPlanLine] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF INDEXPROPERTY(OBJECT_ID(N'[dbo].[Prc_T_MaterialRequestPlanLine]'), 'IX_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId', 'IndexID') IS NULL
BEGIN
CREATE INDEX [IX_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId] ON [dbo].[Prc_T_MaterialRequestPlanLine] ([MaterialRequestItemId] ASC);
END
GO
IF OBJECT_ID(N'[dbo].[FK_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId]', 'F') IS NULL
BEGIN
ALTER TABLE [dbo].[Prc_T_MaterialRequestPlanLine] ADD CONSTRAINT [FK_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId] FOREIGN KEY ([MaterialRequestItemId]) REFERENCES [dbo].[Prc_T_MaterialRequestItem] ([Id]) ON DELETE CASCADE ON UPDATE NO ACTION;
END
GO