Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d331a3d7

Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt

  • ID d331a3d77f0b24a301412799d2e9cc5fa1bf27ba
  • Vorgänger 9c8450d9
  • Nachfolger c25ec982

Nutzung der Tabelle currencies

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

Unterschiede anzeigen:

SL/IS.pm
458 458
  my $query =
459 459
    qq|SELECT ct.*, cp.*, ct.notes as customernotes,
460 460
         ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail,
461
         ct.curr AS currency
461
         (SELECT cu.curr FROM currencies cu WHERE cu.id=ct.curr) AS currency
462 462
       FROM customer ct
463 463
       LEFT JOIN contacts cp on ct.id = cp.cp_cv_id
464 464
       WHERE (ct.id = ?) $where
......
478 478

  
479 479
  map { $form->{$_} = $ref->{$_} } keys %$ref;
480 480

  
481
  # remove any trailing whitespace
482
  $form->{currency} =~ s/\s*$// if ($form->{currency});
483

  
484 481
  if ($form->{delivery_customer_id}) {
485 482
    $query =
486 483
      qq|SELECT *, notes as customernotes
......
536 533
  }
537 534

  
538 535
  $form->{defaultcurrency} = $form->get_default_currency($myconfig);
536
  my $defaultcurrency = $form->{defaultcurrency};
537

  
539 538
  # Seit neuestem wird die department_id schon übergeben UND $form->department nicht mehr
540 539
  # korrekt zusammengebaut. Sehr wahrscheinlich beim Umstieg auf T8 kaputt gegangen
541 540
  # Ich lass den Code von 2005 erstmal noch stehen ;-) jb 03-2011
......
556 555
      $query = qq|SELECT nextval('glid')|;
557 556
      ($form->{"id"}) = selectrow_query($form, $dbh, $query);
558 557

  
559
      $query = qq|INSERT INTO ar (id, invnumber) VALUES (?, ?)|;
560
      do_query($form, $dbh, $query, $form->{"id"}, $form->{"id"});
558
      $query = qq|INSERT INTO ar (id, invnumber, curr) VALUES (?, ?, (SELECT id FROM currencies WHERE curr=?))|;
559
      do_query($form, $dbh, $query, $form->{"id"}, $form->{"id"}, $form->{currency});
561 560

  
562 561
      if (!$form->{invnumber}) {
563 562
        $form->{invnumber} =
......
570 569
  my ($netamount, $invoicediff) = (0, 0);
571 570
  my ($amount, $linetotal, $lastincomeaccno);
572 571

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

  
576 572
  if ($form->{currency} eq $defaultcurrency) {
577 573
    $form->{exchangerate} = 1;
578 574
  } else {
......
1085 1081
                amount      = ?, netamount     = ?, paid          = ?,
1086 1082
                duedate     = ?, deliverydate  = ?, invoice       = ?, shippingpoint = ?,
1087 1083
                shipvia     = ?, terms         = ?, notes         = ?, intnotes      = ?,
1088
                curr        = ?, department_id = ?, payment_id    = ?, taxincluded   = ?,
1084
                curr        = (SELECT id FROM currencies WHERE curr= ?),
1085
                department_id = ?, payment_id    = ?, taxincluded   = ?,
1089 1086
                type        = ?, language_id   = ?, taxzone_id    = ?, shipto_id     = ?,
1090 1087
                employee_id = ?, salesman_id   = ?, storno_id     = ?, storno        = ?,
1091 1088
                cp_id       = ?, marge_total   = ?, marge_percent = ?,
......
1558 1555
         (SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id)    AS income_accno,
1559 1556
         (SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id)   AS expense_accno,
1560 1557
         (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id)    AS fxgain_accno,
1561
         (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id)    AS fxloss_accno,
1562
         d.curr AS currencies
1558
         (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id)    AS fxloss_accno
1563 1559
         ${query_transdate}
1564 1560
       FROM defaults d|;
1565 1561

  
......
1578 1574
           a.orddate, a.quodate, a.globalproject_id,
1579 1575
           a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.gldate,
1580 1576
           a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.taxzone_id,
1581
           a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id,
1577
           a.duedate, a.taxincluded, (SELECT cu.curr FROM currencies cu WHERE cu.id=a.curr) AS currency, a.shipto_id, a.cp_id,
1582 1578
           a.employee_id, a.salesman_id, a.payment_id,
1583 1579
           a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type,
1584 1580
           a.transaction_description, a.donumber, a.invnumber_for_credit_note,
......
1590 1586
    $ref = selectfirst_hashref_query($form, $dbh, $query, $id);
1591 1587
    map { $form->{$_} = $ref->{$_} } keys %{ $ref };
1592 1588

  
1593
    # remove any trailing whitespace
1594
    $form->{currency} =~ s/\s*$//;
1595

  
1596 1589
    $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy");
1597 1590

  
1598 1591
    # get shipto
......
1757 1750
         c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit, c.terms,
1758 1751
         c.email, c.cc, c.bcc, c.language_id, c.payment_id,
1759 1752
         c.street, c.zipcode, c.city, c.country,
1760
         c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, c.curr,
1753
         c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, (SELECT cu.curr FROM currencies cu WHERE cu.id=c.curr) AS curr,
1761 1754
         c.taxincluded_checked, c.direct_debit,
1762 1755
         $duedate + COALESCE(pt.terms_netto, 0) AS duedate,
1763 1756
         b.discount AS tradediscount, b.description AS business
......
1772 1765

  
1773 1766
  map { $form->{$_} = $ref->{$_} } keys %$ref;
1774 1767

  
1775
  # remove any trailing whitespace
1776
  $form->{curr} =~ s/\s*$//;
1777

  
1778
  # use customer currency if not empty
1779
  $form->{currency} = $form->{curr} if $form->{curr};
1768
  # use customer currency
1769
  $form->{currency} = $form->{curr};
1780 1770

  
1781 1771
  $query =
1782 1772
    qq|SELECT sum(amount - paid) AS dunning_amount

Auch abrufbar als: Unified diff