CREATE TABLE [dbo].[acc_invoices_risks_variables]
(
[invrisv_invoice_id] [int] NOT NULL,
[invrisv_risk_situation_id] [int] NOT NULL,
[invrisv_variable_id] [int] NOT NULL,
[invrisv_coef_reduction] [dbo].[ais_decimal4] NULL,
[invrisv_tf] [dbo].[ais_decimal2] NULL,
[invrisv_taxes] [dbo].[ais_decimal2] NULL,
[invrisv_ti] [dbo].[ais_decimal2] NULL,
[invrisv_commission_tf] [dbo].[ais_decimal2] NULL,
[invrisv_commission_taxes] [dbo].[ais_decimal2] NULL,
[invrisv_commission_ti] [dbo].[ais_decimal2] NULL,
[invrisv_commission_percent] [dbo].[ais_decimal4] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables] ADD CONSTRAINT [PK_acc_invoices_risks_variables] PRIMARY KEY CLUSTERED  ([invrisv_invoice_id], [invrisv_risk_situation_id], [invrisv_variable_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables] ADD CONSTRAINT [FK_acc_invoices_risks_variables_acc_invoices_risks_situations] FOREIGN KEY ([invrisv_invoice_id], [invrisv_risk_situation_id]) REFERENCES [dbo].[acc_invoices_risks_situations] ([invris_invoice_id], [invris_risk_situation_id])
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables] ADD CONSTRAINT [FK_acc_invoices_risks_variables_ris_variables] FOREIGN KEY ([invrisv_risk_situation_id], [invrisv_variable_id]) REFERENCES [dbo].[ris_variables] ([risv_risk_situation_id], [risv_variable_id])
GO
