1518 |
1518 |
$query =
|
1519 |
1519 |
qq|SELECT
|
1520 |
1520 |
c.name AS customer, c.discount, c.creditlimit, c.terms,
|
1521 |
|
c.email, c.cc, c.bcc, c.language_id, c.payment_id AS customer_payment_id,
|
|
1521 |
c.email, c.cc, c.bcc, c.language_id, c.payment_id,
|
1522 |
1522 |
c.street, c.zipcode, c.city, c.country,
|
1523 |
1523 |
c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id,
|
1524 |
1524 |
$duedate + COALESCE(pt.terms_netto, 0) AS duedate,
|
... | ... | |
1550 |
1550 |
$ref = selectfirst_hashref_query($form, $dbh, $query, $cid);
|
1551 |
1551 |
map { $form->{$_} = $ref->{$_} } keys %$ref;
|
1552 |
1552 |
|
1553 |
|
#check whether payment_terms are better than old payment_terms
|
1554 |
|
if (($form->{payment_id} ne "") && ($form->{customer_payment_id} ne "")) {
|
1555 |
|
$query =
|
1556 |
|
qq|SELECT
|
1557 |
|
(SELECT ranking FROM payment_terms WHERE id = ?),
|
1558 |
|
(SELECT ranking FROM payment_terms WHERE id = ?)|;
|
1559 |
|
my ($old_ranking, $new_ranking)
|
1560 |
|
= selectrow_query($form, $dbh, $query, conv_i($form->{payment_id}), conv_i($form->{customer_payment_id}));
|
1561 |
|
if ($new_ranking > $old_ranking) {
|
1562 |
|
$form->{payment_id} = $form->{customer_payment_id};
|
1563 |
|
}
|
1564 |
|
}
|
1565 |
|
|
1566 |
|
if ($form->{payment_id} eq "") {
|
1567 |
|
$form->{payment_id} = $form->{customer_payment_id};
|
1568 |
|
}
|
1569 |
|
|
1570 |
1553 |
$form->{creditremaining} = $form->{creditlimit};
|
1571 |
1554 |
$query = qq|SELECT SUM(amount - paid) FROM ar WHERE customer_id = ?|;
|
1572 |
1555 |
my ($value) = selectrow_query($form, $dbh, $query, $cid);
|
... | ... | |
1755 |
1738 |
}
|
1756 |
1739 |
}
|
1757 |
1740 |
|
1758 |
|
#check whether payment_terms are better than old payment_terms
|
1759 |
|
if (($form->{payment_id} ne "") && ($form->{part_payment_id} ne "")) {
|
1760 |
|
$query =
|
1761 |
|
qq|SELECT
|
1762 |
|
(SELECT ranking FROM payment_terms WHERE id = ?),
|
1763 |
|
(SELECT ranking FROM payment_terms WHERE id = ?)|;
|
1764 |
|
my ($old_ranking, $new_ranking)
|
1765 |
|
= selectrow_query($form, $dbh, $query, conv_i($form->{payment_id}), conv_i($form->{part_payment_id}));
|
1766 |
|
if ($new_ranking > $old_ranking) {
|
1767 |
|
$form->{payment_id} = $form->{customer_payment_id};
|
1768 |
|
}
|
1769 |
|
}
|
1770 |
|
|
1771 |
1741 |
if ($form->{payment_id} eq "") {
|
1772 |
1742 |
$form->{payment_id} = $form->{part_payment_id};
|
1773 |
1743 |
}
|
Die Variable "ranking" für Zahlungsbedinungen konnte nirgends konfiguriert werden. Zusätzlich werden beim Wechsel des Kunden in einer Verkaufsmaske die beim Kunden hinterlegten Zahlungsbedingungen immer ausgewählt, nicht nur dann, wenn vorher keine ausgewählt waren.