Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6e61f90a

Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt

  • ID 6e61f90a8efa2fe1ed10bac083ac80875ffd5ca0
  • Vorgänger 98452aaa
  • Nachfolger 20bb56c1

Verwendung von benutzerdefinierten Variablen für Waren/Dienstleistungen/Erzegunisse in Einkaufsrechnungen implementiert.

Unterschiede anzeigen:

SL/IR.pm
37 37
use SL::AM;
38 38
use SL::ARAP;
39 39
use SL::Common;
40
use SL::CVar;
40 41
use SL::DBUtils;
41 42
use SL::DO;
42 43
use SL::GenericTranslations;
......
52 53
  my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
53 54
  $form->{defaultcurrency} = $form->get_default_currency($myconfig);
54 55

  
56
  my $ic_cvar_configs = CVar->get_configs(module => 'IC',
57
                                          dbh    => $dbh);
58

  
55 59
  my ($query, $sth, @values, $project_id);
56 60
  my ($allocated, $taxrate, $taxamount, $taxdiff, $item);
57 61
  my ($amount, $linetotal, $lastinventoryaccno, $lastexpenseaccno);
......
290 294
    next if $payments_only;
291 295

  
292 296
    # save detail record in invoice table
297
    my ($invoice_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('invoiceid')|);
298

  
293 299
    $query =
294
      qq|INSERT INTO invoice (trans_id, parts_id, description, qty, base_qty,
300
      qq|INSERT INTO invoice (id, trans_id, parts_id, description, qty, base_qty,
295 301
                              sellprice, fxsellprice, allocated, unit, deliverydate,
296 302
                              project_id, serialnumber, price_factor_id, price_factor, marge_price_factor)
297
         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|;
298
    @values = (conv_i($form->{id}), conv_i($form->{"id_$i"}),
303
         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|;
304
    @values = ($invoice_id, conv_i($form->{id}), conv_i($form->{"id_$i"}),
299 305
               $form->{"description_$i"}, $form->{"qty_$i"} * -1,
300 306
               $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $allocated,
301 307
               $form->{"unit_$i"}, conv_date($form->{deliverydate}),
302 308
               conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"},
303 309
               conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"marge_price_factor_$i"}));
304 310
    do_query($form, $dbh, $query, @values);
311

  
312
    CVar->save_custom_variables(module       => 'IC',
313
                                sub_module   => 'invoice',
314
                                trans_id     => $invoice_id,
315
                                configs      => $ic_cvar_configs,
316
                                variables    => $form,
317
                                name_prefix  => 'ic_',
318
                                name_postfix => "_$i",
319
                                dbh          => $dbh);
305 320
  }
306 321

  
307 322
  $h_item_unit->finish();
......
760 775
        c2.accno AS income_accno,    c2.new_chart_id AS income_new_chart,    date($transdate) - c2.valid_from AS income_valid,
761 776
        c3.accno AS expense_accno,   c3.new_chart_id AS expense_new_chart,   date($transdate) - c3.valid_from AS expense_valid,
762 777

  
778
        i.id AS invoice_id,
763 779
        i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
764 780
        i.price_factor_id, i.price_factor, i.marge_price_factor,
765 781
        p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup
......
778 794
  $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
779 795

  
780 796
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
797
    # Retrieve custom variables.
798
    my $cvars = CVar->get_custom_variables(dbh        => $dbh,
799
                                           module     => 'IC',
800
                                           sub_module => 'invoice',
801
                                           trans_id   => $ref->{invoice_id},
802
                                          );
803
    map { $ref->{"ic_cvar_$_->{name}"} = $_->{value} } @{ $cvars };
804
    delete $ref->{invoice_id};
805

  
781 806
    map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"};
782 807
    delete($ref->{"part_inventory_accno_id"});
783 808

  

Auch abrufbar als: Unified diff