Revision 915cb1a4
Von Jan Büren vor mehr als 4 Jahren hinzugefügt
SL/DN.pm | ||
---|---|---|
346 | 346 |
my ($send_email, $print_invoice) = (0, 0); |
347 | 347 |
|
348 | 348 |
foreach my $row (@{ $rows }) { |
349 |
if ($row->{credit_note}) { |
|
350 |
my $i = $row->{row}; |
|
351 |
%{ $form->{LIST_CREDIT_NOTES}{$row->{customer_id}}{$row->{invoice_id}} } = ( |
|
352 |
open_amount => $form->{"open_amount_$i"}, |
|
353 |
amount => $form->{"amount_$i"}, |
|
354 |
invnumber => $form->{"invnumber_$i"}, |
|
355 |
invdate => $form->{"invdate_$i"}, |
|
356 |
); |
|
357 |
next; |
|
358 |
} |
|
349 | 359 |
push @invoice_ids, $row->{invoice_id}; |
350 | 360 |
$next_dunning_config_id = $row->{next_dunning_config_id}; |
351 | 361 |
$customer_id = $row->{customer_id}; |
... | ... | |
364 | 374 |
$next_config_id, $next_config_id); |
365 | 375 |
do_statement($form, $h_insert_dunning, $q_insert_dunning, @values); |
366 | 376 |
} |
377 |
# die this transaction, because for this customer only credit notes are |
|
378 |
# selected ... |
|
379 |
return unless $customer_id; |
|
367 | 380 |
|
368 | 381 |
$h_update_ar->finish(); |
369 | 382 |
$h_insert_dunning->finish(); |
... | ... | |
580 | 593 |
if (!$form->{l_include_direct_debit}) { |
581 | 594 |
$where .= qq| AND NOT COALESCE(a.direct_debit, FALSE) |; |
582 | 595 |
} |
596 |
my $paid = ($form->{l_include_credit_notes}) ? "WHERE (a.paid <> a.amount)" : "WHERE (a.paid < a.amount)"; |
|
583 | 597 |
|
584 | 598 |
$query = |
585 | 599 |
qq|SELECT |
... | ... | |
628 | 642 |
WHERE (d2.trans_id = a.id) |
629 | 643 |
AND (d2.dunning_level = cfg.dunning_level) |
630 | 644 |
)) |
631 |
|
|
632 |
WHERE (a.paid < a.amount) |
|
633 |
AND (a.duedate < current_date) |
|
645 |
$paid |
|
646 |
AND (a.duedate < current_date) |
|
634 | 647 |
|
635 | 648 |
$where |
636 | 649 |
|
... | ... | |
641 | 654 |
|
642 | 655 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
643 | 656 |
next if ($ref->{pastdue} < $ref->{terms}); |
644 |
|
|
657 |
$ref->{credit_note} = 1 if ($ref->{amount} < 0 && $form->{l_include_credit_notes}); |
|
645 | 658 |
$ref->{interest} = $form->round_amount($ref->{interest}, 2); |
646 | 659 |
push(@{ $form->{DUNNINGS} }, $ref); |
647 | 660 |
} |
... | ... | |
869 | 882 |
} |
870 | 883 |
$sth->finish(); |
871 | 884 |
|
885 |
# if we have some credit notes to add, do a safety check on the first customer id |
|
886 |
# and add one entry for each credit note |
|
887 |
if ($form->{LIST_CREDIT_NOTES} && $form->{LIST_CREDIT_NOTES}->{$form->{TEMPLATE_ARRAYS}->{"dn_customer_id"}[0]}) { |
|
888 |
my $first_customer_id = $form->{TEMPLATE_ARRAYS}->{"dn_customer_id"}[0]; |
|
889 |
while ( my ($cred_id, $value) = each(%{ $form->{LIST_CREDIT_NOTES}->{$first_customer_id} } ) ) { |
|
890 |
map { push @{ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} }, $value->{$_} } keys %{ $value }; |
|
891 |
} |
|
892 |
} |
|
872 | 893 |
$query = |
873 | 894 |
qq|SELECT |
874 | 895 |
c.id AS customer_id, c.name, c.street, c.zipcode, c.city, |
... | ... | |
918 | 939 |
$form->{interest_rate} = $form->format_amount($myconfig, $ref->{interest_rate} * 100); |
919 | 940 |
$form->{fee} = $form->format_amount($myconfig, $ref->{fee}, 2); |
920 | 941 |
$form->{total_interest} = $form->format_amount($myconfig, $form->round_amount($ref->{total_interest}, 2), 2); |
921 |
$form->{total_open_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{total_open_amount}, 2), 2); |
|
922 |
$form->{total_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{fee} + $ref->{total_interest} + $ref->{total_open_amount}, 2), 2); |
|
942 |
my $total_open_amount = $ref->{total_open_amount}; |
|
943 |
if ($form->{l_include_credit_notes}) { |
|
944 |
# a bit stupid, but redo calc because of credit notes |
|
945 |
$total_open_amount = 0; |
|
946 |
foreach my $amount (@{ $form->{TEMPLATE_ARRAYS}->{dn_open_amount} }) { |
|
947 |
$total_open_amount += $form->parse_amount($myconfig, $amount, 2); |
|
948 |
} |
|
949 |
} |
|
950 |
$form->{total_open_amount} = $form->format_amount($myconfig, $form->round_amount($total_open_amount, 2), 2); |
|
951 |
$form->{total_amount} = $form->format_amount($myconfig, $form->round_amount($ref->{fee} + $ref->{total_interest} + $total_open_amount, 2), 2); |
|
923 | 952 |
|
924 | 953 |
$::form->format_dates($output_dateformat, $output_longdates, |
925 | 954 |
qw(dn_dunning_date dn_dunning_duedate dn_transdate dn_duedate |
bin/mozilla/dn.pl | ||
---|---|---|
209 | 209 |
|
210 | 210 |
my $saved_language_id = $form->{language_id}; |
211 | 211 |
|
212 |
if ($form->{groupinvoices}) { |
|
212 |
if ($form->{groupinvoices} || $form->{l_include_credit_notes}) {
|
|
213 | 213 |
my %dunnings_for; |
214 | 214 |
|
215 | 215 |
for my $i (1 .. $form->{rowcount}) { |
... | ... | |
223 | 223 |
|
224 | 224 |
push @{ $level }, { "row" => $i, |
225 | 225 |
"invoice_id" => $form->{"inv_id_$i"}, |
226 |
"credit_note" => $form->{"credit_note_$i"}, |
|
226 | 227 |
"customer_id" => $form->{"customer_id_$i"}, |
227 | 228 |
"language_id" => $form->{"language_id_$i"}, |
228 | 229 |
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"}, |
locale/de/all | ||
---|---|---|
161 | 161 |
'Add Assortment' => 'Sortiment erfassen', |
162 | 162 |
'Add Client' => 'Neuer Mandant', |
163 | 163 |
'Add Credit Note' => 'Gutschrift erfassen', |
164 |
'Add Credit Note for this dunning level:' => 'Diese Gutschrift für untenstehende Mahnstufe anzeigen', |
|
164 | 165 |
'Add Customer' => 'Kunde erfassen', |
165 | 166 |
'Add Customer/Vendor Number as a reference add-on for SEPA export.' => 'Kunden- Lieferantennummer im Verwendungszweck bei SEPA-Überweisungen anhängen', |
166 | 167 |
'Add Delivery Note' => 'Lieferschein erfassen', |
... | ... | |
216 | 217 |
'Add new price rule item' => 'Neue Bedingung hinzufügen', |
217 | 218 |
'Add new record template' => 'Neue Belegvorlage hinzufügen', |
218 | 219 |
'Add note' => 'Notiz erfassen', |
220 |
'Add open Credit Notes' => 'Offene Gutschriften hinzufügen', |
|
219 | 221 |
'Add part' => 'Artikel hinzufügen', |
220 | 222 |
'Add part classification' => 'Artikel-Klassifizierung hinzufügen', |
221 | 223 |
'Add partsgroup' => 'Warengruppe hinzufügen', |
templates/webpages/dunning/add.html | ||
---|---|---|
68 | 68 |
<th align="right" nowrap><label for="l_include_direct_debit">[% 'Include invoices with direct debit' | $T8 %]</label></th> |
69 | 69 |
<td><input type="checkbox" value="1" id="l_include_direct_debit" name="l_include_direct_debit"></td> |
70 | 70 |
</tr> |
71 |
<tr> |
|
72 |
<th align="right" nowrap><label for="l_include_credit_notes">[% 'Add open Credit Notes' | $T8 %]</label></th> |
|
73 |
<td><input type="checkbox" value="1" id="l_include_credit_notes" name="l_include_credit_notes"></td> |
|
74 |
</tr> |
|
71 | 75 |
</table> |
72 | 76 |
</form> |
templates/webpages/dunning/show_invoices.html | ||
---|---|---|
61 | 61 |
</td> |
62 | 62 |
|
63 | 63 |
<td> |
64 |
[% IF row.credit_note %] |
|
65 |
[% LxERP.t8("Add Credit Note for this dunning level:") %] |
|
66 |
<input type="hidden" name="credit_note_[% loop.count %]" value="1"> |
|
67 |
[% END %] |
|
64 | 68 |
<select name="next_dunning_config_id_[% loop.count %]"> |
65 | 69 |
[% FOREACH cfg_row = row.DUNNING_CONFIG %]<option value="[% HTML.escape(cfg_row.id) %]" [% IF cfg_row.SELECTED %]selected[% END %]>[% HTML.escape(cfg_row.dunning_description) %]</option>[% END %] |
66 | 70 |
</select> |
... | ... | |
94 | 98 |
|
95 | 99 |
<input name="rowcount" type="hidden" value="[% HTML.escape(rowcount) %]"> |
96 | 100 |
<input name="groupinvoices" type="hidden" value="[% HTML.escape(groupinvoices) %]"> |
97 |
|
|
101 |
<input name="l_include_credit_notes" type="hidden" value="[% HTML.escape(l_include_credit_notes) %]"> |
|
98 | 102 |
<input name="callback" type="hidden" value="[% HTML.escape(callback) %]"> |
99 | 103 |
</form> |
Auch abrufbar als: Unified diff
Mahnungen: Offene Gutschriften anzeigen und bei Auswahl gegen Offene Posten rechnen
Falls der Haken in der Übersicht gemacht wird, werden alle offenen
Gutschriften für den jeweiligen Kunden angezeigt. Wenn diese aktiviert
werden, werden diese Gutschriften für die jeweilige Mahnstufe ausgegeben.
Entsprechend wird die Summe der offenen Zahlung reduziert.
Offen: Im Mahnungsbericht werden die Mahnungen dann allerdings ohne
die Gutschriften angezeigt