[set page_banner]Accounts Receivables[/set]
[set fm_class]receivables[/set]
[set help_name]accounts receivables[/set]
[set page_title]Accounts Receivables[/set]
[set icon_name]icon_orders.gif[/set]
@_FM_STD_HEAD_@
[query list=1 sql="SELECT coa_id, date_trunc('month','now'::date) AS periodnr FROM gl_chartofaccount WHERE number = [value acctnr]"]
[seti coa_id][sql-param coa_id][/seti]
[seti periodnr][sql-param periodnr][/seti]
[/query]
[if scratch coa_id]
[then]
[seti sqlSentence]
BEGIN TRANSACTION;
[perl]
my $trans;
$coacct_id = $Scratch->{fm_debtcoaid};
$text = $Scratch->{fm_artext};
$batchtext = $Scratch->{fm_arbatchtext};
$amounttype = $Scratch->{fm_amounttype};
$currency_id = $Scratch->{fm_currencyid};
$batchnr = 1; # 0.01
my $action = $Values->{"mv_action"};
my $ar_id = $Values->{"select_ar"};
if ($action eq "Update") {
$trans = "UPDATE ar_journal SET paid = paid + '[value payment]'::decimal, updated='now' WHERE ar_id = $ar_id;\n";
$trans .= "INSERT INTO ar_payment (contact_id, ar_id, description, amount)
VALUES ([scratch contact_id], $ar_id, '[value description]',[value payment]);\n";
# update of GL
$trans .= "INSERT INTO gl_batch (system_id, type, batchnr, name, status, createddate, posteddate, totaldr, totalcr)
VALUES (10004, 40001, $batchnr, '$batchtext'||$batchnr, 200, 'now', 'now', [value payment], [value payment]);\n";
$trans .= "SELECT gl_posting($coacct_id, NULL, NULL, '[scratch periodnr]',
0, [value payment], '$text', $amounttype, $currency_id, currval('gl_batchsequence'), 1);\n";
$trans .= "SELECT gl_posting([scratch coa_id], NULL, NULL, '[scratch periodnr]',
[value payment], 0, '$text', $amounttype, $currency_id, currval('gl_batchsequence'), 2);\n";
}
undef $Values->{select_ar};
$trans;
[/perl]
COMMIT;
[/seti]
[set returnpage]freemoney/arList[/set]
[set leadtext]The Accounts Receivables entry has been updated[/set]
[value name=mv_action set=""]
[try][sql interpolate=1][scratch sqlSentence][/sql][/try]
[L][scratch leadtext][/L]
[bounce freemoney/arList]
[catch] [L]There was an error updating the Accounts Receivables row. Please check your data.[/L]
[/catch] [L]BACK[/L] [/then] [else] [L]Invalid account number. Please enter a correct acount number[/L] [set returnpage]freemoney/ar[/set] [L]BACK[/L] [/else] [/if] @_FM_STD_FOOTER_@