Reconfigure for GIT

This commit is contained in:
2017-03-26 20:00:03 +02:00
commit 00637826ab
8056 changed files with 535977 additions and 0 deletions
@@ -0,0 +1,193 @@
SELECT 1 As "PartnerType",
0 As "GLRowsTypeVAT",
t1."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t2."Customers" As "Customers",
t2."F_DateExecution" As "DateExecution",
t2."DocumentNumber" As "DocumentNumber",
t2."RegistryNumber" As "RegistryNumber",
CASE WHEN coalesce(t1."IsReInvoice",false)=false THEN t3."ChartOfAccounts"
ELSE t8."ChartOfAccounts2"
END As "DebitChartOfAccounts",
t9."ChartOfAccountsIn" As "CreditChartOfAccounts",
t1."Controlling" As "Controlling",
t1."JobNumberObjects" As "JobNumberObjects",
t7."UniqueObjects" As "UniqueObjects",
t1."CostPlace" As "CostPlace",
t1."CostHolder" As "CostHolder",
t2."F_CurrencyRate" As "CurrencyRate",
t1."Amount" As "AmountHUF",
CASE WHEN t2."F_CurrencyRate"<>0 AND t6."ShortName"<>'HUF' THEN ROUND(cast(t1."Amount"/t2."F_CurrencyRate" AS numeric),2) ELSE 0 END As "AmountDEV",
t2."ShortName" As "Note1",
'' As "Note2",
NULL As "VAT",
t1."ChartOfAccounts" As "ChartOfAccounts2",
coalesce(t1."IsReInvoice",false) As "IsReinvoice",
t1."ContractRows" As "ContractRows",
coalesce(t1."F_ReadyforBookEntryRows",false) As "ReadyforBookEntryRows",
t2."Oid" As "RegistryHeader",
NULL As "InvoiceHeader",
t2."CurrentWorkflowSystemSteps" As "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 extract(year from cast(t2."F_DateExecution" as timestamp))=t8."AccountYear" left join "CustomersGLParametersYear" t9 on
t5."Oid"=t9."CustomersGLParameters" and extract(year from cast(t2."F_DateExecution"as timestamp))=t9."AccountYear"
WHERE t1."GCRecord" IS NULL AND
coalesce(t2."IsEditable",false)=false AND
t2."F_GLAccounts" IS NULL AND
coalesce(t1."F_ReadyforBookEntryRows",false)=false
UNION ALL
SELECT 1 As "PartnerType",
1 As "GLRowsTypeVAT",
t1."Oid"As " Oid",
t2."CustomersFrom" As "CustomersFrom",
t2."Customers" As "Customers",
coalesce(coalesce(t1."DateVAT",t2."F_DateVAT"),t2."F_DateExecution") As "DateExecution",
t2."DocumentNumber" As "DocumentNumber",
t2."RegistryNumber" As "RegistryNumber",
t3."ChartOfAccountsIn" As "DebitChartOfAccounts",
case when coalesce(t3."InversState",false)=true then t7."ChartOfAccountsOut"
else t9."ChartOfAccountsIn" end "CreditChartOfAccounts",
NULL As "Controlling",
NULL As "JobNumberObjects",
NULL As "UniqueObjects",
NULL As "CostPlace",
NULL As "CostHolder",
1 As "CurrencyRate",
CASE WHEN t1."VAT" IS NULL THEN 0
WHEN t1."VAT" IS NOT NULL THEN
case when t3."InversState"=false then ROUND(cast(t1."BruttoAmount"/(1+t3."KeyValue")*t3."KeyValue" as numeric),0)
else ROUND(cast(t1."BruttoAmount"/(1+t3."InversKeyValue")*t3."InversKeyValue" as numeric),0) end
END "AmountHUF",
0 As "AmountDEV",
t2."ShortName" As "Note1",
'' As "Note2",
t1."VAT" As "VAT",
NULL As "ChartOfAccounts2",
false As "IsReinvoice",
NULL As "ContractRows",
coalesce(t1."F_ReadyforBookEntryRows",false) As "ReadyforBookEntryRows",
t2."Oid" As "RegistryHeader",
NULL As "InvoiceHeader",
t2."CurrentWorkflowSystemSteps" As "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 extract(year from cast(t2."F_DateExecution" as timestamp))=t7."AccountYear" left join "CustomersGLParametersYear" t9 on
t5."Oid"=t9."CustomersGLParameters" and extract(year from cast(t2."F_DateExecution" as timestamp))=t9."AccountYear"
WHERE t1."GCRecord" IS NULL AND
coalesce(t2."IsEditable",false)=false AND
t2."F_GLAccounts" IS NULL AND
coalesce(t1."F_ReadyforBookEntryRows",false)=false
UNION ALL
SELECT 0 As "PartnerType",
0 As "GLRowsTypeVAT",
t1."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t2."Customers" As "Customers",
t2."DateExecution" As "DateExecution",
t2."DocumentNumber" As "DocumentNumber",
'' As "RegistryNumber",
t11."ChartOfAccountsOut" As "DebitChartOfAccounts",
coalesce(t12."ChartOfAccounts",t10."ChartOfAccounts") As "CreditChartOfAccounts",
coalesce(t8."Controlling",t1."Controlling") As "Controlling",
coalesce(t8."JobNumberObjects",t1."JobNumberObjects") As "JobNumberObjects",
coalesce(t8."UniqueObjects",t1."UniqueObjects") As "UniqueObjects",
coalesce(t8."CostPlace",t1."CostPlace") As "CostPlace",
coalesce(t8."CostHolder",t1."CostHolder") As "CostHolder",
t2."CurrencyRate" As "CurrencyRate",
(t1."ListPriceHUF"-t1."DiscountPriceHUF")*t1."QTT" As "AmountHUF",
(t1."ListPriceDEV"-t1."DiscountPriceDEV")*t1."QTT" As "AmountDEV",
t2."Description" As "Note1",
'' As "Note2",
NULL As "VAT",
t1."ChartOfAccounts" As "ChartOfAccounts2",
false As "IsReinvoice",
t1."ContractRows" As "ContractRows",
coalesce(t1."ReadyforBookEntryRows",false) As "ReadyforBookEntryRows",
NULL As "RegistryHeader",
t2."Oid" As "InvoiceHeader",
t1."WorkflowSystemSteps" As "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 extract(year from cast(t2."DateExecution" as timestamp))=t10."AccountYear" left join "CustomersGLParametersYear" t11 on
t5."Oid"=t11."CustomersGLParameters" and extract(year from cast(t2."DateExecution" as timestamp))=t11."AccountYear" left join "ControllingYear" t12 on
t9."Oid"=t12."Controlling" and extract(year from cast(t2."DateExecution" as timestamp))=t12."AccountYear"
WHERE t1."GCRecord" IS NULL AND
coalesce(t2."IsEditable",false)=false AND
t2."GLAccounts" IS NULL AND
coalesce(t1."ReadyforBookEntryRows",false)=false AND
t7."InvoiceTypeBase" IN (1,2,3) AND
coalesce(t2."IsProforma",false)=false
UNION ALL
SELECT 0 As "PartnerType",
1 As "GLRowsTypeVAT",
t1."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t2."Customers" As "Customers",
t2."DateExecution" As "DateExecution",
t2."DocumentNumber" As "DocumentNumber",
'' As "RegistryNumber",
t9."ChartOfAccountsOut" As "DebitChartOfAccounts",
t7."ChartOfAccountsOut" As "CreditChartOfAccounts",
NULL As "Controlling",
NULL As "JobNumberObjects",
NULL As "UniqueObjects",
NULL As "CostPlace",
NULL As "CostHolder",
1 As "CurrencyRate2",
t1."AmountVATHUF" As "AmountHUF",
t1."AmountVATDEV" As "AmountDEV",
t2."Description" As "Note1",
'' As "Note2",
t1."VAT" As "VAT",
NULL As "ChartOfAccounts2",
false As "IsReinvoice",
NULL As "ContractRows",
coalesce(t1."ReadyforBookEntryRows",false) As "ReadyforBookEntryRows",
NULL As "RegistryHeader",
t2."Oid" As "InvoiceHeader",
Null As "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 extract(year from cast(t2."DateExecution" as timestamp))=t7."AccountYear" left join "CustomersGLParametersYear" t9 on
t5."Oid"=t9."CustomersGLParameters" and extract(year from cast(t2."DateExecution" as timestamp))=t9."AccountYear"
WHERE t1."GCRecord" IS NULL AND
coalesce(t2."IsEditable",false)=false AND
t2."GLAccounts" IS NULL AND
coalesce(t1."ReadyforBookEntryRows",false)=false AND
coalesce(t2."IsProforma",false)=false AND
t10."InvoiceTypeBase" IN (1,2,3)
@@ -0,0 +1,81 @@
SELECT '01-Account' AS "MainType",
t2."Oid" AS "Oid",
t2."CustomersFrom" AS "CustomersFrom",
t1."Customer" AS "Customers",
t1."PartnerType" AS "PartnerType",
t2."DocumentNumber" AS "ConnectInfo",
t2."CurrencyName" AS "CurrencyName",
sum(t1."AmountHUF") AS "BallanceHuf",
sum(t1."AmountDEV") AS "BallanceDev",
t3."ShortName" AS "Currency",
t2."DatePayment" AS "DatePayment",
t2."DateCreated" AS "DateCreated",
t2."DateExecution" AS "DateExecution",
t2."CurrencyRate" AS "CurrencyRate",
t2."DocumentNumber" AS "DocumentNumber",
max(t2."RegistryNumber") AS "RegistryNumber"
from "GLRows" t1
join "GLHeader" t2 on t1."GLHeader"=t2."Oid"
left join "CurrencyName" t3 on t2."CurrencyName"=t3."Oid"
where t2."GCRecord" is null and
t2."GLDocumentType"=1 and
coalesce(t2."IsEditable", false) = false and
t1."PartnerType" in (0,1) and
t1."GCRecord" is null
group by t2."Oid",t2."CustomersFrom",t1."Customer",t1."PartnerType",
t2."DocumentNumber",t2."CurrencyName",t3."ShortName",t2."DateExecution",t2."DatePayment",
t2."DateCreated",t2."DateExecution",t2."CurrencyRate"
union all
SELECT '01-Account' AS "MainType",
t1."Oid" AS "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
0 AS "PartnerType",
t1."DocumentNumber" AS "ConnectInfo",
t1."CurrencyName" AS currencyname,
t1."TotalBruttoHUF" AS "BallanceHuf",
t1."TotalBruttoDEV" AS "BallanceDev",
t3."ShortName" AS "Currency",
t1."DatePayment" AS "DatePayment",
t1."DateCreated" AS "DateCreated",
t1."DateExecution" AS "DateExecution",
t1."CurrencyRate" AS "CurrencyRate",
t1."DocumentNumber" AS "DocumentNumber",
t1."DocumentNumber" AS "RegistryNumber"
from "InvoiceHeader" t1
left join "CurrencyName" t3 on t1."CurrencyName"=t3."Oid"
where t1."GLAccounts" is null and
t1."IsEditable"= false and
t1."GCRecord" is null
union all
SELECT '01-Account' AS "MainType",
t1."Oid" AS "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
1 AS "PartnerType",
t1."DocumentNumber" AS "ConnectInfo",
t1."F_CurrencyName" AS currencyname,
t1."F_AmountBruttoHUF" AS "BallanceHuf",
t1."F_AmountBruttoDEV" AS "BallanceDev",
t3."ShortName" AS "Currency",
t1."F_DatePayment" AS "DatePayment",
t1."F_DateCreated" AS "DateCreated",
t1."F_DateExecution" AS "DateExecution",
t1."F_CurrencyRate" AS "CurrencyRate",
t1."DocumentNumber" AS "DocumentNumber",
t1."RegistryNumber" AS "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"= false and
t1."IsStorno"= false and
t2."RegistryMainType"=0 and
t1."RegistryAcceptState"=0
@@ -0,0 +1,23 @@
select t1."Oid" AS "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
t1."PartnerType" AS "PartnerType",
t1."ConnectInfo" AS "ConnectInfo",
t2."DocumentNumber" AS "DocumentNumber",
t2."RegistryNumber" AS "RegistryNumber",
t1."DateExecution" AS "DateExecution",
t1."DatePayment_Account"AS "DatePayment",
t1."CurrencyName_Account" AS "CurrencyName_Account",
t1."AmountHUF_Account" AS "AmountHUF",
t1."AmountDEV_Account" AS "AmountDEV",
t1."BallanceHUF" AS "BallanceHUF",
t1."BallanceDEV" AS "BallanceDEV",
t1."InvoiceHeader" AS "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"
@@ -0,0 +1,35 @@
select
t1."MainType" AS "MainType",
t1."Oid" AS "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
t1."PartnerType" AS "PartnerType",
t1."ConnectInfo" AS "ConnectInfo",
t1."CurrencyName" AS "CurrencyName",
t1."DebitTotalHUF" AS "DebitTotalHUF",
t1."CreditTotalHUF" AS "CreditTotalHUF",
t1."DebitTotalDEV" AS "DebitTotalDEV",
t1."CreditTotalDEV" AS "CreditTotalDEV",
t1."BallanceHUF" AS "BallanceHUF",
t1."BallanceDEV" AS "BallanceDEV",
t1."ShortName" AS "ShortName",
t1."Description" AS "Description",
t1."DateExecution" AS "DateExecution",
t1."DateCreated" AS "DateCreated",
t1."DatePayment" AS "DatePayment",
t1."DelayedDay" AS "DelayedDay",
t1."DelayedRange" AS "DelayedRange",
t1."CurrencyName_Account" AS "CurrencyName_Account",
t1."AmountHUF_Account" AS "AmountHUF_Account",
t1."AmountDEV_Account" AS "AmountDEV_Account",
t1."DateExecution_Account" AS "DateExecution_Account",
t2."BallanceState" AS "BallanceState",
t2."BallanceRateDiff" AS "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"
@@ -0,0 +1,405 @@
SELECT '01-Account' As "MainType",
t2."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t1."Customer" As "Customers",
t1."PartnerType" As "PartnerType",
t1."ConnectInfo" As "ConnectInfo",
t2."CurrencyName" As "CurrencyName",
max(t3."AmountHUFBrutto") As "DebitTotalHUF",
0 As "CreditTotalHUF",
max(t3."AmountDEVBrutto") As "DebitTotalDEV",
0 As "CreditTotalDEV",
max(t3."AmountHUFBrutto") As "BallanceHUF",
max(t3."AmountDEVBrutto") As "BallanceDEV",
'' As "ShortName",
'' As "Description",
t2."DateExecution" As "DateExecution",
t2."DateCreated" As "DateCreated",
t2."DatePayment" As "DatePayment",
CURRENT_DATE-Cast(t2."DatePayment" AS Date) As "DelayedDay",
CASE WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)<=0 THEN 0
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>0 AND CURRENT_DATE-Cast(t2."DatePayment" AS date)<=15 then 1
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>15 and CURRENT_DATE-Cast(t2."DatePayment" AS date)<=30 then 2
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>30 and CURRENT_DATE-Cast(t2."DatePayment" AS date)<=60 then 3
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>60 and CURRENT_DATE-Cast(t2."DatePayment" AS date)<=90 then 4
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>90 and CURRENT_DATE-Cast(t2."DatePayment" AS date)<=180 then 5
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>180 and CURRENT_DATE-Cast(t2."DatePayment" AS date)<=360 then 6
WHEN CURRENT_DATE-Cast(t2."DatePayment" AS date)>360 then 7
END As "DelayedRange",
t2."CurrencyName" As "CurrencyName_Account",
SUM(t1."AmountHUF") As "AmountHUF_Account",
SUM(t1."AmountDEV") As "AmountDEV_Account",
t2."DateExecution" As "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"=false 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' As "MainType",
t1."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t1."Customer" As "Customers",
t1."PartnerType" As "PartnerType",
t1."ConnectInfo" As "ConnectInfo",
t3."CurrencyName" As "CurrencyName",
0 As "DebitTotalHUF",
case WHEN t1."PartnerType"=0 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")
WHEN t1."PartnerType"=1 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")*-1
end AS "CreditTotalHUF",
0 AS "DebitTotalDEV",
case WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")*-1
end AS "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 AS "BallanceHUF",
(case WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."InAmountDEV")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."OutAmountDEV")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."OutAmountDEV")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."InAmountDEV")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV2")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF' then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV2")<>0 and
coalesce(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
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF' then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV2")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF'then sum(t1."InAmountDEV2")*-1
else 0
end)*-1 AS "BallanceDEV",
max(t3."ShortName"||', '||coalesce(t2."DocumentNumber",'')) AS "ShortName",
'' AS "Description",
t2."DateExecution" AS "DateExecution",
t2."DateExecution" AS "DateCreated",
t4."DatePayment" AS "DatePayment",
0 AS "DelayedDay",
0 AS "DelayedRange",
t4."CurrencyName" AS "CurrencyName_Account",
0 AS "AmountHUF_Account",
0 AS "AmountDEV_Account",
max(t4."DateExecution") AS "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' As "MainType",
t1."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t1."Customer" As "Customers",
t1."PartnerType" As "PartnerType",
t1."ConnectInfo" As "ConnectInfo",
t3."CurrencyName" As "CurrencyName",
0 As "DebitTotalHUF",
CASE WHEN t1."PartnerType"=0 AND SUM(t1."InAmountHUF")<>0 AND coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" THEN SUM(t1."AmountHUF")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")
WHEN t1."PartnerType"=1 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")*-1
end As "CreditTotalHUF",
0 As "DebitTotalDEV",
case WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")*-1
end As "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 As "BallanceHUF",
(case WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV2")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF' then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV2")<>0 and
coalesce(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
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF' then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV2")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF'then sum(t1."InAmountDEV2")*-1
end)*-1 As "BallanceDEV",
MAX(t3."ShortName"||', '||coalesce(t2."DocumentNumber",'')) As "ShortName",
'' As "Description",
t2."DateExecution" As "DateExecution",
t2."DateExecution" As "DateCreated",
t4."DatePayment" As "DatePayment",
0 As "DelayedDay",
0 As "DelayedRange",
t4."CurrencyName" As "CurrencyName_Account",
0 As "AmountHUF_Account",
0 As "AmountDEV_Account",
max(t4."DateExecution") As "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' As "MainType",
t1."Oid" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t1."Customer" As "Customers",
t1."PartnerType" As "PartnerType",
t1."ConnectInfo" As "ConnectInfo",
t2."CurrencyName" As "CurrencyName",
0 As "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 As "CreditTotalHUF",
0 As "DebitTotalDEV",
0 As "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 As "BallanceHUF",
0 As "BallanceDEV",
max(t7."ShortName"||', '||coalesce(t8."DocumentNumber",'')||', '||coalesce(t2."DocumentNumber",''))As "ShortName",
'' As "Description",
t2."DateExecution" As "DateExecution",
t2."DateExecution" As "DateCreated",
null As "DatePayment",
0 As "DelayedDay",
0 As "DelayedRange",
t4."CurrencyName" As "CurrencyName_Account",
0 As "AmountHUF_Account",
0 As "AmountDEV_Account",
max(t4."DateExecution") As "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" As "Oid",
t2."CustomersFrom" As "CustomersFrom",
t1."Customer" As "Customers",
t1."PartnerType" As "PartnerType",
t1."ConnectInfo" As "ConnectInfo",
t3."CurrencyName" As "CurrencyName",
0 As "DebitTotalHUF",
case WHEN t1."PartnerType"=0 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")
WHEN t1."PartnerType"=1 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountHUF")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountHUF")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")*-1
end As "CreditTotalHUF",
0 As "DebitTotalDEV",
case WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" then sum(t1."InAmountDEV2")*-1
end As "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 As "BallanceHUF",
(case WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=1 and sum(t1."OutAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")=t3."CurrencyName" then sum(t1."AmountDEV")*-1
WHEN t1."PartnerType"=0 and sum(t1."InAmountDEV2")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF' then sum(t1."InAmountDEV2")
WHEN t1."PartnerType"=0 and sum(t1."OutAmountDEV2")<>0 and
coalesce(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
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF' then sum(t1."OutAmountDEV2")
WHEN t1."PartnerType"=1 and sum(t1."InAmountDEV2")<>0 and
coalesce(t4."CurrencyName",t3."CurrencyName")<>t3."CurrencyName" and t4."Currency"<>'HUF'then sum(t1."InAmountDEV2")*-1
else 0
end)*-1 As "BallanceDEV",
max(t3."ShortName"||', '||t2."DocumentNumber") As "ShortName",
'' As "Description",
t2."DateExecution" As "DateExecution",
t2."DateExecution" As "DateCreated",
t2."DateExecution" As "DatePayment",
0 As "DelayedDay",
0 As "DelayedRange",
t4."CurrencyName" As "CurrencyName_Account",
0 As "AmountHUF_Account",
0 As "AmountDEV_Account",
max(t4."DateExecution") As "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' AS "MainType",
t1."Oid" AS "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
0 AS "PartnerType",
t1."ConnectInfo" AS "ConnectInfo",
t1."CurrencyName" AS "CurrencyName",
t1."TotalBruttoHUF" AS "DebitTotalHUF",
0 AS "CreditTotalHUF",
t1."TotalBruttoDEV" AS "DebitTotalDEV",
0 AS "CreditTotalDEV",
t1."TotalBruttoHUF" AS "BallanceHUF",
t1."TotalBruttoDEV" AS "BallanceDEV",
'' AS "ShortName",
t1."Description" AS "Description",
t1."DateExecution" AS "DateExecution",
t1."DateCreated" AS "DateCreated",
t1."DatePayment" AS "DatePayment",
CURRENT_DATE-Cast(t1."DatePayment" AS date) AS "DelayedDay",
case WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)<=0 then 0
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>0 and CURRENT_DATE-Cast(t1."DatePayment" AS date)<=15 then 1
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>15 and CURRENT_DATE-Cast(t1."DatePayment" AS date)<=30 then 2
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>30 and CURRENT_DATE-Cast(t1."DatePayment" AS date)<=60 then 3
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>60 and CURRENT_DATE-Cast(t1."DatePayment" AS date)<=90 then 4
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>90 and CURRENT_DATE-Cast(t1."DatePayment" AS date)<=180 then 5
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>180 and CURRENT_DATE-Cast(t1."DatePayment" AS date)<=360 then 6
WHEN CURRENT_DATE-Cast(t1."DatePayment" AS date)>360 then 7
end AS "DelayedRange",
t1."CurrencyName" AS "CurrencyName_Account",
t1."TotalBruttoHUF" AS "AmountHUF_Account",
t1."TotalBruttoDEV" AS "AmountDEV_Account",
t1."DateExecution" AS "DateExecution_Account"
from "InvoiceHeader" t1
where t1."GLAccounts" is null and
t1."IsEditable"=false and
t1."GCRecord" is null
union all
select '01-Account' AS "MainType",
t1."Oid" AS "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
1 AS "PartnerType",
t1."DocumentNumber" AS "ConnectInfo",
t1."F_CurrencyName" AS "CurrencyName",
t1."F_AmountBruttoHUF" AS "DebitTotalHUF",
0 AS "CreditTotalHUF",
t1."F_AmountBruttoDEV" AS "DebitTotalDEV",
0 AS "CreditTotalDEV",
t1."F_AmountBruttoHUF" AS "BallanceHUF",
t1."F_AmountBruttoDEV" AS "BallanceDEV",
'' AS "ShortName",
'' AS "Description",
t1."F_DateExecution" AS "DateExecution",
t1."F_DateCreated" AS "DateCreated",
t1."F_DatePayment" AS "DatePayment",
CURRENT_DATE-Cast(t1."F_DatePayment" AS date) AS "DelayedDay",
case WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=0 then 0
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>0 and CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=15 then 1
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>15 and CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=30 then 2
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>30 and CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=60 then 3
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>60 and CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=90 then 4
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>90 and CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=180 then 5
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>180 and CURRENT_DATE-Cast(t1."F_DatePayment" AS date)<=360 then 6
WHEN CURRENT_DATE-Cast(t1."F_DatePayment" AS date)>360 then 7
end As "DelayedRange",
t1."F_CurrencyName" AS "CurrencyName_Account",
t1."F_AmountBruttoHUF" AS "AmountHUF_Account",
t1."F_AmountBruttoDEV" AS "AmountDEV_Account",
t1."F_DateExecution" AS "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"=false and
t1."IsStorno"=false and
t2."RegistryMainType"=0 and
t1."RegistryAcceptState"=0
@@ -0,0 +1,54 @@
SELECT MAX(CAST(t1."Oid" AS CHAR(100))) As "Oid",
t1."CustomersFrom" AS "CustomersFrom",
t1."Customers" AS "Customers",
t1."PartnerType" AS "PartnerType",
t1."ConnectInfo" AS "ConnectInfo",
max(t2."ShortName") AS "Currency",
sum(t1."DebitTotalHUF") AS "DebitTotalHUF",
SUM(t1."CreditTotalHUF") AS "CreditTotalHUF",
sum(t1."DebitTotalDEV") AS "DebitTotalDEV",
SUM(t1."CreditTotalDEV") AS "CreditTotalDEV",
SUM(t1."BallanceHUF") AS "BallanceHUF",
SUM(t1."BallanceDEV") AS "BallanceDEV",
case when t1."PartnerType"=1 then SUM(t1."BallanceHUF")*-1 else 0 end AS "BallanceHUF_P",
case when t1."PartnerType"=1 then SUM(t1."BallanceDEV")*-1 else 0 end AS "BallanceDEV_P",
case when t1."PartnerType"=0 then SUM(t1."BallanceHUF") else 0 end AS "BallanceHUF_R",
case when t1."PartnerType"=0 then SUM(t1."BallanceDEV") else 0 end AS "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) AS "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) AS "BallanceDEV_B",
max(t3."ShortName") AS "Currency_Account",
sum(t1."AmountHUF_Account") AS "AmountHUF_Account",
sum(t1."AmountDEV_Account") AS "AmountDEV_Account",
case when max(t3."ShortName")='HUF' then
case when round(cast(SUM(t1."BallanceHUF") as numeric),0)=0 then 1
else 0
end
else
case when round(cast(SUM(t1."BallanceDEV") as numeric),2)=0 then 1
else 0
end
end AS "BallanceState",
case when max(t3."ShortName")='HUF' then -1
when t1."CurrencyName_Account" IS null then -1
else
case when round(cast(SUM(t1."BallanceDEV")as numeric),2)=0 and round(cast(SUM(t1."BallanceHUF")as numeric),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"
@@ -0,0 +1,8 @@
select case when t2."Oid" IS null then t1."Oid" else t2."Oid" end Oid,
t1."Oid" Products,
t2."Oid" StorageComputed
from "Products" t1 left join "StorageComputed" t2 on
t1."Oid"=t2."Products"
where t1."GCRecord" is null and t2."GCRecord" is null
@@ -0,0 +1,29 @@
select t1."Oid" AS "Oid",
t1."RegistryHeader" AS "RegistryHeader",
t1."AmountHUF" AS "AmountHUF",
t1."AmountDEV" AS "AmountDEV",
t1."DatePayment" AS "DatePayment",
t1."IsBlocked" AS "IsBlocked",
t1."Note" AS "Note",
t1."BankSavedFileName" AS "BankSavedFileName",
coalesce(t3."BallanceHUF",t2."F_AmountBruttoHUF") AS "BallanceHUF",
coalesce(t3."BallanceDEV",t2."F_AmountBruttoDEV") AS "BallanceDEV",
t1."AmountHUF"-coalesce(t3."BallanceHUF",t2."F_AmountBruttoHUF") AS "DifferenceHUF",
t1."AmountDEV"-coalesce(t3."BallanceDEV",t2."F_AmountBruttoDEV") AS "DifferenceDEV",
case when round(cast(coalesce(t3."BallanceHUF",t2."F_AmountBruttoHUF") as numeric),2)=0 then 0
when coalesce(t3."BallanceHUF",t2."F_AmountBruttoHUF")>=t1."AmountHUF" then t1."AmountHUF"
when coalesce(t3."BallanceHUF",t2."F_AmountBruttoHUF")<=t1."AmountHUF" then coalesce(t3."BallanceHUF",t2."F_AmountBruttoHUF")
end AS "OfferedHUF",
case when round(cast(coalesce(t3."BallanceDEV",t2."F_AmountBruttoDEV") as numeric),2)=0 then 0
when coalesce(t3."BallanceDEV",t2."F_AmountBruttoDEV")>=t1."AmountDEV" then t1."AmountDEV"
when coalesce(t3."BallanceDEV",t2."F_AmountBruttoDEV")<=t1."AmountDEV" then coalesce(t3."BallanceDEV",t2."F_AmountBruttoDEV")
end AS "OfferedDEV",
t1."BankPrepareName" AS "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
@@ -0,0 +1,8 @@
select MAX(CAST("Oid" AS CHAR(100))) As "Oid",
"BankPrepareName"
from "RegistryBankTransfer"
where Rtrim(Ltrim(coalesce("BankPrepareName",'')))<>''
group by "BankPrepareName"
@@ -0,0 +1,71 @@
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(cast(t4."AmountDEV_Account" as numeric),2) AmountDEV_Account,
round(cast(t4."AmountHUF_Account" as numeric),2) AmountHUF_Account,
round(cast(t4."BallanceDEV" as numeric),2) BallanceDEV_Account,
case when round(cast(t4."AmountDEV_Account" as numeric),2)<>0 then round(cast(round(cast(t4."AmountHUF_Account" as numeric),2)/round(cast(t4."AmountDEV_Account" as numeric),2) as numeric),2) else 0 end CurrencyRate_Account,
t1."LiquidAssets" LiquidAssets,
t2."DateExecution" DateExecution,
round(cast(t1."InAmountDEV" as numeric),2) InAmountDEV,
round(cast(t1."OutAmountDEV" as numeric),2) OutAmountDEV,
round(cast(t1."InAmountDEV2" as numeric),2) InAmountDEV2,
round(cast(t1."OutAmountDEV2" as numeric),2) OutAmountDEV2,
case when "InAmountHUF">0 then
case when t1."InAmountDEV" <>0 then round(cast(t1."InAmountHUF" as numeric),2)/round(cast(t1."InAmountDEV" as numeric),2)
else 0
end
else
case when t1."OutAmountDEV" <>0 then round(cast(t1."OutAmountHUF" as numeric),2)/round(cast(t1."OutAmountDEV" as numeric),2)
else 0
end
end CurrencyRate,
round(cast(t1."InAmountHUF" as numeric),2) InAmountHUF,
round(cast(t1."OutAmountHUF" as numeric),2) OutAmountHUF,
case when t3."CurrencyName"=t5."CurrencyName" then round(cast(t1."InAmountDEV" as numeric),2)* round(cast(t3."CurrencyRate" as numeric),2)
else round(cast(t1."InAmountDEV2" as numeric),2)* round(cast(t3."CurrencyRate" as numeric),2)
end InAmountHUF_Account,
case when t3."CurrencyName"=t5."CurrencyName" then round(cast(t1."OutAmountDEV" as numeric),2)*round(cast(t3."CurrencyRate" as numeric),2)
else round(cast(t1."OutAmountDEV2" as numeric),2)*round(cast(t3."CurrencyRate" as numeric),2)
end OutAmountHUF_Account,
case when t3."CurrencyName"=t5."CurrencyName" then round(cast(t1."InAmountDEV" as numeric),2)* round(cast(t3."CurrencyRate" as numeric),2)
else round(cast(t1."InAmountDEV2" as numeric),2)* round(cast(t3."CurrencyRate" as numeric),2)
end - round(cast(t1."InAmountHUF" as numeric),2) InAmountHUF_Diff,
case when t3."CurrencyName"=t5."CurrencyName" then round(cast(t1."OutAmountDEV" as numeric),2)*round(cast(t3."CurrencyRate" as numeric),2)
else round(cast(t1."OutAmountDEV2" as numeric),2)*round(cast(t3."CurrencyRate" as numeric),2)
end - round(cast(t1."OutAmountHUF" as numeric),2) OutAmountHUF_Diff,
t1."GLRowsRateDiff" GLRowsRateDiff,
case when t1."PartnerType" = 0 Then
case when case when t3."CurrencyName"=t5."CurrencyName" then round(cast(t1."InAmountDEV" as numeric),2)* round(cast(t3."CurrencyRate" as numeric),2)
else round(cast(t1."InAmountDEV2" as numeric),2)* round(cast(t3."CurrencyRate" as numeric),2)
end - round(cast(t1."InAmountHUF" as numeric),2) > 0 Then -1
else 1
end
when t1."PartnerType" = 1 Then
case when case when t3."CurrencyName"=t5."CurrencyName" then round(cast(t1."OutAmountDEV" as numeric),2)*round(cast(t3."CurrencyRate" as numeric),2)
else round(cast(t1."OutAmountDEV2" as numeric),2)*round(cast(t3."CurrencyRate" as numeric),2)
end - round(cast(t1."OutAmountHUF" as numeric),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 coalesce(t7."ShortName",'HUF')<>'HUF' and
((t1."PartnerType"=0 and t1."InAmountHUF">0) or (t1."PartnerType"=1 and t1."OutAmountHUF">0))