Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d13114c0

Von Tamino Steinert vor 8 Tagen hinzugefügt

  • ID d13114c01420dfdd4e0f53909647cf495e111c04
  • Vorgänger e84b30f1

S:C:Part: Massendruck für Artikeletiketten

Unterschiede anzeigen:

SL/DB/Manager/Part.pm
34 34
    return or => [ map { $prefix . $_ => $value } qw(partnumber description ean customerprices.customer_partnumber) ],
35 35
      $prefix . 'customerprices';
36 36
  },
37
  price_change_printed => sub {
38
    my ($key, $value, $prefix) = @_;
39
    die "value must be a scalar ref to a hash ref"
40
      unless ref $value eq 'REF' && ref ($$value) eq 'HASH';
41

  
42
    my %value = %$$value;
43

  
44
    my $template   = $value{template};
45
    my $print_type = $value{print_type};
46
    my $printed    = $value{printed};
47

  
48
    my $comp = !!$printed  ? '>' : '<=';
49

  
50
    # table part_table is aliased as t1
51
    return
52
      [\qq{(
53
        SELECT DISTINCT CASE WHEN count(*) $comp 1 THEN FALSE ELSE TRUE END
54
        FROM (
55
          (
56
            -- last printed or first price
57
            SELECT t2_sellprice
58
            FROM (
59
              (
60
                SELECT
61
                  parts_price_history.sellprice AS t2_sellprice,
62
                  parts_price_history.valid_from AS t2_valid_from,
63
                  parts_price_history.id as t2_id
64
                FROM parts_price_history
65
                JOIN part_label_prints
66
                  ON (parts_price_history.id = part_label_prints.price_history_id)
67
                WHERE parts_price_history.part_id = t1.id AND (
68
                    ('' = ? OR part_label_prints.template = ?) AND
69
                    ('' = ? OR part_label_prints.print_type = ?)
70
                  )
71
                ORDER by
72
                  parts_price_history.valid_from DESC,
73
                  parts_price_history.id DESC
74
                LIMIT 1
75
              ) UNION (
76
                SELECT
77
                  parts_price_history.sellprice AS t2_sellprice,
78
                  parts_price_history.valid_from AS t2_valid_from,
79
                  parts_price_history.id as t2_id
80
                FROM parts_price_history
81
                WHERE part_id = t1.id
82
                ORDER BY
83
                  parts_price_history.valid_from ASC,
84
                  parts_price_history.id ASC
85
                LIMIT 1
86
              )
87
            )
88
            ORDER by
89
              t2_valid_from DESC,
90
              t2_id DESC
91
            LIMIT 1
92
          ) UNION (
93
            -- current price
94
            SELECT parts_price_history.sellprice AS t2_sellprice
95
            FROM parts_price_history
96
            WHERE part_id = t1.id
97
            ORDER BY
98
              parts_price_history.valid_from DESC,
99
              parts_price_history.id
100
            DESC LIMIT 1
101
          )
102
        )
103
        )} => ($template, $template, $print_type, $print_type || 'stock')
104
      ] => \'TRUE';
105
  },
37 106
);
38 107

  
39 108
sub type_filter {

Auch abrufbar als: Unified diff