und einen Fremdschlüssel gesetzt.
}
my $pg_select = $form->{l_pricegroup} ? qq|, pg.pricegroup as pricegroup | : '';
- my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.klass = pg.id) | : '';
+ my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.pricegroup_id = pg.id) | : '';
my $query =
qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | .
qq| pt.description as payment | .
$form->{CONTACTS} = selectall_hashref_query($form, $dbh, $query, $vc_id);
# Only show default pricegroup for customer, not vendor, which is why this is outside the main query
- ($form->{pricegroup}) = selectrow_query($form, $dbh, qq|SELECT pricegroup FROM pricegroup WHERE id = ?|, $form->{klass});
+ ($form->{pricegroup}) = selectrow_query($form, $dbh, qq|SELECT pricegroup FROM pricegroup WHERE id = ?|, $form->{pricegroup_id});
$dbh->disconnect();
{ name => 'greeting', description => $::locale->text('Greeting') },
{ name => 'homepage', description => $::locale->text('Homepage') },
{ name => 'iban', description => $::locale->text('IBAN') },
- { name => 'klass', description => $::locale->text('Preisklasse') },
+ { name => 'pricegroup_id', description => $::locale->text('Price group (database ID)') },
{ name => 'language_id', description => $::locale->text('Language (database ID)') },
{ name => 'language', description => $::locale->text('Language (name)') },
{ name => 'name', description => $::locale->text('Name') },
iban => { type => 'text' },
id => { type => 'integer', not_null => 1, sequence => 'id' },
itime => { type => 'timestamp', default => 'now()' },
- klass => { type => 'integer', default => '0' },
language => { type => 'text' },
language_id => { type => 'integer' },
mandate_date_of_signature => { type => 'date' },
obsolete => { type => 'boolean', default => 'false' },
payment_id => { type => 'integer' },
phone => { type => 'text' },
+ pricegroup_id => { type => 'integer' },
salesman_id => { type => 'integer' },
street => { type => 'text' },
taxincluded => { type => 'boolean' },
key_columns => { payment_id => 'id' },
},
+ pricegroup => {
+ class => 'SL::DB::Pricegroup',
+ key_columns => { pricegroup_id => 'id' },
+ },
+
taxzone => {
class => 'SL::DB::TaxZone',
key_columns => { taxzone_id => 'id' },
my $i = 1;
foreach my $pg (@{ $pricegroups }) {
- $form->{"klass_$i"} = "$pg->{id}";
- $form->{"price_$i"} = $form->format_amount($myconfig, $form->{"price_$i"}, -2);
+ $form->{"price_$i"} = $form->format_amount($myconfig, $form->{"price_$i"}, -2);
$form->{"pricegroup_id_$i"} = "$pg->{id}";
$form->{"pricegroup_$i"} = "$pg->{pricegroup}";
$i++;
c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit,
c.email, c.cc, c.bcc, c.language_id, c.payment_id, c.delivery_term_id,
c.street, c.zipcode, c.city, c.country,
- c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, cu.name AS curr,
+ c.notes AS intnotes, c.pricegroup_id as customer_pricegroup_id, c.taxzone_id, c.salesman_id, cu.name AS curr,
c.taxincluded_checked, c.direct_debit,
b.discount AS tradediscount, b.description AS business
FROM customer c
my @prices = $self->available_prices;
my $customer = $self->record->customer;
- return () if !$customer || !$customer->klass;
+ return () if !$customer || !$customer->pricegroup_id;
- my $best_price = first { $_->spec == $customer->klass } @prices;
+ my $best_price = first { $_->spec == $customer->pricegroup_id } @prices;
return $best_price || ();
}
# business
$TMPL_VAR{business_label} = ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor type'));
- push @custom_hiddens, "customer_klass" if $form->{vc} eq 'customer';
+ push @custom_hiddens, "customer_pricegroup_id" if $form->{vc} eq 'customer';
my $credittext = $locale->text('Credit Limit exceeded!!!');
* In der Rechte-Tabelle auth.master_rights wurden alle Positionswerte mit 100
multipliziert, um Lücken für neue Rechte zu schaffen.
+* In der Tabelle "customer" wurde die Spalte "klass" nach "pricegroup_id"
+ migriert. Bei Kunden ohne Preisgruppe ist der Datenbankwert jetzt NULL statt
+ "0". Falls Kunden per CSV-Import importiert werden muß dieses Feld in der
+ CSV-Datei ebenfalls umbenannt werden.
+
* Es wird jetzt Postgres 9.1 vorausgesetzt um GIN Indizes zu verwenden. Wenn
das auf dem Zielsystem absolut nicht möglich ist, muss das Upgradescript
sql/Pg-Upgrade2/trigram_indices.sql deaktiviert oder entfernt werden.
'Preferences saved!' => 'Einstellungen gespeichert!',
'Prefix for the new bins\' names' => 'Namenspräfix für die neuen Lagerplätze',
'Preis' => 'Preis',
- 'Preisklasse' => 'Preisgruppe',
'Prepare bank collection via SEPA XML' => 'Einzug via SEPA XML vorbereiten',
'Prepare bank transfer via SEPA XML' => 'Überweisung via SEPA XML vorbereiten',
'Prepayment' => 'Vorauszahlung',
'Preferences saved!' => '',
'Prefix for the new bins\' names' => '',
'Preis' => '',
- 'Preisklasse' => '',
'Prepare bank collection via SEPA XML' => '',
'Prepare bank transfer via SEPA XML' => '',
'Prepayment' => '',
--- /dev/null
+-- @tag: customer_klass_rename_to_pricegroup_id_and_foreign_key
+-- @description: klass nach pricegroup_id umbenannt
+-- @depends: release_3_4_1
+-- @ignore: 0
+
+ALTER TABLE customer ADD COLUMN pricegroup_id INTEGER REFERENCES pricegroup (id);
+UPDATE customer SET pricegroup_id = klass WHERE klass != 0;
+ALTER TABLE customer DROP COLUMN klass;
<th align="right">[% 'Price group' | $T8 %]</th>
<td>
- [% L.select_tag('cv.klass', SELF.all_pricegroups, default = SELF.cv.klass, value_key = 'id', title_key = 'pricegroup', with_empty = 1) %]
+ [% L.select_tag('cv.pricegroup_id', SELF.all_pricegroups, default = SELF.cv.pricegroup_id, value_key = 'id', title_key = 'pricegroup', with_empty = 1) %]
</td>
[% END %]
<input type="hidden" name="closed" value="[% HTML.escape(closed) %]">
<input type="hidden" name="convert_from_oe_ids" value="[% HTML.escape(convert_from_oe_ids) %]">
<input type="hidden" name="currency" value="[% HTML.escape(currency) %]">
- <input type="hidden" name="customer_klass" value="[% HTML.escape(customer_klass) %]">
+ <input type="hidden" name="customer_pricegroup_id" value="[% HTML.escape(customer_pricegroup_id) %]">
<input type="hidden" name="discount" value="[% HTML.escape(discount) %]">
<input type="hidden" name="dunning_amount" value="[% HTML.escape(dunning_amount) %]">
<input type="hidden" name="email" value="[% HTML.escape(email) %]">
onChange = "document.getElementById('update_button').click();" -%]
<input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('[% vc | html %]')">
</td>
- <input type="hidden" name="vendor_klass" value="[% HTML.escape(vendor_klass) %]">
<input type="hidden" name="vendor_id" value="[% HTML.escape(vendor_id) %]">
<input type="hidden" name="oldvendor" value="[% HTML.escape(oldvendor) %]">
<input type="hidden" name="selectvendor" value="[% HTML.escape(selectvendor) %]">
allow_textbox = 1,
onChange = "document.getElementById('update_button').click();" -%]
<input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('[% HTML.escape(vc) %]')">
- <input type="hidden" name="customer_klass" value="[% HTML.escape(customer_klass) %]">
+ <input type="hidden" name="customer_pricegroup_id" value="[% HTML.escape(customer_pricegroup_id) %]">
<input type="hidden" name="customer_id" value="[% HTML.escape(customer_id) %]">
<input type="hidden" name="oldcustomer" value="[% HTML.escape(oldcustomer) %]">
<input type="hidden" name="selectcustomer" value="[% HTML.escape(selectcustomer) %]">