Subject: Re: referaluri daxmareba
From: sergo <[email-masked]>
To: Batiashvili Zurab <[email-masked]>
Date: Sun, 26 Oct 2014 21:47:38 +0000

გამარჯობა ,
ეს უნდა შეიცვალოს იმიტომ რომ ჩამოწერის შემდეგ ბანკის მიერ შეიძლება დაბრუნდეს მთელი თანხა ან ნაწილი

where A.STATUS_ID in (38,41)

A.[AMOUNT] მაგივრად ISNULL(A.AMOUNT,0)-ISNULL(A.returnedamount,0)

ერთ შესრულებას შეიძლება ჰქონდეს რამდენიმე გადარიცხვა ამიტომ ჯამურად ჯობია აღება

გიგზავნი სკრიპტს

SELECT

bp.[name] as N'პროგრამა',

bpc.[name] as N'კომპონენტი',

bpsc.[name] as N'სუბკომპონენტი',

org.[name] as N'ორგანიზაცია',

con.NO_OLD_STYLE as N'კონტრაქტი',

con.year as 'conYEAR',

ps.id as 'შესრულების ID',

convert(varchar(20),ps.reporting_period_start,102)+'-'+convert(varchar(20),ps.reporting_period_end,102) as N'ანგარიშგების პერიოდი',

d.amount as N'მოთხოვნილი თანხა /ანგარიშ-ფაქტურის თანხა',

(select sum(ISNULL(po.AMOUNT,0)-ISNULL(po.returnedamount,0))

from

LIABILITY_DOC ld  LEFT JOIN

LIABILITY_DOC_DETAIL ldd ON ldd.LIABILITY_DOC_ID=ld.ID and ld.PROVIDED_SERVICE_ID=ps.ID LEFT JOIN

PAYMENT_ORDER po ON po.LIABILITY_DOC_DETAIL_ID=ldd.ID   and po.STATUS_ID in (38,41)

) as N'გადარიცხული თანხები'

FROM

BUDGET_PROGRAM bp INNER JOIN

BUDGET_PROGRAM_COMPONENT bpc ON bp.ID=bpc.BUDGET_PROGRAM_ID INNER JOIN

BUDGET_PROGRAM_SUBCOMPONENT bpsc ON bpc.id=bpsc.BUDGET_PROGRAM_COMPONENT_ID INNER  JOIN

[CONTRACT] con ON con.BUDGET_PROGRAM_SUBCOMPONENT_ID=bpsc.ID INNER JOIN

ORGANIZATION org ON con.ORGANIZATION_ID=org.ID INNER JOIN

PROVIDED_SERVICE ps ON ps.CONTRACT_ID=con.ID LEFT JOIN

DOC d ON d.PROVIDED_SERVICE_ID=ps.id and d.DOC_TYPE_ID=60

WHERE

org.id=183 and

bpsc.id in (957,860,554) and

ps.REPORTING_PERIOD_START>'2009.04.30' and ps.REPORTING_PERIOD_END<'2014.10.01' and

ps.status_id=14

order by ps.REPORTING_PERIOD_START

On Fri, Oct 24, 2014 at 5:32 PM, Batiashvili Zurab <[email-masked]> wrote:

ეს სცორადაა სერგო?

SELECT -- TOP 100

G.[YEAR]

,F.[ID] as BUDGET_PROGRAM_SUBCOMPONENT_ID

,F.[NAME] as BUDGET_PROGRAM_SUBCOMPONENT_NAME

,E.[ID] as CONTRACT_ID

,E.[ORGANIZATION_ID]

,E.[BUDGET_PROGRAM_SUBCOMPONENT_ID]

,E.[STATUS_ID]

,E.[YEAR]

,E.[NO_OLD_STYLE]

,D.[ID] as PROVIDED_SERVICE_ID

,D.[CONTRACT_ID]

,D.[REPORTING_PERIOD_START]

,D.[REPORTING_PERIOD_END]

,C.[ID] as LIABILITY_DOC_ID

,C.[STATUS_ID]

,C.[PROVIDED_SERVICE_ID]

,C.[DATE]

,C.[REGISTERED]

,B.[ID] as LIABILITY_DOC_DETAIL_ID

,B.[LIABILITY_DOC_ID]

,B.[SERVICE_TYPE_ID]

,B.[CORRECTION]

,B.[AMOUNT]

,B.[REGISTERED_AMOUNT]

,A.[ID] as PAYMENT_ORDER_ID

,A.[AMOUNT]

,A.[DATE]

,A.[NO]

,A.[RECIPIENT]

,A.[RECIPIENT_TIN]

FROM PAYMENT_ORDER A

join LIABILITY_DOC_DETAIL B on B.ID = A.LIABILITY_DOC_DETAIL_ID

join LIABILITY_DOC C on C.ID = B.LIABILITY_DOC_ID

join PROVIDED_SERVICE D on D.ID = C.PROVIDED_SERVICE_ID

join [CONTRACT] E on E.ID = D.CONTRACT_ID

join BUDGET_PROGRAM_SUBCOMPONENT F on F.ID = E.BUDGET_PROGRAM_SUBCOMPONENT_ID

join BUDGET_CODE_HISTORY G on G.[BUDGET_PROGRAM_SUBCOMPONENT_ID] = F.ID

where A.STATUS_ID = 41 and D.STATUS_ID = 14 and E.ORGANIZATION_ID = 183 and E.[STATUS_ID] = 7

and G.[YEAR] = '2011'  and F.ID = 860

From: sergo [mailto:[email-masked]]
Sent: Friday, October 24, 2014 03:25
To: Batiashvili Zurab
Subject: Re: referaluri daxmareba

გამარჯობა,

გიგზავნი სკრიპტს