Revision 32ee774f
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/SEPA.pm | ||
---|---|---|
336 | 336 |
|
337 | 337 |
my $myconfig = \%main::myconfig; |
338 | 338 |
my $form = $main::form; |
339 |
my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; |
|
340 |
my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; |
|
341 |
my $mult = $params{vc} eq 'customer' ? -1 : 1; |
|
342 |
my $ARAP = uc $arap; |
|
339 | 343 |
|
340 | 344 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
341 | 345 |
|
... | ... | |
346 | 350 |
FROM sepa_export_items sei |
347 | 351 |
WHERE sei.id = ?| ], |
348 | 352 |
|
349 |
'get_ap' => [ qq|SELECT at.chart_id
|
|
353 |
'get_arap' => [ qq|SELECT at.chart_id
|
|
350 | 354 |
FROM acc_trans at |
351 | 355 |
LEFT JOIN chart c ON (at.chart_id = c.id) |
352 | 356 |
WHERE (trans_id = ?) |
353 |
AND ((c.link LIKE '%:AP') OR (c.link LIKE 'AP:%') OR (c.link = 'AP'))
|
|
357 |
AND ((c.link LIKE '%:${ARAP}') OR (c.link LIKE '${ARAP}:%') OR (c.link = '${ARAP}'))
|
|
354 | 358 |
LIMIT 1| ], |
355 | 359 |
|
356 | 360 |
'add_acc_trans' => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo) |
357 | 361 |
VALUES (?, ?, ?, ?, current_date, ?, '')| ], |
358 | 362 |
|
359 |
'update_ap' => [ qq|UPDATE ap
|
|
363 |
'update_arap' => [ qq|UPDATE ${arap}
|
|
360 | 364 |
SET paid = paid + ? |
361 | 365 |
WHERE id = ?| ], |
362 | 366 |
|
... | ... | |
388 | 392 |
|
389 | 393 |
next if (!$orig_item); |
390 | 394 |
|
391 |
# Retrieve the invoice's AP chart ID. |
|
392 |
do_statement($form, @{ $handles{get_ap} }, $orig_item->{ap_id});
|
|
393 |
my ($ap_chart_id) = $handles{get_ap}->[0]->fetchrow_array();
|
|
395 |
# Retrieve the invoice's AR/AP chart ID.
|
|
396 |
do_statement($form, @{ $handles{get_arap} }, $orig_item->{"${arap}_id"});
|
|
397 |
my ($arap_chart_id) = $handles{get_arap}->[0]->fetchrow_array();
|
|
394 | 398 |
|
395 |
# Record the payment in acc_trans offsetting AP. |
|
396 |
do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{ap_id}, $ap_chart_id, -1 * $orig_item->{amount}, $item->{execution_date}, '');
|
|
397 |
do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{ap_id}, $orig_item->{chart_id}, $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference});
|
|
399 |
# Record the payment in acc_trans offsetting AR/AP.
|
|
400 |
do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id, -1 * $mult * $orig_item->{amount}, $item->{execution_date}, '');
|
|
401 |
do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id}, $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference});
|
|
398 | 402 |
|
399 | 403 |
# Update the invoice to reflect the new paid amount. |
400 |
do_statement($form, @{ $handles{update_ap} }, $orig_item->{amount}, $orig_item->{ap_id});
|
|
404 |
do_statement($form, @{ $handles{update_arap} }, $orig_item->{amount}, $orig_item->{"${arap}_id"});
|
|
401 | 405 |
|
402 | 406 |
# Update the item to reflect that it has been posted. |
403 | 407 |
do_statement($form, @{ $handles{finish_item} }, $item->{execution_date}, $item_id); |
Auch abrufbar als: Unified diff
Unterscheidung Bankeinzug/Überweisung beim Verbuchen von Zahlungen