CREATE TABLE [dbo].[acc_mpay_bordereaux_details]
(
[mpaybd_bordereau_id] [int] NOT NULL,
[mpaybd_invoice_id] [int] NOT NULL,
[mpaybd_monthly_payment_status_code] [dbo].[ais_code_short] NOT NULL,
[mpaybd_transaction_id] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_mpay_bordereaux_details] ADD CONSTRAINT [PK_acc_mpay_bordereaux_details] PRIMARY KEY CLUSTERED  ([mpaybd_bordereau_id], [mpaybd_invoice_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_mpay_bordereaux_details] ADD CONSTRAINT [FK_acc_mpay_bordereaux_details_acc_invoices] FOREIGN KEY ([mpaybd_invoice_id]) REFERENCES [dbo].[acc_invoices] ([inv_invoice_id])
GO
ALTER TABLE [dbo].[acc_mpay_bordereaux_details] ADD CONSTRAINT [FK_acc_mpay_bordereaux_details_acc_mpay_bordereaux] FOREIGN KEY ([mpaybd_bordereau_id]) REFERENCES [dbo].[acc_mpay_bordereaux] ([mpayb_bordereau_id])
GO
ALTER TABLE [dbo].[acc_mpay_bordereaux_details] ADD CONSTRAINT [FK_acc_mpay_bordereaux_details_acc_transactions] FOREIGN KEY ([mpaybd_transaction_id]) REFERENCES [dbo].[acc_transactions] ([atrn_transaction_id])
GO
ALTER TABLE [dbo].[acc_mpay_bordereaux_details] ADD CONSTRAINT [FK_acc_mpay_bordereaux_details_nm_invoices_nm_monthly_payments_statuses] FOREIGN KEY ([mpaybd_monthly_payment_status_code]) REFERENCES [dbo].[nm_invoices_nm_monthly_payments_statuses] ([nminmps_monthly_payment_status_code])
GO
