Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e0ef8114

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID e0ef8114478cf0cf7b1cc185d759ac2780334c2a
  • Vorgänger 3818b392
  • Nachfolger 418601dd

ZUGFeRD: Buchungsvorlage für Lieferant berücksichtigen

Unterschiede anzeigen:

SL/Controller/ZUGFeRD.pm
257 257
  $self->redirect_to(
258 258
    controller           => 'ap.pl',
259 259
    action               => 'load_zugferd',
260
    no_payment_bookings  => 0,
261
    paid_1_suggestion    => $::form->format_amount(\%::myconfig, $metadata{'total'}, 2),
262
    invnumber            => $invnumber,
263
    AP_chart_id          => $ap_chart_id,
264
    currency             => $currency->name,
265
    duedate              => $metadata{'duedate'},
266
    transdate            => $metadata{'transdate'},
267
    notes                => $notes,
268
    taxincluded          => 0,
269
    direct_debit         => $metadata{'direct_debit'},
270
    vendor               => $vendor->name,
271
    vendor_id            => $vendor->id,
272
    zugferd_session_file => $file_name,
273
    %item_form,
260
    form_defaults => {
261
      zugferd_session_file => $file_name,
262
      vendor_id            => $vendor->id,
263
      vendor               => $vendor->name,
264
      invnumber            => $invnumber,
265
      transdate            => $metadata{'transdate'},
266
      duedate              => $metadata{'duedate'},
267
      no_payment_bookings  => 0,
268
      notes                => $notes,
269
      taxincluded          => 0,
270
      direct_debit         => $metadata{'direct_debit'},
271
      currency             => $currency->name,
272
      AP_chart_id          => $ap_chart_id,
273
      paid_1_suggestion    => $::form->format_amount(\%::myconfig, $metadata{'total'}, 2),
274
      %item_form,
275
    },
274 276
  );
