Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8ddfcdc4

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

  • ID 8ddfcdc45791bc4a5a74eeaea3e50eeb964256d2
  • Vorgänger c2bd717d

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
use Rose::Object::MakeMethods::Generic
(
'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses) ],
'scalar --get_set_init' => [ qw(models price_rule vc pricegroups partsgroups businesses cvar) ],
);
# __PACKAGE__->run_before('check_auth');
......
SL::DB::Manager::PartsGroup->get_all;
}
sub init_cvar {
# SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'IC' ]);
# proof of concept: hard coded for articlegroup
SL::DB::Manager::CustomVariableConfig->get_first(where => [ module => 'IC', name => 'articlegroup' ]) ;
}
sub all_price_types {
SL::DB::Manager::PriceRule->all_price_types;
}
SL/DB/Manager/PriceRuleItem.pm
{ type => 'pricegroup', description => t8('Pricegroup'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->pricegroup_id }, exclude_nulls => 1 },
{ type => 'partsgroup', description => t8('Partsgroup'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->part->partsgroup_id }, exclude_nulls => 1 },
{ type => 'qty', description => t8('Qty'), customer => 1, vendor => 1, data_type => 'num', data => sub { $_[1]->qty }, ops => 'num' },
{ 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 },
);
# ITEM.part.cvar_by_name(var.config.name)
sub not_matching_sql_and_values {
my ($class, %params) = @_;
SL/DB/PriceRuleItem.pm
: $op eq 'lt' ? t8('Transdate is before #1', $self->value_date_as_date)
: $op eq 'gt' ? t8('Transdate is after #1', $self->value_date_as_date)
: do { die "unknown op $op for type $type" } )
: $type eq 'cvar' ? t8('Custom Variables') . ' ' . $self->custom_variable_configs->description . ' ' . $self->value_text
# $self->custom_variable_configs->value_col eq 'text_value' ? $self->value_text : 'lu'
: do { die "unknown type $type" }
}
templates/webpages/price_rule/item.html
[% '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) %]
[% CASE 'pricegroup' %]
[% 'Pricegroup' | $T8 %] [% 'is' | $T8 %] [% L.select_tag('price_rule.items[].value_int', SELF.pricegroups, title_key='pricegroup', default=item.value_int) %]
[% CASE 'cvar' %]
[% # Dumper.dump_html(SELF.cvar.processed_options) %]
[% '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 ) %]
[% CASE %]
[%- END %]
</div>

Auch abrufbar als: Unified diff