Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision be776964

Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt

  • ID be776964b83340e69fa2f02eae59b703c0c95b88
  • Vorgänger 6d06b178
  • Nachfolger 014161b8

Nutzung der Tabelle currencies

Dieser Commmit passt den Code an, um die Tabelle currencies zu nutzen.

Unterschiede anzeigen:

SL/IR.pm
57 57
  # connect to database, turn off autocommit
58 58
  my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
59 59
  $form->{defaultcurrency} = $form->get_default_currency($myconfig);
60
  my $defaultcurrency = $form->{defaultcurrency};
60 61

  
61 62
  my $ic_cvar_configs = CVar->get_configs(module => 'IC',
62 63
                                          dbh    => $dbh);
......
70 71

  
71 72
  my $all_units = AM->retrieve_units($myconfig, $form);
72 73

  
74
#markierung
73 75
  if (!$payments_only) {
74 76
    if ($form->{id}) {
75 77
      &reverse_invoice($dbh, $form);
76 78
    } else {
77 79
      ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
78
      do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber) VALUES (?, '')|, $form->{id});
80
      do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber, curr) VALUES (?, '', (SELECT id FROM currencies WHERE curr=?))|, $form->{id}, $form->{currency});
79 81
    }
80 82
  }
81 83

  
82
  my ($currencies)    = selectfirst_array_query($form, $dbh, qq|SELECT curr FROM defaults|);
83
  my $defaultcurrency = (split m/:/, $currencies)[0];
84

  
85 84
  if ($form->{currency} eq $defaultcurrency) {
86 85
    $form->{exchangerate} = 1;
87 86
  } else {
......
686 685
                orddate      = ?, quodate     = ?, vendor_id     = ?, amount      = ?,
687 686
                netamount    = ?, paid        = ?, duedate       = ?,
688 687
                invoice      = ?, taxzone_id  = ?, notes         = ?, taxincluded = ?,
689
                intnotes     = ?, curr        = ?, storno_id     = ?, storno      = ?,
688
                intnotes     = ?, storno_id   = ?, storno        = ?,
690 689
                cp_id        = ?, employee_id = ?, department_id = ?,
691 690
                globalproject_id = ?, direct_debit = ?
692 691
              WHERE id = ?|;
......
695 694
      conv_date($form->{orddate}), conv_date($form->{quodate}),     conv_i($form->{vendor_id}),               $amount,
696 695
                $netamount,                  $form->{paid},      conv_date($form->{duedate}),
697 696
            '1',                             $taxzone_id,                  $form->{notes},          $form->{taxincluded} ? 't' : 'f',
698
                $form->{intnotes},           $form->{currency},     conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f',
697
                $form->{intnotes},           conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f',
699 698
         conv_i($form->{cp_id}),      conv_i($form->{employee_id}), conv_i($form->{department_id}),
700 699
         conv_i($form->{globalproject_id}),
701 700
                $form->{direct_debit} ? 't' : 'f',
......
924 923
               (SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id)    AS income_accno,
925 924
               (SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id)   AS expense_accno,
926 925
               (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id)    AS fxgain_accno,
927
               (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id)    AS fxloss_accno,
928
               d.curr AS currencies
926
               (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id)    AS fxloss_accno
929 927
               $q_invdate
930 928
               FROM defaults d|;
931 929
  $ref = selectfirst_hashref_query($form, $dbh, $query);
......
942 940
  $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate,
943 941
                orddate, quodate, globalproject_id,
944 942
                ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate,
945
                intnotes, curr AS currency, direct_debit
943
                intnotes, (SELECT cu.curr FROM currencies cu WHERE cu.id=ap.curr) AS currency, direct_debit
946 944
              FROM ap
947 945
              WHERE id = ?|;
948 946
  $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id}));
949 947
  map { $form->{$_} = $ref->{$_} } keys %$ref;
950 948

  
951
  # remove any trailing whitespace
952
  $form->{currency} =~ s/\s*$//;
953

  
954 949
  $form->{exchangerate}  = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell");
955 950

  
956 951
  # get shipto
......
1092 1087
         v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount,
1093 1088
         v.creditlimit, v.terms, v.notes AS intnotes,
1094 1089
         v.email, v.cc, v.bcc, v.language_id, v.payment_id,
1095
         v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, v.direct_debit,
1090
         v.street, v.zipcode, v.city, v.country, v.taxzone_id, (SELECT cu.curr FROM currencies cu WHERE cu.id=v.curr) AS curr, v.direct_debit,
1096 1091
         $duedate + COALESCE(pt.terms_netto, 0) AS duedate,
1097 1092
         b.description AS business
1098 1093
       FROM vendor v
......
1102 1097
  my $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
1103 1098
  map { $params->{$_} = $ref->{$_} } keys %$ref;
1104 1099

  
1105
  # remove any trailing whitespace
1106
  $form->{curr} =~ s/\s*$//;
1107

  
1108
  # use vendor currency if not empty
1109
  $form->{currency} = $form->{curr} if $form->{curr};
1100
  # use vendor currency
1101
  $form->{currency} = $form->{curr};
1110 1102

  
1111 1103
  $params->{creditremaining} = $params->{creditlimit};
1112 1104

  
......
1392 1384
  # fax and phone and email as vendor*
1393 1385
  my $query =
1394 1386
    qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail,
1395
         ct.curr AS currency
1387
         (SELECT cu.curr FROM currencies cu WHERE cu.id=ct.curr) AS currency
1396 1388
       FROM vendor ct
1397 1389
       LEFT JOIN contacts cp ON (ct.id = cp.cp_cv_id)
1398 1390
       WHERE (ct.id = ?) $contact
......
1411 1403
  }
1412 1404

  
1413 1405
  map { $form->{$_} = $ref->{$_} } keys %$ref;
1414
  # remove any trailing whitespace
1415
  $form->{currency} =~ s/\s*$// if ($form->{currency});
1416 1406

  
1417 1407
  my $custom_variables = CVar->get_custom_variables('dbh'      => $dbh,
1418 1408
                                                    'module'   => 'CT',

Auch abrufbar als: Unified diff