
BEGIN
	DECLARE @EntityId BIGINT = 123
	DECLARE @BusinessDay DATETIME = '2020-02-03'
	DECLARE @PeriodStart DATETIME
		,@PeriodEnd DATETIME
		,@FiscalYear VARCHAR(12)
		,@MonthName VARCHAR(12)
		,@PeriodNo INT
		,@OwnerEntityId BIGINT
		,@PollPOSID INT
		,@Amount MONEY = 5000.00
		,@ClerkId INT = 123
		,@ClerkName VARCHAR(50) = 'LoadTest Cashier'
		,@POSTransactionId BIGINT  
		,@TransactionDate DATETIME = DATEADD(day, DATEDIFF(day, 0, @BusinessDay), '03:30:00')
		,@TransactionSummaryId BIGINT
		,@TransactionControlInfoId BIGINT
		,@ControlInfoId BIGINT
		,@POSTransactionId2 BIGINT 
		
		SELECT @POSTransactionId = convert(numeric(8,0),rand() * 89999999) + 10000000
		SELECT @POSTransactionId2 = convert(numeric(8,0),rand() * 89999999) + 10000000
		
		DECLARE @CustomerID BIGINT = 63911614
			DECLARE @CustomerAccountName VARCHAR(50) = 'Wire Shark, LLC.'

	SELECT @FiscalYear = sFiscalYear
		,@MonthName = [MonthName]
		,@PeriodStart = iPeriodBegin_dt
		,@PeriodEnd = iPeriodEnd_dt
		,@PeriodNo = PeriodNo
	FROM tbPeriodDetail pd WITH (NOLOCK)
	WHERE @BusinessDay BETWEEN iPeriodBegin_dt
			AND iPeriodEnd_dt

	SELECT TOP 1 @PollPOSID = PollPOSID
	FROM tbPollPOS WITH (NOLOCK)
	WHERE Title = 'RADIANT'

