CREATE TABLE [dbo].[acc_invoices_risks_variables_cies]
(
[invrisvc_invoice_id] [int] NOT NULL,
[invrisvc_risk_situation_id] [int] NOT NULL,
[invrisvc_variable_id] [int] NOT NULL,
[invrisvc_company_id] [int] NOT NULL,
[invrisvc_tf] [dbo].[ais_decimal2] NULL,
[invrisvc_taxes] [dbo].[ais_decimal2] NULL,
[invrisvc_ti] [dbo].[ais_decimal2] NULL,
[invrisvc_commission_tf] [dbo].[ais_decimal2] NULL,
[invrisvc_commission_taxes] [dbo].[ais_decimal2] NULL,
[invrisvc_commission_ti] [dbo].[ais_decimal2] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables_cies] ADD CONSTRAINT [PK_acc_invoices_risks_variables_cies] PRIMARY KEY CLUSTERED  ([invrisvc_invoice_id], [invrisvc_risk_situation_id], [invrisvc_variable_id], [invrisvc_company_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables_cies] ADD CONSTRAINT [FK_acc_invoices_risks_variables_cies_acc_invoices_risks_variables] FOREIGN KEY ([invrisvc_invoice_id], [invrisvc_risk_situation_id], [invrisvc_variable_id]) REFERENCES [dbo].[acc_invoices_risks_variables] ([invrisv_invoice_id], [invrisv_risk_situation_id], [invrisv_variable_id])
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables_cies] ADD CONSTRAINT [FK_acc_invoices_risks_variables_cies_act_cies] FOREIGN KEY ([invrisvc_company_id]) REFERENCES [dbo].[act_cies] ([cie_actor_id])
GO
