CREATE TABLE [dbo].[pr_products_variables_commission_taxes]
(
[prdvct_variable_id] [int] NOT NULL,
[prdvct_tax_code] [dbo].[ais_code_short] NOT NULL,
[prdvct_branch_id] [int] NOT NULL,
[prdvct_payable_company] [bit] NOT NULL CONSTRAINT [DF__pr_products_variables_commission_taxes__prdvct_payable_company] DEFAULT ((0)),
[prdvct_added_from_excel] [bit] NOT NULL CONSTRAINT [DF__pr_products_variables_commission_taxes__prdvct_added_from_excel] DEFAULT ((0)),
[prdvct_calculated_in_excel] [bit] NOT NULL CONSTRAINT [DF__pr_products_variables_commission_taxes__prdvct_calculated_in_excel] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[pr_products_variables_commission_taxes] ADD CONSTRAINT [PK_pr_products_variables_commission_taxes] PRIMARY KEY CLUSTERED  ([prdvct_variable_id], [prdvct_tax_code], [prdvct_branch_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[pr_products_variables_commission_taxes] ADD CONSTRAINT [FK_pr_products_variables_commission_taxes_act_branches] FOREIGN KEY ([prdvct_branch_id]) REFERENCES [dbo].[act_branches] ([br_actor_id])
GO
ALTER TABLE [dbo].[pr_products_variables_commission_taxes] ADD CONSTRAINT [FK_pr_products_variables_commission_taxes_nm_taxes] FOREIGN KEY ([prdvct_tax_code]) REFERENCES [dbo].[nm_taxes] ([nmtax_tax_code])
GO
ALTER TABLE [dbo].[pr_products_variables_commission_taxes] ADD CONSTRAINT [FK_pr_products_variables_commission_taxes_pr_products_variables] FOREIGN KEY ([prdvct_variable_id]) REFERENCES [dbo].[pr_products_variables] ([prdv_variable_id]) ON DELETE CASCADE
GO