INSERT INTO tbTransactionSummary (
				EntityID
				,EntityTypeID
				,OwnerEntityID
				,PollPOSID
				,POSTransactionID
				,TransactionDate
				,BusinessDay
				,StartDate
				,EndDate
				,FiscalYear
				,[MonthName]
				,PeriodNo
				,ClerkID
				,ClerkIDName
				,InOutDel
				,Sales_Incl_GST_INCL
				,Sales_Incl_GST_EXCL
				,Sales_Excl_GST_INCL
				,Sales_Excl_GST_EXCL
				,SalesItemCount
				,GSTAmount
				,Discount
				,Compliment
				,Free
				,Waste
				,Rounding
				,NonSales
				,CountAsTransaction
				,RegisterNumber
				,CurrentShiftNumber
				,DateAdded
				,TransactionVersion
				,RewardsSchemeID
				,ProcessComplete
				,NoOfCovers
				,CurrentDayNumber
				)
			VALUES (
				@EntityId
				,4
				,@OwnerEntityId
				,@PollPOSID
				,@POSTransactionId
				,@TransactionDate
				,@BusinessDay
				,@PeriodStart
				,@PeriodEnd
				,@FiscalYear
				,@MonthName
				,@PeriodNo
				,@ClerkId
				,@ClerkName
				,0
				,0
				,0
				,0
				,0
				,1
				,0
				,0
				,0
				,0
				,0
				,0
				,0
				,1
				,1
				,1
				,GETDATE()
				,0
				,0
				,1
				,0
				,0
				)

			SELECT @TransactionSummaryId = SCOPE_IDENTITY()

			SELECT @ControlInfoId = ControlInfoID
			FROM tbControlINFO WITH (NOLOCK)
			WHERE ControlInfo = 'OPShift Collected Sale AccountName'

			INSERT INTO tbTransactionControlInfo (
				EntityID
				,EntityTypeID
				,OwnerEntityID
				,SystemTransactionID
				,POSTransactionID
				,TransactionDate
				,BusinessDay
				,StartDate
				,EndDate
				,FiscalYear
				,PeriodNo
				,ClerkID
				,ClerkName
				,ControlInfoID
				,ControlInfoAmount
				,ControlInfoCount
				,DateAdded
				,OtherInfo1
				,OtherInfo2
				,OtherInfo3
				,RegisterNumber
				,CurrentShiftNumber
				,PolledDataID
				,CurrentDayNumber
				)
			SELECT @EntityId
				,4
				,@OwnerEntityId
				,@TransactionSummaryId
				,@POSTransactionId2
				,@TransactionDate
				,@BusinessDay
				,@PeriodStart
				,@PeriodEnd
				,@FiscalYear
				,@PeriodNo
				,@ClerkId
				,@ClerkName
				,@ControlInfoId
				,@Amount
				,1
				,GETDATE()
				,'OPShift_Collected SaleAccountName'
				,@CustomerAccountName
				,@POSTransactionId
				,1
				,1
				,0
				,0

			SELECT @ControlInfoId = ControlInfoID
			FROM tbControlINFO WITH (NOLOCK)
			WHERE ControlInfo = 'OPShift Collected Sale Description'

			INSERT INTO tbTransactionControlInfo (
				EntityID
				,EntityTypeID
				,OwnerEntityID
				,SystemTransactionID
				,POSTransactionID
				,TransactionDate
				,BusinessDay
				,StartDate
				,EndDate
				,FiscalYear
				,PeriodNo
				,ClerkID
				,ClerkName
				,ControlInfoID
				,ControlInfoAmount
				,ControlInfoCount
				,DateAdded
				,OtherInfo1
				,OtherInfo2
				,OtherInfo3
				,RegisterNumber
				,CurrentShiftNumber
				,PolledDataID
				,CurrentDayNumber
				)
			SELECT @EntityId
				,4
				,@OwnerEntityId
				,@TransactionSummaryId
				,@POSTransactionId2
				,@TransactionDate
				,@BusinessDay
				,@PeriodStart
				,@PeriodEnd
				,@FiscalYear
				,@PeriodNo
				,@ClerkId
				,@ClerkName
				,@ControlInfoId
				,@Amount
				,1
				,GETDATE()
				,'OPShift_Collected SaleDescription'
				,''
				,@POSTransactionId
				,1
				,1
				,0
				,0

			SELECT @ControlInfoId = ControlInfoID
			FROM tbControlINFO WITH (NOLOCK)
			WHERE ControlInfo = 'OPShift Collected Sale Invoice'

			INSERT INTO tbTransactionControlInfo (
				EntityID
				,EntityTypeID
				,OwnerEntityID
				,SystemTransactionID
				,POSTransactionID
				,TransactionDate
				,BusinessDay
				,StartDate
				,EndDate
				,FiscalYear
				,PeriodNo
				,ClerkID
				,ClerkName
				,ControlInfoID
				,ControlInfoAmount
				,ControlInfoCount
				,DateAdded
				,OtherInfo1
				,OtherInfo2
				,OtherInfo3
				,RegisterNumber
				,CurrentShiftNumber
				,PolledDataID
				,CurrentDayNumber
				)
			SELECT @EntityId
				,4
				,@OwnerEntityId
				,@TransactionSummaryId
				,@POSTransactionId2
				,@TransactionDate
				,@BusinessDay
				,@PeriodStart
				,@PeriodEnd
				,@FiscalYear
				,@PeriodNo
				,@ClerkId
				,@ClerkName
				,@ControlInfoId
				,@Amount
				,1
				,GETDATE()
				,'OPShift_Collected SaleInvoice'
				,'OPShift_Collected SaleInvoice'
				,@POSTransactionId
				,1
				,1
				,0
				,0

			SELECT @ControlInfoId = ControlInfoID
			FROM tbControlINFO WITH (NOLOCK)
			WHERE ControlInfo = 'OPShift Collected Sale Cash'

			INSERT INTO tbTransactionControlInfo (
				EntityID
				,EntityTypeID
				,OwnerEntityID
				,SystemTransactionID
				,POSTransactionID
				,TransactionDate
				,BusinessDay
				,StartDate
				,EndDate
				,FiscalYear
				,PeriodNo
				,ClerkID
				,ClerkName
				,ControlInfoID
				,ControlInfoAmount
				,ControlInfoCount
				,DateAdded
				,OtherInfo1
				,OtherInfo2
				,OtherInfo3
				,RegisterNumber
				,CurrentShiftNumber
				,PolledDataID
				,CurrentDayNumber
				)
			SELECT @EntityId
				,4
				,@OwnerEntityId
				,@TransactionSummaryId
				,@POSTransactionId2
				,@TransactionDate
				,@BusinessDay
				,@PeriodStart
				,@PeriodEnd
				,@FiscalYear
				,@PeriodNo
				,@ClerkId
				,@ClerkName
				,@ControlInfoId
				,@Amount
				,1
				,GETDATE()
				,'OPShift Collected Sale Cash'
				,'OPShift_Collected SaleCash'
				,@POSTransactionId
				,1
				,1
				,0
				,0
		END