Do not let any software impress you!

Only let it convince your intellect.
Slider img 1
Do not look for a business paradise!

It is a waste of time.
Slider img 2
Only yourself can push you uphill.

There is no easy road to prizes.
Slider img 3
Productivity is the name of the game.

And you have to conquer it.
Slider img 4
As long as you understand it,

you will start to build your know-how.
Slider img 5
We can help with that.

We have the tools and the method.
Slider img 6
Procedure : AU_CASH_DASH_EXPERT

AutoScript

start_agent_info
   AgentName = "AU_CASH_DASH_EXPERT"
   AgentDescr = "Cashflow Dashboard"
   AgentLanguage = ""
   __timer_interval = 0 {....define (in seconds) the timer interval for the wake up}
   __delete_on_termination = 0 {....1=the agent frees itself when terminates its task}
end_agent_info

start_action
                                                
    function = __params[1]
    code     = __params[2]

    {.......................................GET_CASHFLOW_POINTS..........................}
    if (function = "GET_CASHFLOW_POINTS") then

       line_series = True
       title = "Cash Flow Chart"
       draw_type = "CHART"
       y_count = 3
       line1 = "Debit"
       line2 = "Gredit"
       line3 = "Difference"
       show_legend = True
       left_axis_title = "Count of Activities"
       bottom_axis_title = "Days since the begining"

       start_sql "*" "KOSMOS"
       SELECT
         AU_K_ACCOUNT.DATE AS DAT,
         SUM(AU_K_ACCOUNT.DEBIT) AS X, SUM(AU_K_ACCOUNT.DEBIT_P) AS XP,
         SUM(AU_K_ACCOUNT.GREDIT) AS P, SUM(AU_K_ACCOUNT.GREDIT_P) AS PP
       FROM
         AU_EVENT, AU_K_ACCOUNT, AU_ACCOUNT, AU_PER
       WHERE
         (AU_K_ACCOUNT.AU_ACCOUNT = AU_ACCOUNT.AU_ACCOUNT)
         AND (AU_EVENT.AU_EVENT = AU_K_ACCOUNT.AU_EVENT)
         AND (AU_EVENT.AU_PERIOD = AU_PER.AU_PER)
         AND (LEFT(AU_ACCOUNT.CODE,LEN(:COD))=:COD)
         AND (AU_K_ACCOUNT.DATE>=(:DD1))
         AND (AU_K_ACCOUNT.DATE<=(:DD2))
         AND (AU_PER.AU_ACCOUNT_YEAR =:X)
       GROUP BY
         AU_K_ACCOUNT.DATE
       ORDER BY
         AU_K_ACCOUNT.DATE
       end_sql
       q = QueryByName()

       start_sql "DAT1" "KOSMOS"
       SELECT
         SUM (AU_K_ACCOUNT.DEBIT) AS X, SUM(AU_K_ACCOUNT.GREDIT) AS P
       FROM
         AU_K_ACCOUNT, AU_ACCOUNT, AU_EVENT, AU_PER
       WHERE
         (AU_K_ACCOUNT.AU_ACCOUNT = AU_ACCOUNT.AU_ACCOUNT)
         AND (AU_EVENT.AU_EVENT = AU_K_ACCOUNT.AU_EVENT)
         AND (AU_EVENT.AU_PERIOD = AU_PER.AU_PER)
         AND (LEFT(AU_ACCOUNT.CODE,LEN(:COD)) = :COD)
         AND (AU_K_ACCOUNT.DATE >= (:D1) AND AU_K_ACCOUNT.DATE <= (:D2))
         AND (AU_PER.AU_ACCOUNT_YEAR =:X)
       end_sql
       q1 = QueryByName()

       x = GetXRHSH_ID()
       dd1 = LookUpId("AU_ACCOUNT_YEAR",x,"DATE1")
       dd2 = LookUpId("AU_ACCOUNT_YEAR",x,"DATE2")
       cod = code
       d1 = LookUpId("AU_ACCOUNT_YEAR",x,"DATE1")
       d2 = AddDays (dd1;0-1)

       call TSetParam(q,"COD",code)
       call TSetParam(q,"DD1",dd1)
       call TSetParam(q,"DD2",dd2)
       call TSetParam(q,"X",x)
       call TExecute(q)

       call TSetParam(q1,"COD",code)
       call TSetParam(q1,"D1",d1)
       call TSetParam(q1,"D2",d2)
       call TSetParam(q1,"X",x)
       call TExecute(q1)

       px1 = TGetFld(q1,"X")
       pp1 = TGetFld(q1,"P")

       px1[1] = px1
       pp1[1] = pp1
       dat[1] = dd1

       rcount = TRecordCount(q)
       rcount = rcount + 1

       x1 = 0
       p1 = 0

       call TFirst(q)
       for i = 2 to rcount

         x01 = TGetFld(q,"X")
         p01 = TGetFld(q,"P")
         x02 = TGetFld(q,"XP")
         p02 = TGetFld(q,"PP")
         x01 = val(x01)
         p01 = val(p01)
         x02 = val(x02)
         p02 = val(p02)

         x0 = x01 + x02
         p0 = p01 + p02

         px1[i] = px1[i-1] + x0
         pp1[i] = pp1[i-1] + p0
         dat[i] = TGetFld(q,"DAT")

         call TNext(q)
       next
       call FreeEmbSQL(q)
       call FreeEmbSQL(q1)

       for i = 1 to rcount

         x[i] = dat[i]
         y1[i] = px1[i]
         y2[i] = pp1[i]
         y3[i] = y1[i] - y2[i]
       next

       count = rcount

       return
    endif

end_action