Revision 58186225
Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
1054 | 1054 |
# entsprechend auch beim Bestimmen des Steuerschlüssels in Taxkey.pm berücksichtigen |
1055 | 1055 |
my $taxdate = $form->{tax_point} ||$form->{deliverydate} || $form->{invdate}; |
1056 | 1056 |
|
1057 |
|
|
1058 |
# reverse booking for invoices for advance payment |
|
1059 |
my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id}); |
|
1060 |
foreach my $invoice_for_advance_payment (@$invoices_for_advance_payment) { |
|
1061 |
my $transactions = SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $invoice_for_advance_payment->id ], sort_by => 'acc_trans_id ASC'); |
|
1062 |
foreach my $transaction (@$transactions) { |
|
1063 |
$form->{amount}->{$invoice_for_advance_payment->id}->{$transaction->chart->accno} = -1 * $transaction->amount; |
|
1064 |
} |
|
1065 |
} |
|
1066 |
|
|
1057 | 1067 |
foreach my $trans_id (keys %{ $form->{amount_cogs} }) { |
1058 | 1068 |
foreach my $accno (keys %{ $form->{amount_cogs}{$trans_id} }) { |
1059 | 1069 |
next unless ($form->{expense_inventory} =~ /\Q$accno\E/); |
... | ... | |
1474 | 1484 |
return 1; |
1475 | 1485 |
} |
1476 | 1486 |
|
1487 |
sub _get_invoices_for_advance_payment { |
|
1488 |
my ($self, $id) = @_; |
|
1489 |
|
|
1490 |
return [] if !$id; |
|
1491 |
|
|
1492 |
my $invoice_obj = SL::DB::Invoice->new(id => $id*1)->load; |
|
1493 |
my $links = $invoice_obj->linked_records(direction => 'from', from => ['Invoice'], recursive => 1); |
|
1494 |
my @related_invoices = grep {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$links; |
|
1495 |
|
|
1496 |
push @related_invoices, $invoice_obj if "invoice_for_advance_payment" eq $invoice_obj->type; |
|
1497 |
|
|
1498 |
return \@related_invoices; |
|
1499 |
} |
|
1500 |
|
|
1501 |
|
|
1477 | 1502 |
sub transfer_out { |
1478 | 1503 |
$::lxdebug->enter_sub; |
1479 | 1504 |
|
bin/mozilla/is.pl | ||
---|---|---|
1202 | 1202 |
# (order) -> invoice for adv. payment 1 -> invoice for adv. payment 2 -> invoice for adv. payment 3 -> final invoice |
1203 | 1203 |
# |
1204 | 1204 |
# we are currently in the last invoice for adv. payment (3 in this example) |
1205 |
my $invoice_obj = SL::DB::Invoice->load_cached($form->{id}); |
|
1206 |
my $links = $invoice_obj->linked_records(direction => 'from', from => ['Invoice'], recursive => 1); |
|
1207 |
my @related_invoices = grep {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$links; |
|
1208 |
|
|
1209 |
push @related_invoices, $invoice_obj; |
|
1205 |
my $related_invoices = IS->_get_invoices_for_advance_payment($form->{id}); |
|
1210 | 1206 |
|
1211 | 1207 |
delete @{ $form }{qw(printed emailed queued invnumber invdate exchangerate forex deliverydate datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno locked)}; |
1212 | 1208 |
|
... | ... | |
1233 | 1229 |
remove_emptied_rows(1); |
1234 | 1230 |
|
1235 | 1231 |
my $i = 0; |
1236 |
foreach my $ri (@related_invoices) { |
|
1232 |
foreach my $ri (@$related_invoices) {
|
|
1237 | 1233 |
foreach my $item (@{$ri->items_sorted}) { |
1238 | 1234 |
$i++; |
1239 | 1235 |
$form->{"id_$i"} = $item->parts_id; |
Auch abrufbar als: Unified diff
Anzahlungs-Rg.: Gegenbuchung bei Schluss-Rg.