Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 34b81691

Von Jan Büren vor fast 2 Jahren hinzugefügt

  • ID 34b816913b6482a75e29474aa921252da7f2fc6e
  • Vorgänger 91d06da8
  • Nachfolger 4d819a87

Cvar für Preisregeln. Proof of Concept mit hartkodierter Bdv articlegroup

Voraussetzung: Eine optionale BDV (Auswahlliste) mit dem Namen articlegroup

Unterschiede anzeigen:

SL/Controller/PriceRule.pm
17 17

  
18 18
use Rose::Object::MakeMethods::Generic
19 19
(
20
 'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses) ],
20
 'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses cvar) ],
21 21
);
22 22

  
23 23
# __PACKAGE__->run_before('check_auth');
......
281 281
  SL::DB::Manager::PartsGroup->get_all;
282 282
}
283 283

  
284
sub init_cvar {
285
  # SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'IC' ]);
286
  # proof of concept: hard coded for articlegroup
287
  SL::DB::Manager::CustomVariableConfig->get_first(where => [ module => 'IC', name => 'articlegroup' ]) ;
288
}
289

  
290

  
284 291
sub all_price_types {
285 292
  SL::DB::Manager::PriceRule->all_price_types;
286 293
}
SL/DB/Manager/PriceRuleItem.pm
32 32
  { type => 'pricegroup', description => t8('Pricegroup'),         customer => 1, vendor => 1, data_type => 'int',  data => sub { $_[1]->pricegroup_id }, exclude_nulls => 1 },
33 33
  { type => 'partsgroup', description => t8('Partsgroup'),         customer => 1, vendor => 1, data_type => 'int',  data => sub { $_[1]->part->partsgroup_id }, exclude_nulls => 1 },
34 34
  { type => 'qty',        description => t8('Qty'),                customer => 1, vendor => 1, data_type => 'num',  data => sub { $_[1]->qty }, ops => 'num' },
35
  { type => 'cvar',       description => t8('Custom Variables'),   customer => 1, vendor => 1, data_type => 'int',  data => sub { $_[1]->part->cvar_by_name('articlegroup')->id }, exclude_nulls => 1 },
35 36
);
36 37

  
38
# ITEM.part.cvar_by_name(var.config.name)
39

  
37 40
sub not_matching_sql_and_values {
38 41
  my ($class, %params) = @_;
39 42

  
SL/DB/PriceRuleItem.pm
128 128
     : $op eq 'lt' ? t8('Transdate is before #1', $self->value_date_as_date)
129 129
     : $op eq 'gt' ? t8('Transdate is after #1',  $self->value_date_as_date)
130 130
     : do { die "unknown op $op for type $type" } )
131
  : $type eq 'cvar' ? t8('Custom Variables')       . ' ' . $self->custom_variable_configs->description . ' ' . $self->value_text
132
#     $self->custom_variable_configs->value_col eq 'text_value' ?  $self->value_text : 'lu'
131 133
  : do { die "unknown type $type" }
132 134
}
133 135

  
templates/webpages/price_rule/item.html
36 36
    [% 'Transdate Record' | $T8 %] [% L.select_tag('price_rule.items[].op', date_compare_ops, default=item.op) %] [% L.date_tag('price_rule.items[].value_date', item.value_date) %]
37 37
  [% CASE 'pricegroup' %]
38 38
    [% 'Pricegroup' | $T8 %] [% 'is' | $T8 %] [% L.select_tag('price_rule.items[].value_int', SELF.pricegroups, title_key='pricegroup', default=item.value_int) %]
39
  [% CASE 'cvar' %]
40
  [% # Dumper.dump_html(SELF.cvar.processed_options) %]
41
    [% 'Custom Variables' | $T8 %] [% 'is' | $T8 %] [% L.select_tag('price_rule.items[].custom_variable_configs_id', SELF.cvar, title_key='description', default=item.custom_variable_configs_id ) %] [% 'with value' | $T8 %]  [% L.select_tag('price_rule.items[].value_text', SELF.cvar.processed_options, title_key='options', default=item.value_text ) %]
42

  
39 43
  [% CASE %]
40 44
[%- END %]
41 45
</div>

Auch abrufbar als: Unified diff