$query.Payments
SELECT 0 AS Type, ma.FirstName, ma.LastName, g.GroupName, ma.Company, DATEDIFF(dd,getdate(),p.CreateDate) AS SortOrder, pt.PaymentType, p.Amount, p.CreateDate, p.PayInfo, NULL AS OldAmount, p.CheckNumber
FROM MasterAccounts ma, Groups g, Payments p, PaymentTypes pt
WHERE ma.CustomerID = p.CustomerID
AND ma.GroupID = g.GroupID
AND p.PaymentTypeID = pt.PaymentTypeID
AND p.CreateDate >= $!Variables.StartDate
AND p.CreateDate <= $!Variables.EndDate
AND ma.GroupID = $-Variables.GroupID
AND g.OrganizationID = $-Variables.OrganizationID
UNION ALL
SELECT 1 AS Type, ma.FirstName, ma.LastName, g.GroupName, ma.Company, DATEDIFF(dd,getdate(),p.FinalCreateDate) AS SortOrder, pt.PaymentType, p.FinalAmount, p.FinalCreateDate, p.PayInfo, p.Amount AS OldAmount, p.CheckNumber
FROM MasterAccounts ma, Groups g, Payments p, PaymentTypes pt
WHERE ma.CustomerID = p.CustomerID
AND ma.GroupID = g.GroupID
AND p.PaymentTypeID = pt.PaymentTypeID
AND p.FinalCreateDate >= $!Variables.StartDate
AND p.FinalCreateDate <= $!Variables.EndDate
AND ma.GroupID = $-Variables.GroupID
AND g.OrganizationID = $-Variables.OrganizationID
UNION ALL
SELECT 2 AS Type, NULL AS FirstName, NULL AS LastName, NULL AS GroupName, NULL AS Company, DATEDIFF(dd,getdate(),COALESCE(p.FinalCreateDate,p.CreateDate)) AS SortOrder, pt.PaymentType,
SUM(CASE WHEN p.FinalAmount IS NOT NULL AND p.FinalCreateDate >= $!Variables.StartDate AND p.FinalCreateDate <= $!Variables.EndDate THEN p.FinalAmount ELSE p.Amount END) AS Amount, NULL AS CreateDate, NULL AS PayInfo, NULL AS OldAmount, NULL AS CheckNumber
FROM MasterAccounts ma, Groups g, Payments p, PaymentTypes pt
WHERE ma.CustomerID = p.CustomerID
AND ma.GroupID = g.GroupID
AND p.PaymentTypeID = pt.PaymentTypeID
AND ((p.CreateDate >= $!Variables.StartDate AND p.CreateDate <= $!Variables.EndDate)
OR (p.FinalCreateDate >= $!Variables.StartDate AND p.FinalCreateDate <= $!Variables.EndDate))
AND ma.GroupID = $-Variables.GroupID
AND g.OrganizationID = $-Variables.OrganizationID
GROUP BY DATEDIFF(dd,getdate(),COALESCE(p.FinalCreateDate,p.CreateDate)), pt.PaymentType
ORDER BY 6 DESC, 1, 7, 8
$query
$query.PaymentsTotal
SELECT p.Amount
Into #t
FROM MasterAccounts ma, Groups g, Payments p, PaymentTypes pt
WHERE ma.CustomerID = p.CustomerID
AND ma.GroupID = g.GroupID
AND p.PaymentTypeID = pt.PaymentTypeID
AND p.PaymentTypeID = 8
AND p.CreateDate >= $!Variables.StartDate
AND p.CreateDate <= $!Variables.EndDate
AND ma.GroupID = $-Variables.GroupID
AND g.OrganizationID = $-Variables.OrganizationID
UNION ALL
SELECT p.FinalAmount
FROM MasterAccounts ma, Groups g, Payments p, PaymentTypes pt
WHERE ma.CustomerID = p.CustomerID
AND ma.GroupID = g.GroupID
AND p.PaymentTypeID = pt.PaymentTypeID
AND p.PaymentTypeID = 8
AND p.FinalCreateDate >= $!Variables.StartDate
AND p.FinalCreateDate <= $!Variables.EndDate
AND ma.GroupID = $-Variables.GroupID
AND g.OrganizationID = $-Variables.OrganizationID
Select Count(*) as Numb, Sum(Amount) As Amount
From #t
Drop Table #t
$query
$query.Org
SELECT Organization FROM Organizations WHERE OrganizationID=$-Variables.OrganizationID
$query
$time.now
$time
$set.language
LanguageID=$Variables.LanguageID
$set
${10058:Date} | ${10114:Type} | ${12122:Pay Type} | ${10095:Billing Group} | ${10054:Name} | ${10159:Company} | ${10078:Amount} |
$floop.Payments
$check.compare
compare=$floop.Type
with=2
denied_inline=$check2.compare
compare=$newt.value
with=1
allowed_inline=
${10058:Date} | ${10114:Type} | ${12122:Pay Type} | ${10095:Billing Group} | ${10054:Name} | ${10159:Company} | ${10078:Amount} |
$tablist.newt
Value
0
$tablist
$check2
$check
$check.compare
compare=$floop.Type
with=2
allowed=
denied=
$check
$floop.CreateDate |
$check.compare
compare=$floop.Type
with=0
allowed=${12123:New Payment}
$check
$check.compare
compare=$floop.Type
with=1
allowed=${12124:Changed Payment}
$check
$check.compare
compare=$floop.Type
with=2
allowed=${12125:Payment Total}
$check
|
$floop.PaymentType $floop.CheckNumber |
$floop.GroupName |
$floop.FirstName $floop.LastName |
$floop.Company |
$check.compare
compare=$floop.Type
with=1
allowed=$$floop.OldAmount to $$floop.Amount |
denied=$$floop.Amount |
$check
$check.compare
compare=$floop.Type
with=2
allowed_inline=$tablist.newt
value
1
$tablist
$check
$floop
$PaymentsTotal.Numb Payments in Period $!Variables.StartDate - $!Variables.EndDate Totaling: $PaymentsTotal.Amount
$set.language
$set
|