1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
4 package SL::DB::ShopPart;
9 use SL::DB::MetaSetup::ShopPart;
10 use SL::DB::Manager::ShopPart;
11 use SL::DB::Helper::AttrHTML;
12 #use SL::DB::Helper::ActsAsList;
14 __PACKAGE__->meta->initialize;
15 __PACKAGE__->attr_html('shop_description');
17 sub get_tax_and_price {
22 my ( $price_src_str, $price_src_id ) = split(/\//,$self->active_price_source);
25 if ($price_src_str eq "master_data") {
26 $part = SL::DB::Manager::Part->find_by( id => $self->part_id );
27 $price = $part->$price_src_id;
29 $part = SL::DB::Manager::Part->find_by( id => $self->part_id );
30 $price = $part->prices->[0]->price;
34 my $dbh = $::form->get_standard_dbh();
35 my $b_id = $part->buchungsgruppen_id;
36 my $t_id = $self->shop->taxzone_id;
38 my $sql_str = "SELECT a.rate AS taxrate from tax a
39 WHERE a.taxkey = (SELECT b.taxkey_id
40 FROM chart b LEFT JOIN taxzone_charts c ON b.id = c.income_accno_id
41 WHERE c.taxzone_id = $t_id
42 AND c.buchungsgruppen_id = $b_id)";
44 my $rate = selectall_hashref_query($::form, $dbh, $sql_str);
45 $taxrate = @$rate[0]->{taxrate}*100;
47 $tax_n_price->{price} = $price;
48 $tax_n_price->{tax} = $taxrate;
53 my ($self, %params) = @_;
55 require SL::DB::ShopImage;
56 my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $self->{part_id}, ], with_objects => 'file', sort_by => 'position' );
58 foreach my $img (@{ $images }) {
59 my $file = SL::File->get(id => $img->file->id );
60 # no good: split("\." , 202.220.pdf) -> invaild extension 220
61 # file->extension should be in SL::File, a valid extension may also be 'tar.gz'
62 my ($path, $extension) = split(/\.([^\.]+)$/, $file->file_name);
63 my $content = File::Slurp::read_file($file->get_file);
66 link => $params{want_binary} ? $content : 'data:' . $file->mime_type . ';base64,' . MIME::Base64::encode($content, ""),
67 description => $img->file->title,
68 position => $img->position,
69 extension => $extension,
72 push( @upload_img, $temp);
87 SL::DB::ShopPart - Model for the 'shop_parts' table
91 This is a standard Rose::DB::Object based model and can be used as one.
97 =item C<get_tax_and_price>
99 Returns the price and the taxrate for an shop_article
103 Returns the images for the shop_article
109 Prices, pricesources, pricerules could be implemented
113 Werner Hahn E<lt>wh@futureworldsearch.netE<gt>