275 277

  
276 278
}
......
351 353
This is just a very basic Parser for ZUGFeRD/Factur-X/XRechnung invoices.
352 354
We assume that the invoice's creator is a company with a valid
353 355
European VAT ID or German tax number and enrolled in
354
Kivitendo. Currently, implementation is a bit hacky because
355
invoice import uses AP record templates as a vessel for
356
generating the AP record form with the imported data filled
357
in.
356
Kivitendo.
358 357

  
359 358
=head1 TODO
360 359

  
......
362 361

  
363 362
=over 4
364 363

  
365
=item Direct creation of the filled in AP record form
366

  
367
Creating an AP record template in the database is not
368
very elegant, since it will spam the database with record
369
templates that become redundant once the invoice has been
370
booked. It would be preferable to fill in the form directly.
371

  
372 364
=item Automatic upload of invoice
373 365

  
374 366
Right now, one has to use the "Book and upload" button to
bin/mozilla/ap.pl
113 113
sub load_zugferd {
114 114
  $::auth->assert('ap_transactions');
115 115

  
116
  my $file_name = $::form->{zugferd_session_file};
116
  my $file_name = $::form->{form_defaults}->{zugferd_session_file};
117
  flash('info', $::locale->text(
118
      "The ZUGFeRD/Factur-X invoice '#1' has been loaded.", $file_name));
119

  
120
  my $template_ap = SL::DB::Manager::RecordTemplate->get_first(where => [vendor_id => $::form->{form_defaults}->{vendor_id}]);
121
  if ($template_ap) {
122
    $::form->{id} = $template_ap->id;
123
    # set default values for items
124
    my $template_item = $template_ap->items->[0];
125
    my $chart = SL::DB::Chart->new(id => $template_item->chart_id)->load();
126
    my $tax = SL::DB::Tax->new(id => $template_item->tax_id)->load();
127
    foreach my $pos (1 .. $::form->{form_defautls}->{rowcount}) {
128
      $::form->{form_defautls}->{"AP_amount_chart_id_$pos"}          = $chart->id;
129
      $::form->{form_defautls}->{"previous_AP_amount_chart_id_$pos"} = $chart->id;
130
      $::form->{form_defautls}->{"taxchart_$pos"}   = $tax->id . '--' . $tax->rate;
131
      $::form->{form_defautls}->{"project_id_$pos"} = $template_item->project_id;
117 132

  
118
  # Defaults
119
  $::form->{title}      ||= "Add";
120
  $::form->{paidaccounts} = 1 if undef $::form->{paidaccounts};
133
    }
134
    $::form->{form_defaults}->{FLASH} = $::form->{FLASH}; # store flash, form gets cleared
135
    return load_record_template();
136
  } else {
137
    flash('error', $::locale->text(
138
        "No AP Record Template for vendor '#1' found.", $::form->{form_defaults}->{vendor}));
139
  }
121 140

  
141
  my $form_defaults = delete $::form->{form_defaults};
142
  $::form->{$_} = $form_defaults->{$_} for keys %{ $form_defaults // {} };
143
  $::form->{title} ||= "Add";
122 144
  $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_PURCHASE_INVOICE_POST())->token;
123
  flash('info', $::locale->text(
124
      "The ZUGFeRD/Factur-X invoice '#1' has been loaded.", $file_name));
125 145
  update(
126 146
    keep_rows_without_amount => 1,
127 147
    dont_add_new_row         => 1,
locale/de/all
2433 2433
  'Next run at'                 => 'Nächste Ausführung um',
2434 2434
  'No'                          => 'Nein',
2435 2435
  'No 1:n or n:1 relation'      => 'Keine 1:n oder n:1 Beziehung',
2436
  'No AP Record Template for vendor \'#1\' found.' => 'Keine Kreditorenbuchungsvorlage für Lieferant \'#1\' gefunden.',
2436 2437
  'No AP template was found.'   => 'Keine Kreditorenbuchungsvorlage gefunden.',
2437 2438
  'No Billing and ship to address, for Order Number #1 with ID Billing #2 and ID Shipping #3' => 'Keine Rechnungs- und Lieferadresse zur Bestellnummer #1 mit Rechnungs-ID #2 und Liefer-ID #3 gefunden',
2438 2439
  'No Company Address given'    => 'Keine Firmenadresse hinterlegt!',
......
2444 2445
  'No Order items fetched'      => 'Keine Auftragspositionen gefunden',
2445 2446
  'No Shopdescription'          => 'Keine Shop-Artikelbeschreibung',
2446 2447
  'No Shopimages'               => 'Keine Shop-Bilder',
2447
  'No VAT Info for this Factur-X/ZUGFeRD invoice, please ask your vendor to add this for his Factur-X/ZUGFeRD data.' => 'Keine USt-Info für diese Factur-X/ZUGFeRD Rechnung, bitte fragen Sie Ihren Lieferanten, diese für seine Factur-X/ZUGFeRD Daten hinzuzufügen.',
2448 2448
  'No Vendor'                   => 'Kein Lieferant',
2449 2449
  'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Händler gefunden',
2450 2450
  'No account selected. Please select an account.' => 'Kein Konto ausgewählt. Bitte Konto auswählen.',
......
2836 2836
  'Pictures for search parts'   => 'Bilder für Warensuche',
2837 2837
  'Please Check the bank information for each customer:' => 'Bitte überprüfen Sie die Bankinformationen der Kunden:',
2838 2838
  'Please Check the bank information for each vendor:' => 'Bitte überprüfen Sie die Kontoinformationen der Lieferanten:',
2839
  'Please add a valid VAT-ID for this vendor: #1' => 'Bitte fügen Sie eine gültige USt-ID für diesen Lieferanten hinzu: #1',
2840 2839
  'Please ask your administrator to create warehouses and bins.' => 'Bitten Sie Ihren Administrator, dass er Lager und Lagerplätze anlegt.',
2841 2840
  'Please change the partnumber of the following parts and run the update again:' => 'Bitte ändern Sie daher die Artikelnummer folgender Artikel:',
2842 2841
  'Please choose a part.'       => 'Bitte wählen Sie einen Artikel aus.',
locale/en/all
2432 2432
  'Next run at'                 => '',
2433 2433
  'No'                          => '',
2434 2434
  'No 1:n or n:1 relation'      => '',
2435
  'No AP Record Template for vendor #1 found, please add one' => '',
2435
  'No AP Record Template for vendor \'#1\' found.' => '',
2436 2436
  'No AP template was found.'   => '',
2437 2437
  'No Billing and ship to address, for Order Number #1 with ID Billing #2 and ID Shipping #3' => '',
2438 2438
  'No Company Address given'    => '',

Auch abrufbar als: Unified diff