Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d94f14be

Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt

  • ID d94f14be752b6293190a97fdfd33c12e9b3e57b8
  • Vorgänger 19132371
  • Nachfolger 58186225

Anzahlungs-Rg.: Workflow Anzahlungs-Rg. -> Schluss-Rg.

Unterschiede anzeigen:

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);
......
317 319
    $has_further_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr;
318 320
  }
319 321

  
322
  my $has_final_invoice;
323
  if ($form->{id} && $form->{type} eq "invoice_for_advance_payment") {
324
    my $invoice_obj = SL::DB::Invoice->load_cached($form->{id});
325
    my $lr          = $invoice_obj->linked_records(direction => 'to', to => ['Invoice']);
326
    $has_final_invoice = any {'SL::DB::Invoice' eq ref $_ && "invoice" eq $_->invoice_type} @$lr;
327
  }
328

  
320 329
  for my $bar ($::request->layout->get('actionbar')) {
321 330
    $bar->add(
322 331
      action => [
......
408 417
          disabled => !$may_edit_create ? t8('You must not change this invoice.')
409 418
                    : !$form->{id}      ? t8('This invoice has not been posted yet.')
410 419
                    : $has_further_invoice_for_advance_payment ? t8('This invoice has already a further invoice for advanced payment.')
420
                    : $has_final_invoice                       ? t8('This invoice has already a final invoice.')
421
                    :                     undef,
422
          only_if  => $form->{type} eq "invoice_for_advance_payment",
423
        ],
424
        action => [
425
          t8('Final Invoice'),
426
          submit   => [ '#form', { action => "final_invoice" } ],
427
          checks   => [ 'kivi.validate_form' ],
428
          disabled => !$may_edit_create ? t8('You must not change this invoice.')
429
                    : !$form->{id}      ? t8('This invoice has not been posted yet.')
430
                    : $has_further_invoice_for_advance_payment ? t8('This invoice has a further invoice for advanced payment.')
431
                    : $has_final_invoice                       ? t8('This invoice has already a final invoice.')
411 432
                    :                     undef,
412 433
          only_if  => $form->{type} eq "invoice_for_advance_payment",
413 434
        ],
......
1170 1191
  &display_form;
1171 1192
}
1172 1193

  
1194
sub final_invoice {
1195
  my $form     = $main::form;
1196
  my %myconfig = %main::myconfig;
1197

  
1198
  $main::auth->assert('invoice_edit');
1199

  
1200
  # search all related invoices for advance payment
1201
  #
1202
  # (order) -> invoice for adv. payment 1 -> invoice for adv. payment 2 -> invoice for adv. payment 3 -> final invoice
1203
  #
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;
1210

  
1211
  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

  
1213
  $form->{convert_from_ar_ids} = $form->{id};
1214
  $form->{id}                  = '';
1215
  $form->{type}                = 'invoice';
1216
  $form->{title}               = t8('Edit Final Invoice');
1217
  $form->{paidaccounts}        = 1;
1218
  $form->{invdate}             = $form->current_date(\%myconfig);
1219
  my $terms                    = get_payment_terms_for_invoice();
1220
  $form->{duedate}             = $terms ? $terms->calc_date(reference_date => $form->{invdate})->to_kivitendo : $form->{invdate};
1221
  $form->{employee_id}         = SL::DB::Manager::Employee->current->id;
1222
  $form->{forex}               = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy');
1223
  $form->{exchangerate}        = $form->{forex} if $form->{forex};
1224

  
1225
  foreach my $i (1 .. $form->{"rowcount"}) {
1226
    delete $form->{"id_$i"};
1227
    delete $form->{"invoice_id_$i"};
1228
    delete $form->{"parts_id_$i"};
1229
    delete $form->{"partnumber_$i"};
1230
    delete $form->{"description_$i"};
1231
  }
1232

  
1233
  remove_emptied_rows(1);
1234

  
1235
  my $i = 0;
1236
  foreach my $ri (@related_invoices) {
1237
    foreach my $item (@{$ri->items_sorted}) {
1238
      $i++;
1239
      $form->{"id_$i"}         = $item->parts_id;
1240
      $form->{"partnumber_$i"} = $item->part->partnumber;
1241
      $form->{"discount_$i"}   = $item->discount*100.0;
1242
      $form->{"sellprice_$i"}  = $item->fxsellprice;
1243
      $form->{$_ . "_" . $i}   = $item->$_       for qw(description longdescription qty price_factor_id unit sellprice active_price_source active_discount_source);
1244

  
1245
      $form->{$_ . "_" . $i}   = $form->format_amount(\%myconfig, $form->{$_ . "_" . $i}) for qw(qty sellprice discount);
1246
    }
1247
  }
1248
  $form->{rowcount} = $i;
1249

  
1250
  update();
1251
  $::dispatcher->end_request;
1252
}
1253

  
1173 1254
sub storno {
1174 1255
  $main::lxdebug->enter_sub();
1175 1256

  
locale/de/all
1246 1246
  'Edit Dunning Process Config' => 'Mahnwesenkonfiguration bearbeiten',
1247 1247
  'Edit Employee #1'            => 'Benutzer #1 bearbeiten',
1248 1248
  'Edit Factur-X/ZUGFeRD notes' => 'Factur-X-/ZUGFeRD-Notizen bearbeiten',
1249
  'Edit Final Invoice'          => 'Schlussrechnung bearbeiten',
1249 1250
  'Edit Follow-Up'              => 'Wiedervorlage bearbeiten',
1250 1251
  'Edit Follow-Up for #1'       => 'Wiedervorlage für #1 bearbeiten',
1251 1252
  'Edit General Ledger Transaction' => 'Buchung im Hauptbuch bearbeiten',
......
1555 1556
  'Filter for item variables'   => 'Filter für benutzerdefinierte Artikelvariablen',
1556 1557
  'Filter parts'                => 'Artikel filtern',
1557 1558
  'Filter record template'      => 'Filter für Buchungsvorlagen',
1559
  'Final Invoice'               => 'Schlussrechnung',
1558 1560
  'Financial Controlling'       => 'Finanzcontrolling',
1559 1561
  'Financial Controlling Report' => 'Finanzcontrollingbericht',
1560 1562
  'Financial Overview'          => 'Finanzübersicht',
......
3851 3853
  'This group is valid for the following clients' => 'Diese Gruppe ist für die folgenden Mandanten gültig',
3852 3854
  '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.',
3853 3855
  'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.',
3856
  'This invoice has a further invoice for advanced payment.' => 'Diese Rechnung hat eine weitere Anzahlungsrechnung.',
3857
  'This invoice has already a final invoice.' => 'Diese Rechnung hat schon eine Schlussrechnung.',
3854 3858
  'This invoice has already a further invoice for advanced payment.' => 'Diese Rechnung hat schon eine weitere Anzahlungsrechnung.',
3855 3859
  'This invoice has already been posted.' => 'Die Rechnung wurde bereits gebucht.',
3856 3860
  'This invoice has been canceled already.' => 'Die Rechnung wurde bereits storniert.',
locale/en/all
1246 1246
  'Edit Dunning Process Config' => '',
1247 1247
  'Edit Employee #1'            => '',
1248 1248
  'Edit Factur-X/ZUGFeRD notes' => '',
1249
  'Edit Final Invoice'          => '',
1249 1250
  'Edit Follow-Up'              => '',
1250 1251
  'Edit Follow-Up for #1'       => '',
1251 1252
  'Edit General Ledger Transaction' => '',
......
1555 1556
  'Filter for item variables'   => '',
1556 1557
  'Filter parts'                => '',
1557 1558
  'Filter record template'      => '',
1559
  'Final Invoice'               => '',
1558 1560
  'Financial Controlling'       => '',
1559 1561
  'Financial Controlling Report' => '',
1560 1562
  'Financial Overview'          => '',
......
3846 3848
  'This group is valid for the following clients' => '',
3847 3849
  'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => '',
3848 3850
  'This has been changed in this version.' => '',
3851
  'This invoice has a further invoice for advanced payment.' => '',
3852
  'This invoice has already a final invoice.' => '',
3849 3853
  'This invoice has already a further invoice for advanced payment.' => '',
3850 3854
  'This invoice has already been posted.' => '',
3851 3855
  'This invoice has been canceled already.' => '',

Auch abrufbar als: Unified diff