<!DOCTYPE html>
<html lang='en'>
<head>
<title>web commit by HarleyPig - ikiwiki-upstream - Unnamed repository; edit this file to name it for gitweb.</title>
<meta name='generator' content='cgit v1.2.3'/>
<meta name='robots' content='index, nofollow'/>
<link rel='stylesheet' type='text/css' href='/cgit-css/cgit.css'/>
<link rel='stylesheet' type='text/css' href='/cgit-local/local.css'/>
<script type='text/javascript' src='/cgit.js'></script>
<link rel='shortcut icon' href='/favicon.ico'/>
<link rel='alternate' title='Atom feed' href='https://source.jones.dk/ikiwiki-upstream/atom/debian/changelog?h=master' type='application/atom+xml'/>
<link rel='vcs-git' href='https://source.jones.dk/ikiwiki-upstream' title='ikiwiki-upstream Git repository'/>
<link rel='vcs-git' href='user@source.jones.dk:ikiwiki-upstream' title='ikiwiki-upstream Git repository'/>
</head>
<body>
<div id='cgit'><table id='header'>
<tr>
<td class='logo' rowspan='2'><a href='/'><img src='/cgit-css/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/'>index</a> : <a href='/ikiwiki-upstream/'>ikiwiki-upstream</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='bb5145db896adc038388910226c902ed84acc177'/><select name='h' onchange='this.form.submit();'>
<option value='layoutgala'>layoutgala</option>
<option value='master' selected='selected'>master</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>Unnamed repository; edit this file to name it for gitweb.</td><td class='sub right'>Jonas Smedegaard</td></tr></table>
<table class='tabs'><tr><td>
<a href='/ikiwiki-upstream/'>summary</a><a href='/ikiwiki-upstream/refs/?id=bb5145db896adc038388910226c902ed84acc177'>refs</a><a href='/ikiwiki-upstream/log/debian/changelog'>log</a><a href='/ikiwiki-upstream/tree/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>tree</a><a class='active' href='/ikiwiki-upstream/commit/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>commit</a><a href='/ikiwiki-upstream/diff/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>diff</a></td><td class='form'><form class='right' method='get' action='/ikiwiki-upstream/log/debian/changelog'>
<input type='hidden' name='id' value='bb5145db896adc038388910226c902ed84acc177'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/ikiwiki-upstream/commit/?id=bb5145db896adc038388910226c902ed84acc177'>root</a>/<a href='/ikiwiki-upstream/commit/debian?id=bb5145db896adc038388910226c902ed84acc177'>debian</a>/<a href='/ikiwiki-upstream/commit/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>changelog</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='bb5145db896adc038388910226c902ed84acc177'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'>
<tr><th>author</th><td>joey &lt;joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071&gt;</td><td class='right'>2007-01-23 01:14:30 +0000</td></tr>
<tr><th>committer</th><td>joey &lt;joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071&gt;</td><td class='right'>2007-01-23 01:14:30 +0000</td></tr>
<tr><th>commit</th><td colspan='2' class='oid'><a href='/ikiwiki-upstream/commit/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>bb5145db896adc038388910226c902ed84acc177</a> (<a href='/ikiwiki-upstream/patch/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/ikiwiki-upstream/tree/?id=bb5145db896adc038388910226c902ed84acc177'>8e1e740016c5845b2c0eebd339c405140b02f32c</a> /<a href='/ikiwiki-upstream/tree/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177'>debian/changelog</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/ikiwiki-upstream/commit/debian/changelog?id=7d08057d97e11f427507179bb50bfc5187c5a036'>7d08057d97e11f427507179bb50bfc5187c5a036</a> (<a href='/ikiwiki-upstream/diff/debian/changelog?id=bb5145db896adc038388910226c902ed84acc177&amp;id2=7d08057d97e11f427507179bb50bfc5187c5a036'>diff</a>)</td></tr></table>
<div class='commit-subject'>web commit by HarleyPig</div><div class='commit-msg'></div><div class='diffstat-header'><a href='/ikiwiki-upstream/diff/?id=bb5145db896adc038388910226c902ed84acc177'>Diffstat</a> (limited to 'debian/changelog')</div><table summary='diffstat' class='diffstat'></table><div class='diffstat-summary'>0 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td></td></tr></table></div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.46.0</a>) at 2025-05-29 08:34:02 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
l"><span class="hl slc">#</span></li>
<li id="n_32" class="hl"><span class="hl slc">#======================================================================</span></li>
<li id="n_33" class="hl"></li>
<li id="n_34" class="hl"><span class="hl kwa">package </span>RC<span class="hl opt">;</span></li>
<li id="n_35" class="hl"></li>
<li id="n_36" class="hl"> </li>
<li id="n_37" class="hl"><span class="hl kwa">sub </span>getposlines<span class="hl opt">{</span></li>
<li id="n_38" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_39" class="hl">  <span class="hl kwb">%pos_config </span><span class="hl opt">= %{</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>pos_config<span class="hl opt">}};</span></li>
<li id="n_40" class="hl">  <span class="hl kwb">%pos_sources </span><span class="hl opt">= %{</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>pos_sources<span class="hl opt">}};</span></li>
<li id="n_41" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sources </span><span class="hl opt">= </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">;</span></li>
<li id="n_42" class="hl">  <span class="hl kwa">foreach </span><span class="hl kwb">$key </span><span class="hl opt">(</span><span class="hl kwc">keys </span><span class="hl kwb">%pos_sources</span><span class="hl opt">){</span></li>
<li id="n_43" class="hl">    <span class="hl kwb">$sources </span><span class="hl opt">.= </span><span class="hl sng">&quot;, &#39;</span><span class="hl ipl">$key</span><span class="hl sng">&#39;&quot;</span><span class="hl opt">;</span></li>
<li id="n_44" class="hl">  <span class="hl opt">}</span></li>
<li id="n_45" class="hl">  <span class="hl kwb">$sources </span><span class="hl opt">=~ </span><span class="hl kwd">s/^,\s*//</span><span class="hl opt">;</span></li>
<li id="n_46" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_47" class="hl"></li>
<li id="n_48" class="hl">  <span class="hl slc"># Considering the query below to be safe since all variables are from config</span></li>
<li id="n_49" class="hl">  <span class="hl slc"># files rather than user input.</span></li>
<li id="n_50" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">| </span></li>
<li id="n_51" class="hl">    SELECT sum<span class="hl opt">(</span>amount<span class="hl opt">) </span>AS amount<span class="hl opt">, </span>source FROM acc_trans</li>
<li id="n_52" class="hl">        WHERE chart_id <span class="hl opt">= </span></li>
<li id="n_53" class="hl">        <span class="hl opt">(</span>SELECT id FROM chart WHERE accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$pos_config</span><span class="hl sng">{till_accno}&#39;</span><span class="hl opt">)</span></li>
<li id="n_54" class="hl">      AND transdate <span class="hl opt">= </span>date <span class="hl sng">&#39;NOW&#39;</span></li>
<li id="n_55" class="hl">          AND cleared IS NOT TRUE</li>
<li id="n_56" class="hl">    GROUP BY source</li>
<li id="n_57" class="hl">  <span class="hl opt">|;</span></li>
<li id="n_58" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_59" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_60" class="hl">  <span class="hl kwa">while </span><span class="hl opt">(</span><span class="hl kwc">my </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">)) {</span></li>
<li id="n_61" class="hl">    <span class="hl kwc">push </span><span class="hl opt">&#64;{</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>TB<span class="hl opt">}}, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_62" class="hl">  <span class="hl opt">}</span></li>
<li id="n_63" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_64" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">| </span></li>
<li id="n_65" class="hl">    SELECT sum<span class="hl opt">(</span>amount<span class="hl opt">) </span>AS sum FROM acc_trans</li>
<li id="n_66" class="hl">        WHERE chart_id <span class="hl opt">= </span></li>
<li id="n_67" class="hl">        <span class="hl opt">(</span>SELECT id FROM chart WHERE accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$pos_config</span><span class="hl sng">{till_accno}&#39;</span><span class="hl opt">)</span></li>
<li id="n_68" class="hl">      AND transdate <span class="hl opt">= </span>date <span class="hl sng">&#39;NOW&#39;</span></li>
<li id="n_69" class="hl">          AND cleared IS NOT TRUE</li>
<li id="n_70" class="hl">  <span class="hl opt">|;</span></li>
<li id="n_71" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_72" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_73" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">);</span></li>
<li id="n_74" class="hl">  <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>sum<span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>sum<span class="hl opt">};</span></li>
<li id="n_75" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_76" class="hl"><span class="hl opt">}</span></li>
<li id="n_77" class="hl"></li>
<li id="n_78" class="hl"><span class="hl kwa">sub </span>clear_till <span class="hl opt">{</span></li>
<li id="n_79" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_80" class="hl">  <span class="hl kwb">%pos_config </span><span class="hl opt">= %{</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>pos_config<span class="hl opt">}};</span></li>
<li id="n_81" class="hl">  <span class="hl kwb">%pos_sources </span><span class="hl opt">= %{</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>pos_sources<span class="hl opt">}};</span></li>
<li id="n_82" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sources </span><span class="hl opt">= </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">;</span></li>
<li id="n_83" class="hl">  <span class="hl kwa">foreach </span><span class="hl kwb">$key </span><span class="hl opt">(</span><span class="hl kwc">keys </span><span class="hl kwb">%pos_sources</span><span class="hl opt">){</span></li>
<li id="n_84" class="hl">    <span class="hl kwb">$sources </span><span class="hl opt">.= </span><span class="hl sng">&quot;, &#39;</span><span class="hl ipl">$key</span><span class="hl sng">&#39;&quot;</span><span class="hl opt">;</span></li>
<li id="n_85" class="hl">  <span class="hl opt">}</span></li>
<li id="n_86" class="hl">  <span class="hl kwb">$sources </span><span class="hl opt">=~ </span><span class="hl kwd">s/^,\s//</span><span class="hl opt">;</span></li>
<li id="n_87" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_88" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">| </span></li>
<li id="n_89" class="hl">    UPDATE acc_trans</li>
<li id="n_90" class="hl">    SET cleared <span class="hl opt">= </span>TRUE</li>
<li id="n_91" class="hl">    WHERE chart_id <span class="hl opt">= </span></li>
<li id="n_92" class="hl">        <span class="hl opt">(</span>SELECT id FROM chart WHERE accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$pos_config</span><span class="hl sng">{till_accno}&#39;</span><span class="hl opt">)</span></li>
<li id="n_93" class="hl">      AND transdate <span class="hl opt">= </span>date <span class="hl sng">&#39;NOW&#39;</span></li>
<li id="n_94" class="hl">  <span class="hl opt">|;</span></li>
<li id="n_95" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_96" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_97" class="hl"><span class="hl opt">}</span></li>
<li id="n_98" class="hl"></li>
<li id="n_99" class="hl"><span class="hl kwa">sub </span>getbalance<span class="hl opt">{</span></li>
<li id="n_100" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_101" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_102" class="hl"></li>
<li id="n_103" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT sum<span class="hl opt">(</span>amount<span class="hl opt">) </span>AS balance</li>
<li id="n_104" class="hl">                 FROM acc_trans</li>
<li id="n_105" class="hl">                 WHERE chart_id <span class="hl opt">=</span></li>
<li id="n_106" class="hl">                   <span class="hl opt">(</span>SELECT id FROM chart WHERE accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span><span class="hl opt">)|;</span></li>
<li id="n_107" class="hl"></li>
<li id="n_108" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_109" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_110" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">);</span></li>
<li id="n_111" class="hl">  <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>balance<span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>balance<span class="hl opt">};</span></li>
<li id="n_112" class="hl"><span class="hl opt">}</span></li>
<li id="n_113" class="hl"> </li>
<li id="n_114" class="hl"></li>
<li id="n_115" class="hl"><span class="hl kwa">sub </span>paymentaccounts <span class="hl opt">{</span></li>
<li id="n_116" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_117" class="hl"></li>
<li id="n_118" class="hl">  <span class="hl slc"># connect to database</span></li>
<li id="n_119" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_120" class="hl"></li>
<li id="n_121" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT accno<span class="hl opt">, </span>description</li>
<li id="n_122" class="hl">                 FROM chart</li>
<li id="n_123" class="hl">         WHERE <span class="hl kwc">link </span>LIKE <span class="hl sng">&#39;</span><span class="hl ipl">%_paid%</span><span class="hl sng">&#39;</span></li>
<li id="n_124" class="hl">         AND <span class="hl opt">(</span>category <span class="hl opt">= </span><span class="hl sng">&#39;A&#39;</span> OR category <span class="hl opt">= </span><span class="hl sng">&#39;L&#39;</span><span class="hl opt">)</span></li>
<li id="n_125" class="hl">         ORDER BY accno<span class="hl opt">|;</span></li>
<li id="n_126" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_127" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_128" class="hl"></li>
<li id="n_129" class="hl">  <span class="hl kwa">while </span><span class="hl opt">(</span><span class="hl kwc">my </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">)) {</span></li>
<li id="n_130" class="hl">    <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>PR<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_131" class="hl">  <span class="hl opt">}</span></li>
<li id="n_132" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_133" class="hl"></li>
<li id="n_134" class="hl">  <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">all_years</span><span class="hl opt">(</span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$dbh</span><span class="hl opt">);</span></li>
<li id="n_135" class="hl"></li>
<li id="n_136" class="hl">  <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">disconnect</span><span class="hl opt">;</span></li>
<li id="n_137" class="hl"></li>
<li id="n_138" class="hl"><span class="hl opt">}</span></li>
<li id="n_139" class="hl"></li>
<li id="n_140" class="hl"></li>
<li id="n_141" class="hl"><span class="hl kwa">sub </span>payment_transactions <span class="hl opt">{</span></li>
<li id="n_142" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_143" class="hl"></li>
<li id="n_144" class="hl">  <span class="hl slc"># connect to database, turn AutoCommit off</span></li>
<li id="n_145" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dbconnect_noauto</span><span class="hl opt">(</span><span class="hl kwb">$myconfig</span><span class="hl opt">);</span></li>
<li id="n_146" class="hl"></li>
<li id="n_147" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query</span><span class="hl opt">;</span></li>
<li id="n_148" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth</span><span class="hl opt">;</span></li>
<li id="n_149" class="hl"></li>
<li id="n_150" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT category FROM chart</li>
<li id="n_151" class="hl">              WHERE accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span><span class="hl opt">|;</span></li>
<li id="n_152" class="hl">  <span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>category<span class="hl opt">}) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_153" class="hl">  </li>
<li id="n_154" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$cleared</span><span class="hl opt">;</span></li>
<li id="n_155" class="hl"></li>
<li id="n_156" class="hl">  <span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">}) = </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">from_to</span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>year<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>month<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>interval<span class="hl opt">}) </span><span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>year<span class="hl opt">} &amp;&amp; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>month<span class="hl opt">};</span></li>
<li id="n_157" class="hl"></li>
<li id="n_158" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$transdate </span><span class="hl opt">= </span>qq<span class="hl opt">| </span>AND ac<span class="hl opt">.</span>transdate <span class="hl opt">&lt; </span>date <span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{fromdate}&#39;</span><span class="hl opt">|;</span></li>
<li id="n_159" class="hl"></li>
<li id="n_160" class="hl">  <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">}) {</span></li>
<li id="n_161" class="hl">    <span class="hl kwb">$cleared </span><span class="hl opt">= </span>qq<span class="hl opt">| </span>AND ac<span class="hl opt">.</span>cleared <span class="hl opt">= </span><span class="hl sng">&#39;1&#39;</span><span class="hl opt">|;</span></li>
<li id="n_162" class="hl">    <span class="hl kwb">$transdate </span><span class="hl opt">= </span><span class="hl sng">&quot;&quot;</span><span class="hl opt">;</span></li>
<li id="n_163" class="hl">  <span class="hl opt">}</span></li>
<li id="n_164" class="hl">    </li>
<li id="n_165" class="hl">  <span class="hl slc"># get beginning balance</span></li>
<li id="n_166" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT sum<span class="hl opt">(</span>ac<span class="hl opt">.</span>amount<span class="hl opt">)</span></li>
<li id="n_167" class="hl">          FROM acc_trans ac</li>
<li id="n_168" class="hl">          JOIN chart ch ON <span class="hl opt">(</span>ch<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>chart_id<span class="hl opt">)</span></li>
<li id="n_169" class="hl">          WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_170" class="hl">          <span class="hl kwb">$transdate</span></li>
<li id="n_171" class="hl">          <span class="hl kwb">$cleared</span></li>
<li id="n_172" class="hl">          <span class="hl opt">|;</span></li>
<li id="n_173" class="hl">  <span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>beginningbalance<span class="hl opt">}) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_174" class="hl"></li>
<li id="n_175" class="hl">  <span class="hl slc"># fx balance</span></li>
<li id="n_176" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT sum<span class="hl opt">(</span>ac<span class="hl opt">.</span>amount<span class="hl opt">)</span></li>
<li id="n_177" class="hl">          FROM acc_trans ac</li>
<li id="n_178" class="hl">          JOIN chart ch ON <span class="hl opt">(</span>ch<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>chart_id<span class="hl opt">)</span></li>
<li id="n_179" class="hl">          WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_180" class="hl">          AND ac<span class="hl opt">.</span>fx_transaction <span class="hl opt">= </span><span class="hl sng">&#39;1&#39;</span></li>
<li id="n_181" class="hl">          <span class="hl kwb">$transdate</span></li>
<li id="n_182" class="hl">          <span class="hl kwb">$cleared</span></li>
<li id="n_183" class="hl">          <span class="hl opt">|;</span></li>
<li id="n_184" class="hl">  <span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fx_balance<span class="hl opt">}) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_185" class="hl">  </li>
<li id="n_186" class="hl"></li>
<li id="n_187" class="hl">  <span class="hl kwb">$transdate </span><span class="hl opt">= </span><span class="hl sng">&quot;&quot;</span><span class="hl opt">;</span></li>
<li id="n_188" class="hl">  <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">}) {</span></li>
<li id="n_189" class="hl">    <span class="hl kwb">$transdate </span><span class="hl opt">= </span>qq<span class="hl opt">| </span>AND ac<span class="hl opt">.</span>transdate <span class="hl opt">&lt;= </span>date <span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{todate}&#39;</span><span class="hl opt">|;</span></li>
<li id="n_190" class="hl">  <span class="hl opt">}</span></li>
<li id="n_191" class="hl"> </li>
<li id="n_192" class="hl">  <span class="hl slc"># get statement balance</span></li>
<li id="n_193" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT sum<span class="hl opt">(</span>ac<span class="hl opt">.</span>amount<span class="hl opt">)</span></li>
<li id="n_194" class="hl">          FROM acc_trans ac</li>
<li id="n_195" class="hl">          JOIN chart ch ON <span class="hl opt">(</span>ch<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>chart_id<span class="hl opt">)</span></li>
<li id="n_196" class="hl">          WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_197" class="hl">          <span class="hl kwb">$transdate</span></li>
<li id="n_198" class="hl">          <span class="hl opt">|;</span></li>
<li id="n_199" class="hl">  <span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>endingbalance<span class="hl opt">}) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_200" class="hl"></li>
<li id="n_201" class="hl">  <span class="hl slc"># fx balance</span></li>
<li id="n_202" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT sum<span class="hl opt">(</span>ac<span class="hl opt">.</span>amount<span class="hl opt">)</span></li>
<li id="n_203" class="hl">          FROM acc_trans ac</li>
<li id="n_204" class="hl">          JOIN chart ch ON <span class="hl opt">(</span>ch<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>chart_id<span class="hl opt">)</span></li>
<li id="n_205" class="hl">          WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_206" class="hl">          AND ac<span class="hl opt">.</span>fx_transaction <span class="hl opt">= </span><span class="hl sng">&#39;1&#39;</span></li>
<li id="n_207" class="hl">          <span class="hl kwb">$transdate</span></li>
<li id="n_208" class="hl">          <span class="hl opt">|;</span></li>
<li id="n_209" class="hl">  <span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fx_endingbalance<span class="hl opt">}) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_210" class="hl"></li>
<li id="n_211" class="hl"></li>
<li id="n_212" class="hl">  <span class="hl kwb">$cleared </span><span class="hl opt">= </span>qq<span class="hl opt">| </span>AND ac<span class="hl opt">.</span>cleared <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span><span class="hl opt">| </span><span class="hl kwa">unless </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">};</span></li>
<li id="n_213" class="hl">  </li>
<li id="n_214" class="hl">  <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>report<span class="hl opt">}) {</span></li>
<li id="n_215" class="hl">    <span class="hl kwb">$cleared </span><span class="hl opt">= </span>qq<span class="hl opt">| </span>AND NOT <span class="hl opt">(</span>ac<span class="hl opt">.</span>cleared <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span> OR ac<span class="hl opt">.</span>cleared <span class="hl opt">= </span><span class="hl sng">&#39;1&#39;</span><span class="hl opt">)|;</span></li>
<li id="n_216" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>cleared<span class="hl opt">}) {</span></li>
<li id="n_217" class="hl">      <span class="hl kwb">$cleared </span><span class="hl opt">= </span>qq<span class="hl opt">| </span>AND ac<span class="hl opt">.</span>cleared <span class="hl opt">= </span><span class="hl sng">&#39;1&#39;</span><span class="hl opt">|;</span></li>
<li id="n_218" class="hl">    <span class="hl opt">}</span></li>
<li id="n_219" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>outstanding<span class="hl opt">}) {</span></li>
<li id="n_220" class="hl">      <span class="hl kwb">$cleared </span><span class="hl opt">= (</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>cleared<span class="hl opt">}) ? </span><span class="hl sng">&quot;&quot;</span> <span class="hl opt">: </span>qq<span class="hl opt">| </span>AND ac<span class="hl opt">.</span>cleared <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span><span class="hl opt">|;</span></li>
<li id="n_221" class="hl">    <span class="hl opt">}</span></li>
<li id="n_222" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">}) {</span></li>
<li id="n_223" class="hl">      <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>beginningbalance<span class="hl opt">} = </span><span class="hl num">0</span><span class="hl opt">;</span></li>
<li id="n_224" class="hl">      <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fx_balance<span class="hl opt">} = </span><span class="hl num">0</span><span class="hl opt">;</span></li>
<li id="n_225" class="hl">    <span class="hl opt">}</span></li>
<li id="n_226" class="hl">  <span class="hl opt">}</span></li>
<li id="n_227" class="hl">  </li>
<li id="n_228" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$fx_transaction</span><span class="hl opt">;</span></li>
<li id="n_229" class="hl">  <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fx_transaction<span class="hl opt">}) {</span></li>
<li id="n_230" class="hl">    <span class="hl kwb">$fx_transaction </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_231" class="hl">          AND NOT</li>
<li id="n_232" class="hl">         <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id IN</li>
<li id="n_233" class="hl">          <span class="hl opt">(</span>SELECT fxgain_accno_id FROM defaults</li>
<li id="n_234" class="hl">           UNION</li>
<li id="n_235" class="hl">           SELECT fxloss_accno_id FROM defaults<span class="hl opt">))|;</span></li>
<li id="n_236" class="hl">  <span class="hl opt">} </span><span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_237" class="hl">    <span class="hl kwb">$fx_transaction </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_238" class="hl">          AND ac<span class="hl opt">.</span>fx_transaction <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span><span class="hl opt">|;</span></li>
<li id="n_239" class="hl">  <span class="hl opt">}</span></li>
<li id="n_240" class="hl"> </li>
<li id="n_241" class="hl">  </li>
<li id="n_242" class="hl">  <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>summary<span class="hl opt">}) {</span></li>
<li id="n_243" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT ac<span class="hl opt">.</span>transdate<span class="hl opt">, </span>ac<span class="hl opt">.</span>source<span class="hl opt">,</span></li>
<li id="n_244" class="hl">        sum<span class="hl opt">(</span>ac<span class="hl opt">.</span>amount<span class="hl opt">) </span>AS amount<span class="hl opt">, </span>ac<span class="hl opt">.</span>cleared</li>
<li id="n_245" class="hl">        FROM acc_trans ac</li>
<li id="n_246" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_247" class="hl">        WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_248" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&gt;= </span><span class="hl num">0</span></li>
<li id="n_249" class="hl">        <span class="hl kwb">$fx_transaction</span></li>
<li id="n_250" class="hl">        <span class="hl kwb">$cleared</span><span class="hl opt">|;</span></li>
<li id="n_251" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &gt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{fromdate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">};</span></li>
<li id="n_252" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &lt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{todate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">};</span></li>
<li id="n_253" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; GROUP BY ac.source, ac.transdate, ac.cleared&quot;</span><span class="hl opt">;</span></li>
<li id="n_254" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span>qq<span class="hl opt">|</span></li>
<li id="n_255" class="hl">                UNION ALL</li>
<li id="n_256" class="hl">        SELECT ac<span class="hl opt">.</span>transdate<span class="hl opt">, </span>ac<span class="hl opt">.</span>source<span class="hl opt">,</span></li>
<li id="n_257" class="hl">        sum<span class="hl opt">(</span>ac<span class="hl opt">.</span>amount<span class="hl opt">) </span>AS amount<span class="hl opt">, </span>ac<span class="hl opt">.</span>cleared</li>
<li id="n_258" class="hl">        FROM acc_trans ac</li>
<li id="n_259" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_260" class="hl">        WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_261" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&lt; </span><span class="hl num">0</span></li>
<li id="n_262" class="hl">        <span class="hl kwb">$fx_transaction</span></li>
<li id="n_263" class="hl">        <span class="hl kwb">$cleared</span><span class="hl opt">|;</span></li>
<li id="n_264" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &gt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{fromdate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">};</span></li>
<li id="n_265" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &lt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{todate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">};</span></li>
<li id="n_266" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; GROUP BY ac.source, ac.transdate, ac.cleared&quot;</span><span class="hl opt">;</span></li>
<li id="n_267" class="hl"></li>
<li id="n_268" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; ORDER BY 1,2&quot;</span><span class="hl opt">;</span></li>
<li id="n_269" class="hl">    </li>
<li id="n_270" class="hl">  <span class="hl opt">} </span><span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_271" class="hl">    </li>
<li id="n_272" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT ac<span class="hl opt">.</span>transdate<span class="hl opt">, </span>ac<span class="hl opt">.</span>source<span class="hl opt">, </span>ac<span class="hl opt">.</span>fx_transaction<span class="hl opt">,</span></li>
<li id="n_273" class="hl">        ac<span class="hl opt">.</span>amount<span class="hl opt">, </span>ac<span class="hl opt">.</span>cleared<span class="hl opt">, </span>g<span class="hl opt">.</span>id<span class="hl opt">, </span>g<span class="hl opt">.</span>description</li>
<li id="n_274" class="hl">        FROM acc_trans ac</li>
<li id="n_275" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_276" class="hl">        JOIN gl g ON <span class="hl opt">(</span>g<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_277" class="hl">        WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_278" class="hl">        <span class="hl kwb">$fx_transaction</span></li>
<li id="n_279" class="hl">        <span class="hl kwb">$cleared</span><span class="hl opt">|;</span></li>
<li id="n_280" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &gt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{fromdate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">};</span></li>
<li id="n_281" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &lt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{todate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">};</span></li>
<li id="n_282" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span>qq<span class="hl opt">|</span></li>
<li id="n_283" class="hl">                UNION ALL</li>
<li id="n_284" class="hl">        SELECT ac<span class="hl opt">.</span>transdate<span class="hl opt">, </span>ac<span class="hl opt">.</span>source<span class="hl opt">, </span>ac<span class="hl opt">.</span>fx_transaction<span class="hl opt">,</span></li>
<li id="n_285" class="hl">        ac<span class="hl opt">.</span>amount<span class="hl opt">, </span>ac<span class="hl opt">.</span>cleared<span class="hl opt">, </span>a<span class="hl opt">.</span>id<span class="hl opt">, </span>n<span class="hl opt">.</span>name</li>
<li id="n_286" class="hl">        FROM acc_trans ac</li>
<li id="n_287" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_288" class="hl">        JOIN ar a ON <span class="hl opt">(</span>a<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_289" class="hl">        JOIN customer n ON <span class="hl opt">(</span>n<span class="hl opt">.</span>id <span class="hl opt">= </span>a<span class="hl opt">.</span>customer_id<span class="hl opt">)</span></li>
<li id="n_290" class="hl">        WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_291" class="hl">        <span class="hl kwb">$fx_transaction</span></li>
<li id="n_292" class="hl">        <span class="hl kwb">$cleared</span><span class="hl opt">|;</span></li>
<li id="n_293" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &gt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{fromdate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">};</span></li>
<li id="n_294" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &lt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{todate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">};</span></li>
<li id="n_295" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span>qq<span class="hl opt">|</span></li>
<li id="n_296" class="hl">                UNION ALL</li>
<li id="n_297" class="hl">        SELECT ac<span class="hl opt">.</span>transdate<span class="hl opt">, </span>ac<span class="hl opt">.</span>source<span class="hl opt">, </span>ac<span class="hl opt">.</span>fx_transaction<span class="hl opt">,</span></li>
<li id="n_298" class="hl">        ac<span class="hl opt">.</span>amount<span class="hl opt">, </span>ac<span class="hl opt">.</span>cleared<span class="hl opt">, </span>a<span class="hl opt">.</span>id<span class="hl opt">, </span>n<span class="hl opt">.</span>name</li>
<li id="n_299" class="hl">        FROM acc_trans ac</li>
<li id="n_300" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_301" class="hl">        JOIN ap a ON <span class="hl opt">(</span>a<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_302" class="hl">        JOIN vendor n ON <span class="hl opt">(</span>n<span class="hl opt">.</span>id <span class="hl opt">= </span>a<span class="hl opt">.</span>vendor_id<span class="hl opt">)</span></li>
<li id="n_303" class="hl">        WHERE ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_304" class="hl">        <span class="hl kwb">$fx_transaction</span></li>
<li id="n_305" class="hl">        <span class="hl kwb">$cleared</span><span class="hl opt">|;</span></li>
<li id="n_306" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &gt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{fromdate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>fromdate<span class="hl opt">};</span></li>
<li id="n_307" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND ac.transdate &lt;= &#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{todate}&#39;&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>todate<span class="hl opt">};</span></li>
<li id="n_308" class="hl">    </li>
<li id="n_309" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; ORDER BY 1,2,3&quot;</span><span class="hl opt">;</span></li>
<li id="n_310" class="hl">  <span class="hl opt">}</span></li>
<li id="n_311" class="hl"></li>
<li id="n_312" class="hl">  <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_313" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_314" class="hl"></li>
<li id="n_315" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dr</span><span class="hl opt">;</span></li>
<li id="n_316" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$cr</span><span class="hl opt">;</span></li>
<li id="n_317" class="hl">  </li>
<li id="n_318" class="hl">  <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>summary<span class="hl opt">}) {</span></li>
<li id="n_319" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT c<span class="hl opt">.</span>name</li>
<li id="n_320" class="hl">        FROM customer c</li>
<li id="n_321" class="hl">        JOIN ar a ON <span class="hl opt">(</span>c<span class="hl opt">.</span>id <span class="hl opt">= </span>a<span class="hl opt">.</span>customer_id<span class="hl opt">)</span></li>
<li id="n_322" class="hl">        JOIN acc_trans ac ON <span class="hl opt">(</span>a<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_323" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_324" class="hl">        WHERE ac<span class="hl opt">.</span>transdate <span class="hl opt">= ?</span></li>
<li id="n_325" class="hl">        AND ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_326" class="hl">        AND <span class="hl opt">(</span>ac<span class="hl opt">.</span>source <span class="hl opt">= ? </span>OR ac<span class="hl opt">.</span>source IS NULL<span class="hl opt">)</span></li>
<li id="n_327" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&gt;= </span><span class="hl num">0</span></li>
<li id="n_328" class="hl">        <span class="hl kwb">$cleared</span></li>
<li id="n_329" class="hl">    UNION</li>
<li id="n_330" class="hl">        SELECT v<span class="hl opt">.</span>name</li>
<li id="n_331" class="hl">        FROM vendor v</li>
<li id="n_332" class="hl">        JOIN ap a ON <span class="hl opt">(</span>v<span class="hl opt">.</span>id <span class="hl opt">= </span>a<span class="hl opt">.</span>vendor_id<span class="hl opt">)</span></li>
<li id="n_333" class="hl">        JOIN acc_trans ac ON <span class="hl opt">(</span>a<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_334" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_335" class="hl">        WHERE ac<span class="hl opt">.</span>transdate <span class="hl opt">= ?</span></li>
<li id="n_336" class="hl">        AND ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_337" class="hl">        AND <span class="hl opt">(</span>ac<span class="hl opt">.</span>source <span class="hl opt">= ? </span>OR ac<span class="hl opt">.</span>source IS NULL<span class="hl opt">)</span></li>
<li id="n_338" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&gt; </span><span class="hl num">0</span></li>
<li id="n_339" class="hl">        <span class="hl kwb">$cleared</span></li>
<li id="n_340" class="hl">    UNION</li>
<li id="n_341" class="hl">        SELECT g<span class="hl opt">.</span>description</li>
<li id="n_342" class="hl">        FROM gl g</li>
<li id="n_343" class="hl">        JOIN acc_trans ac ON <span class="hl opt">(</span>g<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_344" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_345" class="hl">        WHERE ac<span class="hl opt">.</span>transdate <span class="hl opt">= ?</span></li>
<li id="n_346" class="hl">        AND ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_347" class="hl">        AND <span class="hl opt">(</span>ac<span class="hl opt">.</span>source <span class="hl opt">= ? </span>OR ac<span class="hl opt">.</span>source IS NULL<span class="hl opt">)</span></li>
<li id="n_348" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&gt;= </span><span class="hl num">0</span></li>
<li id="n_349" class="hl">        <span class="hl kwb">$cleared</span></li>
<li id="n_350" class="hl">        <span class="hl opt">|;</span></li>
<li id="n_351" class="hl">    </li>
<li id="n_352" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; ORDER BY 1&quot;</span><span class="hl opt">;</span></li>
<li id="n_353" class="hl">    <span class="hl kwb">$dr </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_354" class="hl"></li>
<li id="n_355" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT c<span class="hl opt">.</span>name</li>
<li id="n_356" class="hl">        FROM customer c</li>
<li id="n_357" class="hl">        JOIN ar a ON <span class="hl opt">(</span>c<span class="hl opt">.</span>id <span class="hl opt">= </span>a<span class="hl opt">.</span>customer_id<span class="hl opt">)</span></li>
<li id="n_358" class="hl">        JOIN acc_trans ac ON <span class="hl opt">(</span>a<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_359" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_360" class="hl">        WHERE ac<span class="hl opt">.</span>transdate <span class="hl opt">= ?</span></li>
<li id="n_361" class="hl">        AND ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_362" class="hl">        AND <span class="hl opt">(</span>ac<span class="hl opt">.</span>source <span class="hl opt">= ? </span>OR ac<span class="hl opt">.</span>source IS NULL<span class="hl opt">)</span></li>
<li id="n_363" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&lt; </span><span class="hl num">0</span></li>
<li id="n_364" class="hl">        <span class="hl kwb">$cleared</span></li>
<li id="n_365" class="hl">    UNION</li>
<li id="n_366" class="hl">        SELECT v<span class="hl opt">.</span>name</li>
<li id="n_367" class="hl">        FROM vendor v</li>
<li id="n_368" class="hl">        JOIN ap a ON <span class="hl opt">(</span>v<span class="hl opt">.</span>id <span class="hl opt">= </span>a<span class="hl opt">.</span>vendor_id<span class="hl opt">)</span></li>
<li id="n_369" class="hl">        JOIN acc_trans ac ON <span class="hl opt">(</span>a<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_370" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_371" class="hl">        WHERE ac<span class="hl opt">.</span>transdate <span class="hl opt">= ?</span></li>
<li id="n_372" class="hl">        AND ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_373" class="hl">        AND <span class="hl opt">(</span>ac<span class="hl opt">.</span>source <span class="hl opt">= ? </span>OR ac<span class="hl opt">.</span>source IS NULL<span class="hl opt">)</span></li>
<li id="n_374" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&lt; </span><span class="hl num">0</span></li>
<li id="n_375" class="hl">        <span class="hl kwb">$cleared</span></li>
<li id="n_376" class="hl">    UNION</li>
<li id="n_377" class="hl">        SELECT g<span class="hl opt">.</span>description</li>
<li id="n_378" class="hl">        FROM gl g</li>
<li id="n_379" class="hl">        JOIN acc_trans ac ON <span class="hl opt">(</span>g<span class="hl opt">.</span>id <span class="hl opt">= </span>ac<span class="hl opt">.</span>trans_id<span class="hl opt">)</span></li>
<li id="n_380" class="hl">        JOIN chart ch ON <span class="hl opt">(</span>ac<span class="hl opt">.</span>chart_id <span class="hl opt">= </span>ch<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_381" class="hl">        WHERE ac<span class="hl opt">.</span>transdate <span class="hl opt">= ?</span></li>
<li id="n_382" class="hl">        AND ch<span class="hl opt">.</span>accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span></li>
<li id="n_383" class="hl">        AND <span class="hl opt">(</span>ac<span class="hl opt">.</span>source <span class="hl opt">= ? </span>OR ac<span class="hl opt">.</span>source IS NULL<span class="hl opt">)</span></li>
<li id="n_384" class="hl">        AND ac<span class="hl opt">.</span>amount <span class="hl opt">&lt; </span><span class="hl num">0</span></li>
<li id="n_385" class="hl">        <span class="hl kwb">$cleared</span></li>
<li id="n_386" class="hl">        <span class="hl opt">|;</span></li>
<li id="n_387" class="hl">        </li>
<li id="n_388" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span><span class="hl sng">&quot; ORDER BY 1&quot;</span><span class="hl opt">;</span></li>
<li id="n_389" class="hl">    <span class="hl kwb">$cr </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_390" class="hl">  <span class="hl opt">}</span></li>
<li id="n_391" class="hl"> </li>
<li id="n_392" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$name</span><span class="hl opt">;</span></li>
<li id="n_393" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_394" class="hl"></li>
<li id="n_395" class="hl">  <span class="hl kwa">while </span><span class="hl opt">(</span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">)) {</span></li>
<li id="n_396" class="hl"></li>
<li id="n_397" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>summary<span class="hl opt">}) {</span></li>
<li id="n_398" class="hl"></li>
<li id="n_399" class="hl">      <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>amount<span class="hl opt">} &gt; </span><span class="hl num">0</span><span class="hl opt">) {</span></li>
<li id="n_400" class="hl">    <span class="hl kwb">$dr</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>source<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>source<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>source<span class="hl opt">});</span></li>
<li id="n_401" class="hl">    <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>oldcleared<span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>cleared<span class="hl opt">};</span></li>
<li id="n_402" class="hl">    <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>name<span class="hl opt">} = ();</span></li>
<li id="n_403" class="hl"></li>
<li id="n_404" class="hl">    <span class="hl kwa">while </span><span class="hl opt">((</span><span class="hl kwb">$name</span><span class="hl opt">) = </span><span class="hl kwb">$dr</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array</span><span class="hl opt">) {</span></li>
<li id="n_405" class="hl">      <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>name<span class="hl opt">} }, </span><span class="hl kwb">$name</span><span class="hl opt">;</span></li>
<li id="n_406" class="hl">    <span class="hl opt">}</span></li>
<li id="n_407" class="hl">    <span class="hl kwb">$dr</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_408" class="hl">      <span class="hl opt">} </span><span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_409" class="hl">      </li>
<li id="n_410" class="hl">    <span class="hl kwb">$cr</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>source<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>source<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>source<span class="hl opt">});</span></li>
<li id="n_411" class="hl">    <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>oldcleared<span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>cleared<span class="hl opt">};</span></li>
<li id="n_412" class="hl">    <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>name<span class="hl opt">} = ();</span></li>
<li id="n_413" class="hl">    <span class="hl kwa">while </span><span class="hl opt">((</span><span class="hl kwb">$name</span><span class="hl opt">) = </span><span class="hl kwb">$cr</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array</span><span class="hl opt">) {</span></li>
<li id="n_414" class="hl">      <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>name<span class="hl opt">} }, </span><span class="hl kwb">$name</span><span class="hl opt">;</span></li>
<li id="n_415" class="hl">    <span class="hl opt">}</span></li>
<li id="n_416" class="hl">    <span class="hl kwb">$cr</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_417" class="hl">    </li>
<li id="n_418" class="hl">      <span class="hl opt">}</span></li>
<li id="n_419" class="hl"></li>
<li id="n_420" class="hl">    <span class="hl opt">} </span><span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_421" class="hl">      <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>name<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>description<span class="hl opt">};</span></li>
<li id="n_422" class="hl">    <span class="hl opt">}</span></li>
<li id="n_423" class="hl"></li>
<li id="n_424" class="hl">    <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>PR<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_425" class="hl"></li>
<li id="n_426" class="hl">  <span class="hl opt">}</span></li>
<li id="n_427" class="hl">  <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_428" class="hl"></li>
<li id="n_429" class="hl">  <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">disconnect</span><span class="hl opt">;</span></li>
<li id="n_430" class="hl">  </li>
<li id="n_431" class="hl"><span class="hl opt">}</span></li>
<li id="n_432" class="hl"></li>
<li id="n_433" class="hl"></li>
<li id="n_434" class="hl"><span class="hl kwa">sub </span>reconcile <span class="hl opt">{</span></li>
<li id="n_435" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_436" class="hl"></li>
<li id="n_437" class="hl">  <span class="hl slc"># connect to database</span></li>
<li id="n_438" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dbconnect</span><span class="hl opt">(</span><span class="hl kwb">$myconfig</span><span class="hl opt">);</span></li>
<li id="n_439" class="hl"></li>
<li id="n_440" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT id FROM chart</li>
<li id="n_441" class="hl">                 WHERE accno <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{accno}&#39;</span><span class="hl opt">|;</span></li>
<li id="n_442" class="hl">  <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$chart_id</span><span class="hl opt">) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_443" class="hl">  <span class="hl kwb">$chart_id </span><span class="hl opt">*= </span><span class="hl num">1</span><span class="hl opt">;</span></li>
<li id="n_444" class="hl">  </li>
<li id="n_445" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT trans_id FROM acc_trans</li>
<li id="n_446" class="hl">              WHERE <span class="hl opt">(</span>source <span class="hl opt">= ? </span>OR source IS NULL<span class="hl opt">)</span></li>
<li id="n_447" class="hl">          AND transdate <span class="hl opt">= ?</span></li>
<li id="n_448" class="hl">          AND cleared <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_449" class="hl">          AND chart_id <span class="hl opt">= </span><span class="hl kwb">$chart_id</span><span class="hl opt">|;</span></li>
<li id="n_450" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_451" class="hl">    </li>
<li id="n_452" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$i</span><span class="hl opt">;</span></li>
<li id="n_453" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$trans_id</span><span class="hl opt">;</span></li>
<li id="n_454" class="hl"></li>
<li id="n_455" class="hl">  <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>UPDATE acc_trans SET cleared <span class="hl opt">= </span><span class="hl sng">&#39;1&#39;</span></li>
<li id="n_456" class="hl">              WHERE cleared <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_457" class="hl">          AND trans_id <span class="hl opt">= ? </span></li>
<li id="n_458" class="hl">          AND transdate <span class="hl opt">= ?</span></li>
<li id="n_459" class="hl">          AND chart_id <span class="hl opt">= </span><span class="hl kwb">$chart_id</span><span class="hl opt">|;</span></li>
<li id="n_460" class="hl">  <span class="hl kwc">my </span><span class="hl kwb">$tth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_461" class="hl">  </li>
<li id="n_462" class="hl">  <span class="hl slc"># clear flags</span></li>
<li id="n_463" class="hl">  <span class="hl kwa">for </span><span class="hl kwb">$i </span><span class="hl opt">(</span><span class="hl num">1 </span><span class="hl opt">.. </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>rowcount<span class="hl opt">}) {</span></li>
<li id="n_464" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;cleared_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">} &amp;&amp; ! </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;oldcleared_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">}) {</span></li>
<li id="n_465" class="hl">      <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>summary<span class="hl opt">}) {</span></li>
<li id="n_466" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;source_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;transdate_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">}) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">;</span></li>
<li id="n_467" class="hl">      </li>
<li id="n_468" class="hl">    <span class="hl kwa">while </span><span class="hl opt">((</span><span class="hl kwb">$trans_id</span><span class="hl opt">) = </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array</span><span class="hl opt">) {</span></li>
<li id="n_469" class="hl">      <span class="hl kwb">$tth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$trans_id</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;transdate_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">}) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">;</span></li>
<li id="n_470" class="hl">      <span class="hl kwb">$tth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_471" class="hl">    <span class="hl opt">}</span></li>
<li id="n_472" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_473" class="hl">    </li>
<li id="n_474" class="hl">      <span class="hl opt">} </span><span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_475" class="hl"></li>
<li id="n_476" class="hl">    <span class="hl kwb">$tth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;id_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;transdate_</span><span class="hl ipl">$i</span><span class="hl sng">&quot;</span><span class="hl opt">}) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">;</span></li>
<li id="n_477" class="hl">    <span class="hl kwb">$tth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_478" class="hl">      <span class="hl opt">}</span></li>
<li id="n_479" class="hl">    <span class="hl opt">}</span></li>
<li id="n_480" class="hl">  <span class="hl opt">}</span></li>
<li id="n_481" class="hl"></li>
<li id="n_482" class="hl">  <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">disconnect</span><span class="hl opt">;</span></li>
<li id="n_483" class="hl"></li>
<li id="n_484" class="hl"><span class="hl opt">}</span></li>
<li id="n_485" class="hl"></li>
<li id="n_486" class="hl"><span class="hl num">1</span><span class="hl opt">;</span></li>
<li id="n_487" class="hl"></li>
</ol></code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.46.0</a>) at 2025-05-29 08:34:02 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
