USE [P21]
GO

/****** Object:  View [dbo].[vatcImportCustomer]    Script Date: 9/29/2024 9:53:11 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE VIEW [dbo].[vatcImportCustomer]
AS
SELECT        dbo.customer.company_id AS CompanyID, dbo.customer.customer_id AS CustID, dbo.customer.customer_name AS CustName, 
                         CASE WHEN customer.delete_flag = 'Y' THEN 'Deleted' ELSE 'Active' END AS CustStatus, dbo.customer.salesrep_id AS SperID, 
                         dbo.contacts.first_name + ' ' + dbo.contacts.last_name AS SperName, 
                         CASE WHEN customer.invoice_batch_uid = 3 THEN 'FaxCust' ELSE 'Default' END AS CustClassID, 
                         CASE WHEN customer.credit_status = 'HOLD' THEN 1 ELSE 0 END AS CreditHold, dbo.customer.credit_limit AS CreditLimit, UPPER(dbo.terms.terms_desc) 
                         AS PmtTermsID, dbo.customer.date_created AS DateEstab, dbo.address.mail_address1 AS AddrLine1, dbo.address.mail_address2 AS AddrLine2, '' AS AddrLine3, 
                         '' AS AddrLine4, '' AS AddrLine5, dbo.address.mail_city AS City, '' AS SalesTerritory, dbo.address.mail_state AS State, dbo.address.mail_postal_code AS PostalCode, 
                         dbo.address.mail_country AS Country, dbo.currency_hdr.currency_desc AS CurrID, '' AS ContactName, '' AS Reference, 
                         dbo.invoice_batch.invoice_batch_desc AS UDF1, '' AS UDF2, '' AS UDF3, '' AS UDF4, '' AS UDF5, '' AS UDF6, '' AS UDF7, '' AS UDF8, '' AS UDF9, '' AS UDF10, 
                         dbo.customer.date_last_modified AS UpdateDate
FROM            dbo.customer WITH (NOLOCK) INNER JOIN
                         dbo.invoice_batch WITH (NOLOCK) ON dbo.customer.invoice_batch_uid = dbo.invoice_batch.invoice_batch_uid INNER JOIN
                         dbo.currency_hdr WITH (NOLOCK) ON dbo.customer.currency_id = dbo.currency_hdr.currency_id INNER JOIN
                         dbo.terms WITH (NOLOCK) ON dbo.customer.terms_id = dbo.terms.terms_id INNER JOIN
                         dbo.contacts WITH (NOLOCK) ON dbo.customer.salesrep_id = dbo.contacts.id INNER JOIN
                         dbo.address WITH (NOLOCK) ON dbo.customer.customer_id = dbo.address.id
WHERE        (dbo.customer.company_id = 10)
GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[29] 4[26] 2[18] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = -192
         Left = 0
      End
      Begin Tables = 
         Begin Table = "customer"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 135
               Right = 314
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "invoice_batch"
            Begin Extent = 
               Top = 198
               Left = 612
               Bottom = 327
               Right = 887
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "currency_hdr"
            Begin Extent = 
               Top = 6
               Left = 352
               Bottom = 135
               Right = 593
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "terms"
            Begin Extent = 
               Top = 138
               Left = 38
               Bottom = 267
               Right = 292
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "contacts"
            Begin Extent = 
               Top = 138
               Left = 330
               Bottom = 267
               Right = 574
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "address"
            Begin Extent = 
               Top = 270
               Left = 38
               Bottom = 399
               Right = 290
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 36
         Width = 284
         Width = 1500
         Width' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vatcImportCustomer'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N' = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 1785
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vatcImportCustomer'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vatcImportCustomer'
GO


