Commit df59ba63 authored by Hakan Uygun's avatar Hakan Uygun

refs #4696 satıcı performans raporu güncellendi

parent c5487d2b
......@@ -37,12 +37,20 @@
</parameter>
<queryString>
<![CDATA[(
/* satis faturasi */
select 2 as DOCTYPE
,txn.SERIAL,txn.REFERENCE,txn.CODE
,txn.SHIPPING_DATE,txn.DELIVERY_DATE, txn.TXNDATE,txn.TXNTIME
,txn.INFO,txn.INFO1,txn.INFO2
,txn.CREATE_DATE,txn.CREATE_USER,txn.UPDATE_DATE,txn.UPDATE_USER
(select 2 as DOCTYPE
,txn.SERIAL
,txn.REFERENCE,txn.CODE
,txn.SHIPPING_DATE
,txn.DELIVERY_DATE
,txn.TXNDATE
,txn.TXNTIME
,txn.INFO
,txn.INFO1
,txn.INFO2
,txn.CREATE_DATE
,txn.CREATE_USER
,txn.UPDATE_DATE
,txn.UPDATE_USER
,txn.TOTAL_TAX_EXCLUDED_AMOUNT_LCYVAL as VergisizAraToplam
,txn.TOTAL_DISCOUNT_LCYVAL as SatirIndirimi
,txn.TOTAL_DOCUMENT_DISCOUNT_LCYVAL as BelgeIndirimi
......@@ -53,50 +61,66 @@ select 2 as DOCTYPE
,txn.TOTAL_EXPENSE_LCYVAL as Masraf
,txn.TOTAL_AMOUNT_LCYVAL as VergiliSonToplam
,txn.ACCOUNT_ID,txn.CONTACT_ID,txn.WAREHOUSE_ID
,c.FULLNAME as Musteriadi,c.COMPANY as Sirket,c.CODE as Carikod,c.PERSON
,c.FULLNAME as Musteriadi
,c.COMPANY as Sirket
,c.CODE as Carikod,c.PERSON
, (case when c.PERSON is false then 0 else 1 end ) as caritip
,w.CODE as Depokod,w.NAME as Depoadi
,w.CODE as Depokod
,w.NAME as Depoadi
,usr.FULL_NAME as Tezgahtar
,org.NAME as Organizasyon, org.ID as ORGID
,org.NAME as Organizasyon
, org.ID as ORGID
from TEKIR_INVOICE txn
inner join CONTACT c on c.ID = txn.CONTACT_ID
inner join WAREHOUSE w on w.ID = txn.WAREHOUSE_ID
left outer join USERS usr on usr.ID = txn.CLERK_ID
left outer join ORGANIZATION org on org.ID = w.ORGANIZATION_ID
where txn.TRADE_ACTION = 1 and
( ( $P{pWare} = 0 ) or ( w.ID = $P{pWare} ) ) and
( ( $P{pClerk} = 0 ) or ( txn.CLERK_ID = $P{pClerk} ) ) and
( ( $P{pUser} is null ) or ( txn.UPDATE_USER = $P{pUser} ) ) and
( ( $P{pOrgLevel} = 0 ) or ( org.ID = $P{pOrgLevel} ) ) and
( ( $P{pAccount} = 0 ) or ( txn.ACCOUNT_ID = $P{pAccount} ) ) and
( txn.TXNDATE >= $P{pBDate} and txn.TXNDATE <= $P{pEDate} ) and
where txn.TRADE_ACTION = 1
and txn.ID not in ( select ol.INVOICE_ID from INVOICE_ORDER_LINK ol )
and ( txn.TXNDATE >= '2012-10-10' and txn.TXNDATE <= '2012-10-23' )
( ( $P{pWare} = 0 ) or ( w.ID = $P{pWare} ) ) and
( ( $P{pClerk} = 0 ) or ( txn.CLERK_ID = $P{pClerk} ) ) and
( ( $P{pUser} is null ) or ( txn.UPDATE_USER = $P{pUser} ) ) and
( ( $P{pOrgLevel} = 0 ) or ( org.ID = $P{pOrgLevel} ) ) and
( ( $P{pAccount} = 0 ) or ( txn.ACCOUNT_ID = $P{pAccount} ) ) and
( txn.TXNDATE >= $P{pBDate} and txn.TXNDATE <= $P{pEDate} ) and
( ( $P{pWorkBunchId} is null ) or ( txn.WORKBUNCH_ID = $P{pWorkBunchId} ) )
order by org.ID, txn.WAREHOUSE_ID,usr.FULL_NAME, txn.TXNDATE, txn.TXNTIME
)
union all
(
/* teslim edilmemis acik siparis */
select 1 as DOCTYPE
,txm.SERIAL,min(txm.REFERENCE) as REFERENCE,min(txm.CODE) as CODE
,txm.SERIAL
,min(txm.REFERENCE) as REFERENCE
,min(txm.CODE) as CODE
,null as SHIPPING_DATE
,min(txm.DELIVERY_DATE) as DELIVERY_DATE, min(txm.TXNDATE) as TXNDATE,min(txm.TXNTIME) as TXNTIME
,min(txm.INFO) as INFO,min(txm.INFO1) as INFO1,min(txm.INFO2) as INFO2
,min(txm.CREATE_DATE) as CREATE_DATE,min(txm.CREATE_USER) as CREATE_USER,min(txm.UPDATE_DATE) as UPDATE_DATE,min(txm.UPDATE_USER) as UPDATE_USER
,sum((txn.TAX_EXCLUDED_AMOUNT_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as VergisizAraToplam
,sum((txn.DISCOUNT_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as SatirIndirimi
,min(txm.DELIVERY_DATE) as DELIVERY_DATE
, min(txm.TXNDATE) as TXNDATE
,min(txm.TXNTIME) as TXNTIME
,min(txm.INFO) as INFO
,min(txm.INFO1) as INFO1
,min(txm.INFO2) as INFO2
,min(txm.CREATE_DATE) as CREATE_DATE
,min(txm.CREATE_USER) as CREATE_USER
,min(txm.UPDATE_DATE) as UPDATE_DATE
,min(txm.UPDATE_USER) as UPDATE_USER
,sum((txn.TAX_EXCLUDED_AMOUNT_LCYVAL)) as VergisizAraToplam
,sum((txn.DISCOUNT_LCYVAL) ) as SatirIndirimi
,0 as BelgeIndirimi
,sum((txn.BEFORE_TAX_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as OTVMatrah
,sum((txn.TAX_EXCLUDED_TOTAL_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as KDVMatrah
,sum((txn.TAX_TOTAL_AMOUNT_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as VergiToplami
,sum((txn.FEE_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as Harc
,sum((txn.EXPENSE_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as Masraf
,sum((txn.TOTAL_AMOUNT_LCYVAL / txn.QUANTITY) * (txn.QUANTITY - txn.CLOSED_QUANTITY )) as VergiliSonToplam
,sum((txn.BEFORE_TAX_LCYVAL ) ) as OTVMatrah
,sum((txn.TAX_EXCLUDED_TOTAL_LCYVAL ) ) as KDVMatrah
,sum((txn.TAX_TOTAL_AMOUNT_LCYVAL ) ) as VergiToplami
,sum((txn.FEE_LCYVAL ) ) as Harc
,sum((txn.EXPENSE_LCYVAL ) ) as Masraf
,sum((txn.TOTAL_AMOUNT_LCYVAL ) ) as VergiliSonToplam
,min(txm.ACCOUNT_ID) as ACCOUNT_ID,min(txm.CONTACT_ID) as CONTACT_ID,min(txm.WAREHOUSE_ID) as WAREHOUSE_ID
,min(c.FULLNAME) as Musteriadi,min(c.COMPANY) as Sirket,min(c.CODE) as Carikod,min(c.PERSON) as PERSON
, (case when c.PERSON is false then 0 else 1 end ) as caritip
,min(w.CODE) as Depokod,min(w.NAME) as Depoadi
,min(usr.FULL_NAME) as Tezgahtar
,min(org.NAME) as Organizasyon, min(org.ID) as ORGID
,min(org.NAME) as Organizasyon
, min(org.ID) as ORGID
from TEKIR_ORDER_NOTE txm
inner join TEKIR_ORDER_NOTE_DETAIL txn on txn.OWNER_ID = txm.ID
inner join CONTACT c on c.ID = txm.CONTACT_ID
......@@ -105,8 +129,9 @@ inner join ACCOUNT acc on acc.id = txm.account_id
left outer join USERS usr on usr.ID = txm.CLERK_ID
left outer join ORGANIZATION org on org.ID = w.ORGANIZATION_ID
where (txm.TRADE_ACTION = 1 )
and (txm.STATUS = 0 or txm.STATUS = 4)
and (txm.STATUS not in ( 1,2 ))
and (txn.PRODUCT_TYPE = 1 or txn.PRODUCT_TYPE = 2)
and ( txm.TXNDATE >= '2012-10-10' and txm.TXNDATE <= '2012-10-23' )
and ( ( $P{pWare} = 0 ) or ( w.ID = $P{pWare} ) )
and ( ( $P{pOrgLevel} = 0 ) or ( org.ID = $P{pOrgLevel} ) )
and ( ( $P{pAccount} = 0 ) or ( txm.ACCOUNT_ID = $P{pAccount} ) )
......@@ -116,7 +141,7 @@ and ( ( $P{pWorkBunchId} is null ) or ( txm.WORKBUNCH_ID = $P{pWorkBunchId} ) )
group by txm.SERIAL
order by org.ID, txm.WAREHOUSE_ID, txm.TXNDATE, txm.TXNTIME
)
order by ORGID, Depoadi,Tezgahtar, DOCTYPE, TXNDATE, TXNTIME]]>
order by ORGID, Depoadi,Tezgahtar, DOCTYPE, TXNDATE, TXNTIME ]]>
</queryString>
<field name="DOCTYPE" class="java.lang.Long"/>
<field name="SERIAL" class="java.lang.String"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment