Revision 2d66b506
Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt
bin/mozilla/is.pl | ||
---|---|---|
36 | 36 |
use SL::IS; |
37 | 37 |
use SL::OE; |
38 | 38 |
use SL::MoreCommon qw(restore_form save_form); |
39 |
use SL::RecordLinks; |
|
40 |
|
|
39 | 41 |
use Data::Dumper; |
40 | 42 |
use DateTime; |
41 | 43 |
use List::MoreUtils qw(any uniq); |
... | ... | |
315 | 317 |
$has_further_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr; |
316 | 318 |
} |
317 | 319 |
|
320 |
my $has_final_invoice; |
|
321 |
if ($form->{id} && $form->{type} eq "invoice_for_advance_payment") { |
|
322 |
my $invoice_obj = SL::DB::Invoice->load_cached($form->{id}); |
|
323 |
my $lr = $invoice_obj->linked_records(direction => 'to', to => ['Invoice']); |
|
324 |
$has_final_invoice = any {'SL::DB::Invoice' eq ref $_ && "invoice" eq $_->invoice_type} @$lr; |
|
325 |
} |
|
326 |
|
|
318 | 327 |
for my $bar ($::request->layout->get('actionbar')) { |
319 | 328 |
$bar->add( |
320 | 329 |
action => [ |
... | ... | |
406 | 415 |
disabled => !$may_edit_create ? t8('You must not change this invoice.') |
407 | 416 |
: !$form->{id} ? t8('This invoice has not been posted yet.') |
408 | 417 |
: $has_further_invoice_for_advance_payment ? t8('This invoice has already a further invoice for advanced payment.') |
418 |
: $has_final_invoice ? t8('This invoice has already a final invoice.') |
|
419 |
: undef, |
|
420 |
only_if => $form->{type} eq "invoice_for_advance_payment", |
|
421 |
], |
|
422 |
action => [ |
|
423 |
t8('Final Invoice'), |
|
424 |
submit => [ '#form', { action => "final_invoice" } ], |
|
425 |
checks => [ 'kivi.validate_form' ], |
|
426 |
disabled => !$may_edit_create ? t8('You must not change this invoice.') |
|
427 |
: !$form->{id} ? t8('This invoice has not been posted yet.') |
|
428 |
: $has_further_invoice_for_advance_payment ? t8('This invoice has a further invoice for advanced payment.') |
|
429 |
: $has_final_invoice ? t8('This invoice has already a final invoice.') |
|
409 | 430 |
: undef, |
410 | 431 |
only_if => $form->{type} eq "invoice_for_advance_payment", |
411 | 432 |
], |
... | ... | |
1160 | 1181 |
&display_form; |
1161 | 1182 |
} |
1162 | 1183 |
|
1184 |
sub final_invoice { |
|
1185 |
my $form = $main::form; |
|
1186 |
my %myconfig = %main::myconfig; |
|
1187 |
|
|
1188 |
$main::auth->assert('invoice_edit'); |
|
1189 |
|
|
1190 |
# search all related invoices for advance payment |
|
1191 |
# |
|
1192 |
# (order) -> invoice for adv. payment 1 -> invoice for adv. payment 2 -> invoice for adv. payment 3 -> final invoice |
|
1193 |
# |
|
1194 |
# we are currently in the last invoice for adv. payment (3 in this example) |
|
1195 |
my $invoice_obj = SL::DB::Invoice->load_cached($form->{id}); |
|
1196 |
my $links = $invoice_obj->linked_records(direction => 'from', from => ['Invoice'], recursive => 1); |
|
1197 |
my @related_invoices = grep {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$links; |
|
1198 |
|
|
1199 |
push @related_invoices, $invoice_obj; |
|
1200 |
|
|
1201 |
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)}; |
|
1202 |
|
|
1203 |
$form->{convert_from_ar_ids} = $form->{id}; |
|
1204 |
$form->{id} = ''; |
|
1205 |
$form->{type} = 'invoice'; |
|
1206 |
$form->{title} = t8('Edit Final Invoice'); |
|
1207 |
$form->{paidaccounts} = 1; |
|
1208 |
$form->{invdate} = $form->current_date(\%myconfig); |
|
1209 |
my $terms = get_payment_terms_for_invoice(); |
|
1210 |
$form->{duedate} = $terms ? $terms->calc_date(reference_date => $form->{invdate})->to_kivitendo : $form->{invdate}; |
|
1211 |
$form->{employee_id} = SL::DB::Manager::Employee->current->id; |
|
1212 |
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
|
1213 |
$form->{exchangerate} = $form->{forex} if $form->{forex}; |
|
1214 |
|
|
1215 |
foreach my $i (1 .. $form->{"rowcount"}) { |
|
1216 |
delete $form->{"id_$i"}; |
|
1217 |
delete $form->{"invoice_id_$i"}; |
|
1218 |
delete $form->{"parts_id_$i"}; |
|
1219 |
delete $form->{"partnumber_$i"}; |
|
1220 |
delete $form->{"description_$i"}; |
|
1221 |
} |
|
1222 |
|
|
1223 |
remove_emptied_rows(1); |
|
1224 |
|
|
1225 |
my $i = 0; |
|
1226 |
foreach my $ri (@related_invoices) { |
|
1227 |
foreach my $item (@{$ri->items_sorted}) { |
|
1228 |
$i++; |
|
1229 |
$form->{"id_$i"} = $item->parts_id; |
|
1230 |
$form->{"partnumber_$i"} = $item->part->partnumber; |
|
1231 |
$form->{"discount_$i"} = $item->discount*100.0; |
|
1232 |
$form->{"sellprice_$i"} = $item->fxsellprice; |
|
1233 |
$form->{$_ . "_" . $i} = $item->$_ for qw(description longdescription qty price_factor_id unit sellprice active_price_source active_discount_source); |
|
1234 |
|
|
1235 |
$form->{$_ . "_" . $i} = $form->format_amount(\%myconfig, $form->{$_ . "_" . $i}) for qw(qty sellprice discount); |
|
1236 |
} |
|
1237 |
} |
|
1238 |
$form->{rowcount} = $i; |
|
1239 |
|
|
1240 |
update(); |
|
1241 |
$::dispatcher->end_request; |
|
1242 |
} |
|
1243 |
|
|
1163 | 1244 |
sub storno { |
1164 | 1245 |
$main::lxdebug->enter_sub(); |
1165 | 1246 |
|
locale/de/all | ||
---|---|---|
1236 | 1236 |
'Edit Dunning Process Config' => 'Mahnwesenkonfiguration bearbeiten', |
1237 | 1237 |
'Edit Employee #1' => 'Benutzer #1 bearbeiten', |
1238 | 1238 |
'Edit Factur-X/ZUGFeRD notes' => 'Factur-X-/ZUGFeRD-Notizen bearbeiten', |
1239 |
'Edit Final Invoice' => 'Schlussrechnung bearbeiten', |
|
1239 | 1240 |
'Edit Follow-Up' => 'Wiedervorlage bearbeiten', |
1240 | 1241 |
'Edit Follow-Up for #1' => 'Wiedervorlage für #1 bearbeiten', |
1241 | 1242 |
'Edit General Ledger Transaction' => 'Buchung im Hauptbuch bearbeiten', |
... | ... | |
1538 | 1539 |
'Filter for item variables' => 'Filter für benutzerdefinierte Artikelvariablen', |
1539 | 1540 |
'Filter parts' => 'Artikel filtern', |
1540 | 1541 |
'Filter record template' => 'Filter für Buchungsvorlagen', |
1542 |
'Final Invoice' => 'Schlussrechnung', |
|
1541 | 1543 |
'Financial Controlling' => 'Finanzcontrolling', |
1542 | 1544 |
'Financial Controlling Report' => 'Finanzcontrollingbericht', |
1543 | 1545 |
'Financial Overview' => 'Finanzübersicht', |
... | ... | |
3799 | 3801 |
'This group is valid for the following clients' => 'Diese Gruppe ist für die folgenden Mandanten gültig', |
3800 | 3802 |
'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => 'Das wurde in dieser Version umgestellt, bitte ändern Sie die Freitext-Lagerplätze auf vorhandene Lagerplätze.', |
3801 | 3803 |
'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.', |
3804 |
'This invoice has a further invoice for advanced payment.' => 'Diese Rechnung hat eine weitere Anzahlungsrechnung.', |
|
3805 |
'This invoice has already a final invoice.' => 'Diese Rechnung hat schon eine Schlussrechnung.', |
|
3802 | 3806 |
'This invoice has already a further invoice for advanced payment.' => 'Diese Rechnung hat schon eine weitere Anzahlungsrechnung.', |
3803 | 3807 |
'This invoice has already been posted.' => 'Die Rechnung wurde bereits gebucht.', |
3804 | 3808 |
'This invoice has been canceled already.' => 'Die Rechnung wurde bereits storniert.', |
locale/en/all | ||
---|---|---|
1236 | 1236 |
'Edit Dunning Process Config' => '', |
1237 | 1237 |
'Edit Employee #1' => '', |
1238 | 1238 |
'Edit Factur-X/ZUGFeRD notes' => '', |
1239 |
'Edit Final Invoice' => '', |
|
1239 | 1240 |
'Edit Follow-Up' => '', |
1240 | 1241 |
'Edit Follow-Up for #1' => '', |
1241 | 1242 |
'Edit General Ledger Transaction' => '', |
... | ... | |
1538 | 1539 |
'Filter for item variables' => '', |
1539 | 1540 |
'Filter parts' => '', |
1540 | 1541 |
'Filter record template' => '', |
1542 |
'Final Invoice' => '', |
|
1541 | 1543 |
'Financial Controlling' => '', |
1542 | 1544 |
'Financial Controlling Report' => '', |
1543 | 1545 |
'Financial Overview' => '', |
... | ... | |
3798 | 3800 |
'This group is valid for the following clients' => '', |
3799 | 3801 |
'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => '', |
3800 | 3802 |
'This has been changed in this version.' => '', |
3803 |
'This invoice has a further invoice for advanced payment.' => '', |
|
3804 |
'This invoice has already a final invoice.' => '', |
|
3801 | 3805 |
'This invoice has already a further invoice for advanced payment.' => '', |
3802 | 3806 |
'This invoice has already been posted.' => '', |
3803 | 3807 |
'This invoice has been canceled already.' => '', |
Auch abrufbar als: Unified diff
Anzahlungs-Rg.: Workflow Anzahlungs-Rg. -> Schluss-Rg.