First create solution

This commit is contained in:
2017-03-08 11:21:27 +01:00
commit a2fb86bacf
5508 changed files with 1082238 additions and 0 deletions
@@ -0,0 +1,210 @@
/****** Object: View [dbo].[vv_GLAccountRowsforBookEntry] Script Date: 05/18/2012 09:18:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[vv_GLAccountRowsforBookEntry]
AS
SELECT 1 PartnerType,
0 GLRowsTypeVAT,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t2.Customers Customers,
t2.F_DateExecution DateExecution,
t2.DocumentNumber DocumentNumber,
t2.RegistryNumber RegistryNumber,
CASE WHEN isnull(t1.IsReinvoice,0)=0 THEN t8.ChartOfAccounts
ELSE t8.ChartOfAccounts2
END DebitChartOfAccounts,
t9.ChartOfAccountsIn CreditChartOfAccounts,
t1.Controlling Controlling,
t1.JobNumberObjects JobNumberObjects,
t7.UniqueObjects UniqueObjects,
t1.CostPlace CostPlace,
t1.CostHolder CostHolder,
t2.F_CurrencyRate CurrencyRate,
t1.Amount AmountHUF,
CASE WHEN t2.F_CurrencyRate<>0 and t6.ShortName<>'HUF' THEN ROUND(t1.Amount/t2.F_CurrencyRate,2) ELSE 0 END AmountDEV,
t2.ShortName Note1,
'' Note2,
NULL VAT,
t1.ChartofAccounts ChartOfAccounts2,
isnull(t1.IsReinvoice,0) IsReinvoice,
t1.ContractRows ContractRows,
isnull(t1.F_ReadyforBookEntryRows,0) ReadyforBookEntryRows,
t2.Oid RegistryHeader,
Null InvoiceHeader,
t2.CurrentWorkflowSystemSteps WorkflowSystemSteps,
t1.WorkflowMessage WorkflowMessage
from RegistryRowsFinancialControlling t1 join RegistryHeader t2 on
t1.RegistryHeader=t2.Oid LEFT JOIN Controlling t3 ON
t1.Controlling=t3.Oid LEFT JOIN Customers t4 ON
t2.Customers=t4.Oid LEFT JOIN CustomersGLParameters t5 ON
t4.CustomersGLParameters=t5.Oid LEFT JOIN CurrencyName t6 ON
t2.F_CurrencyName=t6.Oid LEFT JOIN ContractRows t7 ON
t1.ContractRows=t7.Oid left join ControllingYear t8 on
t3.Oid=t8.Controlling and Year(t2.F_DateExecution)=t8.AccountYear left join CustomersGLParametersYear t9 on
t5.Oid=t9.CustomersGLParameters and Year(t2.F_DateExecution)=t9.AccountYear
WHERE t1.GCRecord IS NULL AND
isnull(t2.IsEditable,0)=0 AND
t2.F_GLAccounts IS NULL AND
isnull(t1.F_ReadyforBookEntryRows,0)=0
UNION ALL
SELECT 1 PartnerType,
1 GLRowsTypeVAT,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t2.Customers Customers,
isnull(isnull(t1.DateVAT,t2.F_DateVAT),t2.F_DateExecution) DateExecution,
t2.DocumentNumber DocumentNumber,
t2.RegistryNumber RegistryNumber,
t7.ChartOfAccountsIn DebitChartOfAccounts,
case when ISNULL(t3.InversState,0)=1 then t7.ChartOfAccountsOut
else t9.ChartOfAccountsIn end CreditChartOfAccounts,
NULL Controlling,
NULL JobNumberObjects,
NULL UniqueObjects,
NULL CostPlace,
NULL CostHolder,
1 CurrencyRate,
CASE WHEN t1.VAT IS NULL THEN 0
WHEN t1.VAT IS NOT NULL THEN
case when t3.InversState=0 then ROUND(t1.BruttoAmount/(1+t3.KeyValue)*t3.KeyValue,0)
else ROUND(t1.BruttoAmount/(1+t3.InversKeyValue)*t3.InversKeyValue,0) end
END AmountHUF,
0 AmountDEV,
t2.ShortName Note1,
'' Note2,
t1.VAT VAT,
NULL ChartOfAccounts2,
0 IsReinvoice,
NULL ContractRows,
isnull(t1.F_ReadyforBookEntryRows,0) ReadyforBookEntryRows,
t2.Oid RegistryHeader,
NULL InvoiceHeader,
t2.CurrentWorkflowSystemSteps WorkflowSystemSteps,
'' WorkflowMessage
from RegistryRowsFinancial t1 join RegistryHeader t2 on
t1.RegistryHeader=t2.Oid LEFT JOIN VAT t3 ON
t1.VAT=t3.oid LEFT JOIN Customers t4 ON
t2.Customers=t4.Oid LEFT JOIN CustomersGLParameters t5 ON
t4.CustomersGLParameters=t5.Oid LEFT JOIN CurrencyName t6 ON
t2.F_CurrencyName=t6.Oid left join VATYear t7 on
t3.Oid=t7.VAT and Year(t2.F_DateExecution)=t7.AccountYear left join CustomersGLParametersYear t9 on
t5.Oid=t9.CustomersGLParameters and Year(t2.F_DateExecution)=t9.AccountYear
WHERE t1.GCRecord IS NULL AND
isnull(t2.IsEditable,0)=0 AND
t2.F_GLAccounts IS NULL AND
isnull(t1.F_ReadyforBookEntryRows,0)=0
UNION ALL
SELECT 0 PartnerType,
0 GLRowsTypeVAT,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t2.Customers Customers,
t2.DateExecution DateExecution,
t2.DocumentNumber DocumentNumber,
'' RegistryNumber,
t11.ChartOfAccountsOut DebitChartOfAccounts,
isnull(t12.ChartOfAccounts,t10.ChartOfAccounts) CreditChartOfAccounts,
isnull(t8.Controlling,t1.Controlling) Controlling,
isnull(t8.JobNumberObjects,t1.JobNumberObjects) JobNumberObjects,
isnull(t8.UniqueObjects,t1.UniqueObjects) UniqueObjects,
isnull(t8.CostPlace,t1.CostPlace) CostPlace,
isnull(t8.CostHolder,t1.CostHolder) CostHolder,
t2.CurrencyRate CurrencyRate,
(t1.ListPriceHUF-t1.DiscountPriceHUF)*t1.QTT AmountHUF,
(t1.ListPriceDEV-t1.DiscountPriceDEV)*t1.QTT AmountDEV,
t2.Description Note1,
'' Note2,
NULL VAT,
t1.ChartofAccounts ChartOfAccounts2,
0 IsReinvoice,
t1.ContractRows ContractRows,
isnull(t1.ReadyforBookEntryRows,0) ReadyforBookEntryRows,
NULL RegistryHeader,
t2.Oid InvoiceHeader,
t1.WorkflowSystemSteps WorkflowSystemSteps,
'' WorkflowMessage
FROM InvoiceRows t1 JOIN InvoiceHeader t2 ON
t1.InvoiceHeader=t2.Oid LEFT JOIN Controlling t3 ON
t1.Controlling=t3.Oid LEFT JOIN Customers t4 ON
t2.Customers=t4.Oid LEFT JOIN CustomersGLParameters t5 ON
t4.CustomersGLParameters=t5.Oid LEFT JOIN CurrencyName t6 ON
t2.CurrencyName=t6.Oid LEFT JOIN InvoiceType t7 ON
t2.InvoiceType=t7.Oid LEFT JOIN ContractRows t8 ON
t1.ContractRows=t8.Oid LEFT JOIN Controlling t9 ON
t8.Controlling=t9.Oid left join ControllingYear t10 on
t3.Oid=t10.Controlling and Year(t2.DateExecution)=t10.AccountYear left join CustomersGLParametersYear t11 on
t5.Oid=t11.CustomersGLParameters and Year(t2.DateExecution)=t11.AccountYear left join ControllingYear t12 on
t9.Oid=t12.Controlling and Year(t2.DateExecution)=t12.AccountYear
WHERE t1.GCRecord IS NULL AND
isnull(t2.IsEditable,0)=0 AND
t2.GLAccounts IS NULL AND
isnull(t1.ReadyforBookEntryRows,0)=0 AND
t7.InvoiceTypeBase in (1,2,3) and
isnull(t2.IsProforma,0)=0
UNION ALL
SELECT 0 PartnerType,
1 GLRowsTypeVAT,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t2.Customers Customers,
t2.DateExecution DateExecution,
t2.DocumentNumber DocumentNumber,
'' RegistryNumber,
t9.ChartOfAccountsOut DebitChartOfAccounts,
t7.ChartOfAccountsOut CreditChartOfAccounts,
NULL Controlling,
NULL JobNumberObjects,
NULL UniqueObjects,
NULL CostPlace,
NULL CostHolder,
1 CurrencyRate,
t1.AmountVATHUF AmountHUF,
t1.AmountVATDEV AmountDEV,
t2.Description Note1,
'' Note2,
t1.VAT VAT,
NULL ChartOfAccounts2,
0 IsReinvoice,
NULL ContractRows,
isnull(t1.ReadyforBookEntryRows,0) ReadyforBookEntryRows,
NULL RegistryHeader,
t2.Oid InvoiceHeader,
Null WorkflowSystemSteps,
'' WorkflowMessage
from InvoiceVATRows t1 join InvoiceHeader t2 on
t1.InvoiceHeader=t2.Oid LEFT JOIN VAT t3 ON
t1.VAT=t3.oid LEFT JOIN Customers t4 ON
t2.Customers=t4.Oid LEFT JOIN CustomersGLParameters t5 ON
t4.CustomersGLParameters=t5.Oid LEFT JOIN CurrencyName t6 ON
t2.CurrencyName=t6.Oid LEFT JOIN InvoiceType t10 ON
t2.InvoiceType=t10.Oid left join VATYear t7 on
t3.Oid=t7.VAT and Year(t2.DateExecution)=t7.AccountYear left join CustomersGLParametersYear t9 on
t5.Oid=t9.CustomersGLParameters and Year(t2.DateExecution)=t9.AccountYear
WHERE t1.GCRecord IS NULL AND
isnull(t2.IsEditable,0)=0 AND
t2.GLAccounts IS NULL AND
isnull(t1.ReadyforBookEntryRows,0)=0 AND
isnull(t2.IsProforma,0)=0 AND
t10.InvoiceTypeBase in (1,2,3) --and
--t2.GLAccounts is null
GO
@@ -0,0 +1,101 @@
/****** Object: View [dbo].[vv_PartnerConnectionInfoAccount] Script Date: 05/18/2012 09:18:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_PartnerConnectionInfoAccount]
as
select '01-Account' MainType,
t2.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.Customer Customers,
t1.PartnerType PartnerType,
t4.ConnectInfo ConnectInfo,
t2.CurrencyName CurrencyName,
sum(t1.AmountHUF) BallanceHUF,
sum(t1.AmountDEV) BallanceDEV,
t3.ShortName Currency,
t2.DatePayment DatePayment,
t2.DateCreated DateCreated,
t2.DateExecution DateExecution,
t2.CurrencyRate CurrencyRate,
t2.DocumentNumber DocumentNumber,
max(t2.RegistryNumber) RegistryNumber
from GLRows t1 join GLHeader t2 on
t1.GLHeader=t2.Oid left join CurrencyName t3 on
t2.CurrencyName=t3.Oid left join GlAccounts t4 on
t1.GLHeader=t4.Oid
where t2.GCRecord is null and
t2.GLDocumentType=1 and
isnull(t2.IsEditable,0)=0 and
t1.PartnerType in (0,1) and
t1.GCRecord is null
group by t2.Oid,t2.CustomersFrom,t1.Customer,t1.PartnerType,
t4.ConnectInfo,t2.DocumentNumber,t2.CurrencyName,t3.ShortName,t2.DateExecution,t2.DatePayment,
t2.DateCreated,t2.DateExecution,t2.CurrencyRate
union all
select '01-Account' MainType,
t1.Oid Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
0 PartnerType,
t1.ConnectInfo ConnectInfo,
t1.CurrencyName CurrencyName,
t1.TotalBruttoHUF BallanceHUF,
t1.TotalBruttoDEV BallanceDEV,
t3.ShortName Currency,
t1.DatePayment DatePayment,
t1.DateCreated DateCreated,
t1.DateExecution DateExecution,
t1.CurrencyRate CurrencyRate,
t1.DocumentNumber DocumentNumber,
t1.DocumentNumber RegistryNumber
from InvoiceHeader t1 left join CurrencyName t3 on
t1.CurrencyName=t3.Oid
where t1.GLAccounts is null and
t1.IsEditable=0 and
t1.GCRecord is null
union all
select '01-Account' MainType,
t1.Oid Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
1 PartnerType,
t1.F_ConnectInfo ConnectInfo,
t1.F_CurrencyName CurrencyName,
t1.F_AmountBruttoHUF BallanceHUF,
t1.F_AmountBruttoDEV BallanceDEV,
t3.ShortName Currency,
t1.F_DatePayment DatePayment,
t1.F_DateCreated DateCreated,
t1.F_DateExecution DateExecution,
t1.F_CurrencyRate CurrencyRate,
t1.DocumentNumber DocumentNumber,
t1.RegistryNumber RegistryNumber
from RegistryHeader t1 left join RegistryType t2 on
t1.RegistryType=t2.Oid left join CurrencyName t3 on
t1.F_CurrencyName=t3.Oid
where t1.GCRecord is null and
t1.F_GLAccounts is null and
t1.IsEditable=0 and
t1.IsStorno=0 and
t2.RegistryMainType=0 and
t1.RegistryAcceptState=0
GO
@@ -0,0 +1,45 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_PartnerConnectionInfoAged] Script Date: 05/18/2012 09:19:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_PartnerConnectionInfoAged]
as
select t1.Oid Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t2.DocumentNumber DocumentNumber,
t2.RegistryNumber RegistryNumber,
t1.DateExecution DateExecution,
t1.DatePayment_Account DatePayment,
t1.CurrencyName_Account CurrencyName_Account,
t1.AmountHUF_Account AmountHUF,
t1.AmountDEV_Account AmountDEV,
t1.BallanceHUF BallanceHUF,
t1.BallanceDEV BallanceDEV,
t1.InvoiceHeader InvoiceHeader
from PCIDetail t1 join
vv_PartnerConnectionInfoAccount t2 on
t1.CustomersFrom=t2.CustomersFrom and
t1.Customers=t2.Customers and
t1.PartnerType=t2.PartnerType and
t1.ConnectInfo=t2.ConnectInfo
GO
@@ -0,0 +1,53 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_PartnerConnectionInfoConnect] Script Date: 05/18/2012 09:19:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_PartnerConnectionInfoConnect]
as
select
t1.MainType MainType,
t1.Oid Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t1.CurrencyName CurrencyName,
t1.DebitTotalHUF DebitTotalHUF,
t1.CreditTotalHUF CreditTotalHUF,
t1.DebitTotalDEV DebitTotalDEV,
t1.CreditTotalDEV CreditTotalDEV,
t1.BallanceHUF BallanceHUF,
t1.BallanceDEV BallanceDEV,
t1.ShortName ShortName,
t1.Description Description,
t1.DateExecution DateExecution,
t1.DateCreated DateCreated,
t1.DatePayment DatePayment,
t1.DelayedDay DelayedDay,
t1.DelayedRange DelayedRange,
t1.CurrencyName_Account CurrencyName_Account,
t1.AmountHUF_Account AmountHUF_Account,
t1.AmountDEV_Account AmountDEV_Account,
t1.DateExecution_Account DateExecution_Account,
t2.BallanceState BallanceState,
t2.BallanceRateDiff BallanceRateDiff
from vv_PartnerConnectionInfoDetail t1
join vv_PartnerConnectionInfoDetailGroup t2 on
t1.CustomersFrom=t2.CustomersFrom and
t1.Customers=t2.Customers and
t1.PartnerType=t2.PartnerType and
t1.ConnectInfo=t2.ConnectInfo
GO
@@ -0,0 +1,432 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_PartnerConnectionInfoDetail] Script Date: 05/18/2012 09:19:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_PartnerConnectionInfoDetail]
as
select '01-Account' MainType,
t2.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.Customer Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t2.CurrencyName CurrencyName,
max(t3.AmountHUFBrutto) DebitTotalHUF,
0 CreditTotalHUF,
max(t3.AmountDEVBrutto) DebitTotalDEV,
0 CreditTotalDEV,
max(t3.AmountHUFBrutto) BallanceHUF,
max(t3.AmountDEVBrutto) BallanceDEV,
'' ShortName,
'' Description,
t2.DateExecution DateExecution,
t2.DateCreated DateCreated,
t2.DatePayment DatePayment,
DATEDIFF(d,t2.DatePayment,getdate()) DelayedDay,
case when DATEDIFF(d,t2.DatePayment,getdate())<=0 then 0
when DATEDIFF(d,t2.DatePayment,getdate())>0 and DATEDIFF(d,t2.DatePayment,getdate())<=15 then 1
when DATEDIFF(d,t2.DatePayment,getdate())>15 and DATEDIFF(d,t2.DatePayment,getdate())<=30 then 2
when DATEDIFF(d,t2.DatePayment,getdate())>30 and DATEDIFF(d,t2.DatePayment,getdate())<=60 then 3
when DATEDIFF(d,t2.DatePayment,getdate())>60 and DATEDIFF(d,t2.DatePayment,getdate())<=90 then 4
when DATEDIFF(d,t2.DatePayment,getdate())>90 and DATEDIFF(d,t2.DatePayment,getdate())<=180 then 5
when DATEDIFF(d,t2.DatePayment,getdate())>180 and DATEDIFF(d,t2.DatePayment,getdate())<=360 then 6
when DATEDIFF(d,t2.DatePayment,getdate())>360 then 7
end DelayedRange,
t2.CurrencyName CurrencyName_Account,
sum(t1.AmountHUF) AmountHUF_Account,
sum(t1.AmountDEV) AmountDEV_Account,
t2.DateExecution DateExecution_Account
from GLRows t1 join GLHeader t2 on
t1.GLHeader=t2.Oid join GLAccounts t3 on
t1.GLHeader=t3.Oid
where t2.GCRecord is null and
t2.GLDocumentType=1 and
t2.IsEditable=0 and
t1.PartnerType in (0,1) and
t1.GCRecord is null
group by t2.Oid,t2.CustomersFrom,t1.Customer,t1.PartnerType,
t1.ConnectInfo,t2.CurrencyName,t2.DateExecution,t2.DateCreated,t2.DatePayment
union all
select '02-Bank' MainType,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.Customer Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t3.CurrencyName CurrencyName,
0 DebitTotalHUF,
case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)*-1
when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)*-1
end CreditTotalHUF,
0 DebitTotalDEV,
case when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)*-1
end CreditTotalDEV,
(case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)*-1
end)*-1 BallanceHUF,
(case when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.InAmountDEV)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.OutAmountDEV)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.OutAmountDEV)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.InAmountDEV)*-1
when t1.PartnerType=0 and sum(t1.InAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF'then sum(t1.InAmountDEV2)*-1
else 0
end)*-1 BallanceDEV,
max(t3.ShortName+', '+isnull(t2.DocumentNumber,'')) ShortName,
'' Description,
t2.DateExecution DateExecution,
t2.DateExecution DateCreated,
t4.DatePayment DatePayment,
0 DelayedDay,
'' DelayedRange,
t4.CurrencyName CurrencyName_Account,
0 AmountHUF_Account,
0 AmountDEV_Account,
max(t4.DateExecution) DateExecution_Account
from GLRows t1
join GLHeader t2 on t1.GLHeader=t2.Oid
left join GLBank t5 on t2.Oid=t5.Oid
left join LiquidAssets t3 on t5.LiquidAssets_Main=t3.Oid
left join vv_PartnerConnectionInfoAccount t4 on t2.CustomersFrom=t4.CustomersFrom
and t1.Customer=t4.Customers and t1.PartnerType=t4.PartnerType and t1.ConnectInfo=t4.ConnectInfo
where t2.GCRecord is null and
t2.GLDocumentType=2 and
t1.PartnerType in (0,1) and
t1.GCRecord is null
group by t1.Oid,t2.CustomersFrom,t1.Customer,t1.PartnerType,
t1.ConnectInfo,t3.CurrencyName,t4.Currency,t2.DateExecution,t4.DatePayment,t4.CurrencyName
union all
select '03-Cassa' MainType,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.Customer Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t3.CurrencyName CurrencyName,
0 DebitTotalHUF,
case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)*-1
when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)*-1
end CreditTotalHUF,
0 DebitTotalDEV,
case when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)*-1
end CreditTotalDEV,
(case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)*-1
end)*-1 BallanceHUF,
(case when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=0 and sum(t1.InAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF'then sum(t1.InAmountDEV2)*-1
end)*-1 BallanceDEV,
max(t3.ShortName+', '+isnull(t2.DocumentNumber,'')) ShortName,
'' Description,
t2.DateExecution DateExecution,
t2.DateExecution DateCreated,
t4.DatePayment DatePayment,
0 DelayedDay,
'' DelayedRange,
t4.CurrencyName CurrencyName_Account,
0 AmountHUF_Account,
0 AmountDEV_Account,
max(t4.DateExecution) DateExecution_Account
from GLRows t1
join GLHeader t2 on t1.GLHeader=t2.Oid
left join GLCassa t5 on t2.Oid=t5.Oid
left join LiquidAssets t3 on t5.LiquidAssets_Cassa=t3.Oid
left join vv_PartnerConnectionInfoAccount t4 on t2.CustomersFrom=t4.CustomersFrom and
t1.Customer=t4.Customers and t1.PartnerType=t4.PartnerType and t1.ConnectInfo=t4.ConnectInfo
where t2.GCRecord is null and
t2.GLDocumentType=3 and
t1.PartnerType in (0,1) and
t1.GCRecord is null
group by t1.Oid,t2.CustomersFrom,t1.Customer,t1.PartnerType,
t1.ConnectInfo,t3.CurrencyName,t4.Currency,t2.DateExecution,t4.DatePayment,t4.CurrencyName
union all
select '05-Ratediff' MainType,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.Customer Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t2.CurrencyName CurrencyName,
0 DebitTotalHUF,
case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)*-1
end CreditTotalHUF,
0 DebitTotalDEV,
0 CreditTotalDEV,
(case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)*-1
end)*-1 BallanceHUF,
0 BallanceDEV,
max(isnull(t7.ShortName,'')+', '++isnull(t8.DocumentNumber,'')+', '+isnull(t2.DocumentNumber,'')) ShortName,
'' Description,
t2.DateExecution DateExecution,
t2.DateExecution DateCreated,
Null DatePayment,
0 DelayedDay,
'' DelayedRange,
t4.CurrencyName CurrencyName_Account,
0 AmountHUF_Account,
0 AmountDEV_Account,
max(t4.DateExecution) DateExecution_Account
from GLRows t1
join GLHeader t2 on t1.GLHeader=t2.Oid
left join LiquidAssets t3 on t1.LiquidAssets=t3.Oid
left join vv_PartnerConnectionInfoAccount t4 on t2.CustomersFrom=t4.CustomersFrom and
t1.Customer=t4.Customers and t1.PartnerType=t4.PartnerType and t1.ConnectInfo=t4.ConnectInfo
left join GLRows t6 on
t1.GLRowsRateDiff=t6.Oid left join LiquidAssets t7 on
t6.LiquidAssets=t7.oid left join GLHeader t8 on
t6.GLHeader=t8.oid
where t2.GCRecord is null and
t2.GLDocumentType=5 and
t1.PartnerType in (0,1) and
t1.GCRecord is null
group by t1.Oid,t2.CustomersFrom,t1.Customer,t1.PartnerType,
t1.ConnectInfo,t2.CurrencyName,t2.DateExecution,t2.DatePayment,t4.CurrencyName
union all
select case when max(t2.GLDocumentType)=4 then '04-Compensation'
when max(t2.GLDocumentType)=0 then '06-Mixed'
end MainType,
t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.Customer Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
t3.CurrencyName CurrencyName,
0 DebitTotalHUF,
case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountHUF)*-1
when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)*-1
end CreditTotalHUF,
0 DebitTotalDEV,
case when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName then sum(t1.InAmountDEV2)*-1
end CreditTotalDEV,
(case when t1.PartnerType=0 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=0 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)*-1
when t1.PartnerType=1 and sum(t1.OutAmountHUF)<>0 then sum(t1.AmountHUF)
when t1.PartnerType=1 and sum(t1.InAmountHUF)<>0 then sum(t1.AmountHUF)*-1
end)*-1 BallanceHUF,
(case when t1.PartnerType=0 and sum(t1.InAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=0 and sum(t1.OutAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)
when t1.PartnerType=1 and sum(t1.InAmountDEV)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)=t3.CurrencyName then sum(t1.AmountDEV)*-1
when t1.PartnerType=0 and sum(t1.InAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.InAmountDEV2)
when t1.PartnerType=0 and sum(t1.OutAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.OutAmountDEV2)*-1
when t1.PartnerType=1 and sum(t1.OutAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF' then sum(t1.OutAmountDEV2)
when t1.PartnerType=1 and sum(t1.InAmountDEV2)<>0 and
isnull(t4.CurrencyName,t3.CurrencyName)<>t3.CurrencyName and t4.Currency<>'HUF'then sum(t1.InAmountDEV2)*-1
else 0
end)*-1 BallanceDEV,
max(t3.ShortName+', '+t2.DocumentNumber) ShortName,
'' Description,
t2.DateExecution DateExecution,
t2.DateExecution DateCreated,
t2.DateExecution DatePayment,
0 DelayedDay,
'' DelayedRange,
t4.CurrencyName CurrencyName_Account,
0 AmountHUF_Account,
0 AmountDEV_Account,
max(t4.DateExecution) DateExecution_Account
from GLRows t1
join GLHeader t2 on t1.GLHeader=t2.Oid
left join GLCompensation t5 on t2.Oid=t5.Oid left
join LiquidAssets t3 on t5.LiquidAssets_Main=t3.Oid
left join vv_PartnerConnectionInfoAccount t4 on t2.CustomersFrom=t4.CustomersFrom and
t1.Customer=t4.Customers and t1.PartnerType=t4.PartnerType and t1.ConnectInfo=t4.ConnectInfo
where t2.GCRecord is null and
t2.GLDocumentType in (4,0) and
t1.PartnerType in (0,1) and
t1.GCRecord is null
group by t1.Oid,t2.CustomersFrom,t1.Customer,t1.PartnerType,
t1.ConnectInfo,t3.CurrencyName,t4.Currency,t2.DateExecution,t4.DatePayment,t4.CurrencyName
union all
select '01-Account' MainType,
t1.Oid Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
0 PartnerType,
t1.ConnectInfo ConnectInfo,
t1.CurrencyName CurrencyName,
t1.TotalBruttoHUF DebitTotalHUF,
0 CreditTotalHUF,
t1.TotalBruttoDEV DebitTotalDEV,
0 CreditTotalDEV,
t1.TotalBruttoHUF BallanceHUF,
t1.TotalBruttoDEV BallanceDEV,
'' ShortName,
t1.Description Description,
t1.DateExecution DateExecution,
t1.DateCreated DateCreated,
t1.DatePayment DatePayment,
DATEDIFF(d,t1.DatePayment,getdate()) DelayedDay,
case when DATEDIFF(d,t1.DatePayment,getdate())<=0 then 0
when DATEDIFF(d,t1.DatePayment,getdate())>0 and DATEDIFF(d,t1.DatePayment,getdate())<=15 then 1
when DATEDIFF(d,t1.DatePayment,getdate())>15 and DATEDIFF(d,t1.DatePayment,getdate())<=30 then 2
when DATEDIFF(d,t1.DatePayment,getdate())>30 and DATEDIFF(d,t1.DatePayment,getdate())<=60 then 3
when DATEDIFF(d,t1.DatePayment,getdate())>60 and DATEDIFF(d,t1.DatePayment,getdate())<=90 then 4
when DATEDIFF(d,t1.DatePayment,getdate())>90 and DATEDIFF(d,t1.DatePayment,getdate())<=180 then 5
when DATEDIFF(d,t1.DatePayment,getdate())>180 and DATEDIFF(d,t1.DatePayment,getdate())<=360 then 6
when DATEDIFF(d,t1.DatePayment,getdate())>360 then 7
end DelayedRange,
t1.CurrencyName CurrencyName_Account,
t1.TotalBruttoHUF AmountHUF_Account,
t1.TotalBruttoDEV AmountDEV_Account,
t1.DateExecution DateExecution_Account
from InvoiceHeader t1
where t1.GLAccounts is null and
t1.IsEditable=0 and
t1.GCRecord is null
union all
select '01-Account' MainType,
t1.Oid Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
1 PartnerType,
t1.DocumentNumber ConnectInfo,
t1.F_CurrencyName CurrencyName,
t1.F_AmountBruttoHUF DebitTotalHUF,
0 CreditTotalHUF,
t1.F_AmountBruttoDEV DebitTotalDEV,
0 CreditTotalDEV,
t1.F_AmountBruttoHUF BallanceHUF,
t1.F_AmountBruttoDEV BallanceDEV,
'' ShortName,
'' Description,
t1.F_DateExecution DateExecution,
t1.F_DateCreated DateCreated,
t1.F_DatePayment DatePayment,
DATEDIFF(d,t1.F_DatePayment,getdate()) DelayedDay,
case when DATEDIFF(d,t1.F_DatePayment,getdate())<=0 then 0
when DATEDIFF(d,t1.F_DatePayment,getdate())>0 and DATEDIFF(d,t1.F_DatePayment,getdate())<=15 then 1
when DATEDIFF(d,t1.F_DatePayment,getdate())>15 and DATEDIFF(d,t1.F_DatePayment,getdate())<=30 then 2
when DATEDIFF(d,t1.F_DatePayment,getdate())>30 and DATEDIFF(d,t1.F_DatePayment,getdate())<=60 then 3
when DATEDIFF(d,t1.F_DatePayment,getdate())>60 and DATEDIFF(d,t1.F_DatePayment,getdate())<=90 then 4
when DATEDIFF(d,t1.F_DatePayment,getdate())>90 and DATEDIFF(d,t1.F_DatePayment,getdate())<=180 then 5
when DATEDIFF(d,t1.F_DatePayment,getdate())>180 and DATEDIFF(d,t1.F_DatePayment,getdate())<=360 then 6
when DATEDIFF(d,t1.F_DatePayment,getdate())>360 then 7
end DelayedRange,
t1.F_CurrencyName CurrencyName_Account,
t1.F_AmountBruttoHUF AmountHUF_Account,
t1.F_AmountBruttoDEV AmountDEV_Account,
t1.F_DateExecution DateExecution_Account
from RegistryHeader t1
left join RegistryType t2 on t1.RegistryType=t2.Oid
where t1.GCRecord is null and
t1.F_GLAccounts is null and
t1.IsEditable=0 and
t1.IsStorno=0 and
t2.RegistryMainType=0 and
t1.RegistryAcceptState=0
GO
@@ -0,0 +1,70 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_PartnerConnectionInfoDetailGroup] Script Date: 05/18/2012 09:19:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_PartnerConnectionInfoDetailGroup]
as
select MAX(convert(varchar(100),t1.Oid)) Oid,
t1.CustomersFrom CustomersFrom,
t1.Customers Customers,
t1.PartnerType PartnerType,
t1.ConnectInfo ConnectInfo,
max(t2.ShortName) Currency,
sum(t1.DebitTotalHUF) DebitTotalHUF,
SUM(t1.CreditTotalHUF) CreditTotalHUF,
sum(t1.DebitTotalDEV) DebitTotalDEV,
SUM(t1.CreditTotalDEV) CreditTotalDEV,
SUM(t1.BallanceHUF) BallanceHUF,
SUM(t1.BallanceDEV) BallanceDEV,
case when t1.PartnerType=1 then SUM(t1.BallanceHUF)*-1 else 0 end BallanceHUF_P,
case when t1.PartnerType=1 then SUM(t1.BallanceDEV)*-1 else 0 end BallanceDEV_P,
case when t1.PartnerType=0 then SUM(t1.BallanceHUF) else 0 end BallanceHUF_R,
case when t1.PartnerType=0 then SUM(t1.BallanceDEV) else 0 end BallanceDEV_R,
(case when t1.PartnerType=0 then SUM(t1.BallanceHUF) else 0 end) -
(case when t1.PartnerType=1 then SUM(t1.BallanceHUF)*-1 else 0 end) BallanceHUF_B,
(case when t1.PartnerType=0 then SUM(t1.BallanceDEV) else 0 end) -
(case when t1.PartnerType=1 then SUM(t1.BallanceDEV)*-1 else 0 end) BallanceDEV_B,
max(t3.ShortName) Currency_Account,
sum(t1.AmountHUF_Account) AmountHUF_Account,
sum(t1.AmountDEV_Account) AmountDEV_Account,
case when max(t3.ShortName)='HUF' then
case when round(SUM(t1.BallanceHUF),0)=0 then 1
else 0
end
else
case when round(SUM(t1.BallanceDEV),2)=0 then 1
else 0
end
end BallanceState,
case when max(t3.ShortName)='HUF' then -1
when t1.CurrencyName_Account IS null then -1
else
case when round(SUM(t1.BallanceDEV),2)=0 and round(SUM(t1.BallanceHUF),0)<>0 then 1
else 0
end
end BallanceRateDiff,
max(t4.DateExecution) DateExecution_Account,
MAX(t4.DateCreated) DateCreated_Account
from vv_PartnerConnectionInfoDetail t1
left join CurrencyName t2 on t1.CurrencyName=t2.Oid
left join CurrencyName t3 on t1.CurrencyName_Account=t3.Oid
left join vv_PartnerConnectionInfoAccount t4 on
t1.CustomersFrom=t4.CustomersFrom and
t1.Customers=t4.Customers and
t1.PartnerType=t4.PartnerType and
t1.ConnectInfo=t4.ConnectInfo and
t4.MainType='01-Account'
group by t1.CustomersFrom,t1.Customers,t1.PartnerType,t1.ConnectInfo,t1.CurrencyName_Account
GO
@@ -0,0 +1,24 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_ProductSelect] Script Date: 05/18/2012 09:20:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_ProductSelect]
as
select Oid=case when t2.Oid IS null then t1.Oid else t2.Oid end,
Products=t1.Oid,
StorageComputed=t2.oid
from Products t1 left join StorageComputed t2 on
t1.Oid=t2.Products
where t1.GCRecord is null and t2.GCRecord is null
GO
@@ -0,0 +1,44 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_RegistryBankTransfer] Script Date: 05/18/2012 09:20:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_RegistryBankTransfer]
as
select t1.Oid Oid,
t1.RegistryHeader RegistryHeader,
t1.AmountHUF AmountHUF,
t1.AmountDEV AmountDEV,
t1.DatePayment DatePayment,
t1.IsBlocked IsBlocked,
t1.Note Note,
t1.BankSavedFileName BankSavedFileName,
isnull(t3.BallanceHUF,t2.F_AmountBruttoHUF) BallanceHUF,
isnull(t3.BallanceDEV,t2.F_AmountBruttoDEV) BallanceDEV,
t1.AmountHUF-isnull(t3.BallanceHUF,t2.F_AmountBruttoHUF) DifferenceHUF,
t1.AmountDEV-isnull(t3.BallanceDEV,t2.F_AmountBruttoDEV) DifferenceDEV,
case when round(isnull(t3.BallanceHUF,t2.F_AmountBruttoHUF),2)=0 then 0
when isnull(t3.BallanceHUF,t2.F_AmountBruttoHUF)>=t1.AmountHUF then t1.AmountHUF
when isnull(t3.BallanceHUF,t2.F_AmountBruttoHUF)<=t1.AmountHUF then isnull(t3.BallanceHUF,t2.F_AmountBruttoHUF)
end OfferedHUF,
case when round(isnull(t3.BallanceDEV,t2.F_AmountBruttoDEV),2)=0 then 0
when isnull(t3.BallanceDEV,t2.F_AmountBruttoDEV)>=t1.AmountDEV then t1.AmountDEV
when isnull(t3.BallanceDEV,t2.F_AmountBruttoDEV)<=t1.AmountDEV then isnull(t3.BallanceDEV,t2.F_AmountBruttoDEV)
end OfferedDEV,
t1.BankPrepareName BankPrepareName
from RegistryBankTransfer t1
join RegistryHeader t2 on t1.RegistryHeader=t2.Oid
left join PCIGroup t3 on t2.CustomersFrom=t3.CustomersFrom
and t2.Customers=t3.Customers and t3.PartnerType=1 and t2.DocumentNumber=t3.ConnectInfo
where t1.GCRecord is null and t2.RegistryAcceptState=0
GO
@@ -0,0 +1,20 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_RegistryBankTransferPrepareName] Script Date: 05/18/2012 09:20:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_RegistryBankTransferPrepareName]
as
select max(convert(varchar(100),Oid)) Oid,
BankPrepareName
from RegistryBankTransfer
where Isnull(BankPrepareName,'')<>''
group by BankPrepareName
GO
@@ -0,0 +1,92 @@
USE [SISTEST]
GO
/****** Object: View [dbo].[vv_WaitforRateDiff] Script Date: 05/18/2012 09:20:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [dbo].[vv_WaitforRateDiff]
as
select t1.Oid Oid,
t2.CustomersFrom CustomersFrom,
t1.PartnerType PartnerType,
t1.Customer Customers,
t1.ConnectInfo ConnectInfo,
t3.DateExecution DateExecution_Account,
t3.CurrencyName CurrencyName_Account,
round(t4.AmountDEV_Account,2) AmountDEV_Account,
round(t4.AmountHUF_Account,2) AmountHUF_Account,
round(t4.BallanceDEV,2) BallanceDEV_Account,
case when round(t4.AmountDEV_Account,2)<>0 then round(round(t4.AmountHUF_Account,2)/round(t4.AmountDEV_Account,2),2) else 0 end CurrencyRate_Account,
t1.LiquidAssets LiquidAssets,
t2.DateExecution DateExecution,
round(t1.InAmountDEV,2) InAmountDEV,
round(t1.OutAmountDEV,2) OutAmountDEV,
round(t1.InAmountDEV2,2) InAmountDEV2,
round(t1.OutAmountDEV2,2) OutAmountDEV2,
case when InAmountHUF>0 then
case when t1.InAmountDEV <>0 then round(t1.InAmountHUF,2)/round(t1.InAmountDEV,2)
else 0
end
else
case when t1.OutAmountDEV <>0 then round(t1.OutAmountHUF,2)/round(t1.OutAmountDEV,2)
else 0
end
end CurrencyRate,
round(t1.InAmountHUF,2) InAmountHUF,
round(t1.OutAmountHUF,2) OutAmountHUF,
case when t3.CurrencyName=t5.CurrencyName then round(t1.InAmountDEV,2)* round(t3.CurrencyRate,2)
else round(t1.InAmountDEV2,2)* round(t3.CurrencyRate,2)
end InAmountHUF_Account,
case when t3.CurrencyName=t5.CurrencyName then round(t1.OutAmountDEV,2)*round(t3.CurrencyRate,2)
else round(t1.OutAmountDEV2,2)*round(t3.CurrencyRate,2)
end OutAmountHUF_Account,
case when t3.CurrencyName=t5.CurrencyName then round(t1.InAmountDEV,2)* round(t3.CurrencyRate,2)
else round(t1.InAmountDEV2,2)* round(t3.CurrencyRate,2)
end - round(t1.InAmountHUF,2) InAmountHUF_Diff,
case when t3.CurrencyName=t5.CurrencyName then round(t1.OutAmountDEV,2)*round(t3.CurrencyRate,2)
else round(t1.OutAmountDEV2,2)*round(t3.CurrencyRate,2)
end - round(t1.OutAmountHUF,2) OutAmountHUF_Diff,
t1.GLRowsRatediff GLRowsRatediff,
case when t1.PartnerType = 0 Then
case when case when t3.CurrencyName=t5.CurrencyName then round(t1.InAmountDEV,2)* round(t3.CurrencyRate,2)
else round(t1.InAmountDEV2,2)* round(t3.CurrencyRate,2)
end - round(t1.InAmountHUF,2) > 0 Then -1
else 1
end
when t1.PartnerType = 1 Then
case when case when t3.CurrencyName=t5.CurrencyName then round(t1.OutAmountDEV,2)*round(t3.CurrencyRate,2)
else round(t1.OutAmountDEV2,2)*round(t3.CurrencyRate,2)
end - round(t1.OutAmountHUF,2) > 0 Then 1
else -1
end
else 0
end RateDiffState
from GLRows t1
left join GLHeader t2 on t1.GLHeader=t2.Oid
join vv_PartnerConnectionInfoAccount t3 on t2.CustomersFrom=t3.CustomersFrom
and t1.PartnerType=t3.PartnerType and t1.Customer=t3.Customers and t1.ConnectInfo=t3.ConnectInfo
left join PCIGroup t4 on t2.CustomersFrom=t4.CustomersFrom
and t1.PartnerType=t4.PartnerType and t1.Customer=t4.Customers and t1.ConnectInfo=t4.ConnectInfo
left join LiquidAssets t5 on t1.LiquidAssets=t5.Oid
left join CurrencyName t6 on t5.CurrencyName=t6.Oid
left join CurrencyName t7 on t3.CurrencyName=t7.Oid
where t2.GCRecord is null and
t2.GLDocumentType in (2,3,4) and
t6.ShortName <> 'HUF' and isnull(t7.ShortName,'HUF')<>'HUF' and
((t1.PartnerType=0 and t1.InAmountHUF>0) or (t1.PartnerType=1 and t1.OutAmountHUF>0))
GO