select r.contractId, c.claimId, c.claimDate, c.claimInvoice, c.claimPeriodStart, c.claimPeriodEnd, cc.firstDate, cc.lastDate, r.assignedContractNbr, r.description, c.partnerId, c.partnerType, pod.cdrRecordId, cc.approvedAmount, sum( case when pod.proofOfDeliveryId is not null then case when pod.skuId > 0 then pod.itemQty else 0 end else cc.qualifiedQuantity end ) tradeCases, -- sum( pod.qualifiedAmount ) as tradeDollars, sum( case when pod.proofOfDeliveryId is not null then case when cc.status = 'APPROVED_CLAIMAMT' then pod.totalRebate else pod.qualifiedAmount end else cc.approvedAmount end ) tradeDollars, c.checkIssued, count( distinct pod.proofOfDeliveryId ) podLines from tbl_TPM_ClaimContracts cc with (nolock) left outer join tbl_TPM_ProofOfDelivery pod with (nolock) on pod.claimId = cc.claimId and pod.contractNbr = cc.contractNbr and pod.ownerType = cc.ownerType and pod.ownerId = cc.ownerId inner join tbl_TPM_Claims c with (nolock) on c.claimId = cc.claimId and c.ownerType = cc.ownerType and c.ownerId = cc.ownerId inner join tbl_TPM_Requests r with (nolock) on r.requestId= cc.requestId and r.ownerType = cc.ownerType and r.ownerId = cc.ownerId inner join tbl_TPM_Contracts ct with (nolock) on ct.contractId = r.contractId and ct.ownerId = r.ownerId and ct.ownerType = r.ownerType inner join tbl_TPM_RequestTypes rt with (nolock) on rt.ownerId = r.ownerId and rt.ownerType = r.ownerType and rt.requestTypeId = r.requestTypeId where cc.requestId in ( ) 1 = 1 1 = 2 and pod.skuId in ( ) and cc.reconciled = 'Y' and cc.ownerId = and cc.ownerType = and ( pod.status != 'DENIED' or ( nullif( pod.status, '' ) is null and rt.requestTypeId = 76 ) ) and pod.status != 'DENIED' and ( ( c.partnerType = 'OPR' and c.partnerId in ( )) or pod.operatorId in ( ) or ( ct.partnerType = 'OPR' and ct.partnerId in ( ))) and ( ( c.partnerType = 'CDR' and c.partnerId in ( )) or coalesce( pod.cdrRecordId, 0 ) in ( )) and ( or ( coalesce( coalesce( cc.lastDate, c.claimPeriodEnd ), c.claimDate ) between and ) ) group by c.claimId, r.contractId, c.claimDate, c.claimInvoice, c.claimPeriodStart, c.claimPeriodEnd, cc.firstDate, cc.lastDate, r.assignedContractNbr, r.description, c.partnerId, c.partnerType, pod.cdrRecordId, c.checkIssued, cc.approvedAmount order by c.claimDate desc select companyName from tbl_OPR_CLientOperators with (nolock) where operatorId = and ownerId = and fsltablecode = select cdr_dstName from tbl_CDR_Distributors with (nolock) where cdr_recordId = and ownerId = and fsl_tablecode = select cdr_dstName from tbl_CDR_Distributors with (nolock) where cdr_recordId = and ownerId = and fsl_tablecode = select * from qmd_claimData order by claimDate desc, claimId, claimantName, assignedContractNbr, distributorName #_claimDetailRowsHTML#
Claim Date Contract Claimant Distributor Period Trade Cases Trade Dollars
#htmleditformat( distributorName )#unknown #lsdateformat( firstDate, "MM/DD/YY")# - #lsdateformat( lastDate, "MM/DD/YY")# #lsnumberformat( tradeCases )# #lsnumberformat( tradeDollars, ".00" )#
#lsdateformat( claimDate, "MM/DD/YY")# #htmleditformat( assignedContractNbr )# - #htmleditformat( description )# #htmleditformat( claimantName )#
INV: #htmleditformat( claimInvoice )#
Show/Hide #lsnumberformat( _detailCount )# detail rows #htmleditformat( distributorName )#Unknown Distributor #lsdateformat( firstDate, "MM/DD/YY")# - #lsdateformat( lastDate, "MM/DD/YY")# #lsnumberformat( _claimTradeCases )# #lsnumberformat( _claimTradeDollars, ".00" )#
Totals: #lsnumberformat( _totalTradeCases )# #lscurrencyformat( _totalTradeDollars )#
#_claimListHTML#