Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision df362eed

Von Werner Hahn vor etwa 7 Jahren hinzugefügt

  • ID df362eed6dafc99f7462b44407ba90c7cc83100c
  • Vorgänger 7df8f2e4
  • Nachfolger dc84cf04

Shopmodul: sql-Updatesfiles für das Shopmodul.
Beinhaltet auch ein hinzufügen der Spalte Auftragssperre in der Tabelle customer sowie das webtemplate billing beim Kunden wo die Auftragssperre eingegeben werden kann

Unterschiede anzeigen:

SL/BackgroundJob/ShopOrderMassTransfer.pm
42 42
  foreach my $shop_order_id (@{ $job_obj->data_as_hash->{shop_order_record_ids} }) {
43 43
    my $data = $job_obj->data_as_hash;
44 44
    my $shop_order = SL::DB::ShopOrder->new(id => $shop_order_id)->load;
45
    # die "can't find shoporder with id $shop_order_id" unless $shop_order;
46
    #TODO Kundenabfrage so ändern, dass es nicht abricht
47 45
    unless($shop_order){
48 46
      push @{ $error_report{$shop_order_id} }, 'Shoporder not found';
49 47
    }
......
52 50
    my $employee = SL::DB::Manager::Employee->current;
53 51
    my $items = SL::DB::Manager::ShopOrderItem->get_all( where => [shop_order_id => $shop_order_id],
54 52
                                                          sort_by => 'partnumber::int' );
55
    # check inventory onhand > 0 and active = 1
56
    my $transferable = 0;
57
    foreach my $item (@$items) {
58
      my $part = SL::DB::Manager::Part->find_by(partnumber => $item->{partnumber});
59
      # TODO: qty direkt aus dem Lager holen und nicht von onhand
60
      $transferable = $part->{onhand} >= $item->{quantity} ? 1 : 0;
61
      $transferable = $part->{active} = 1 ? 1 : 0;
62

  
63
      last if $transferable == 0;
64
    }
65
    if ($transferable == 1 && $customer->{order_lock} == 0) {
53
    if ($customer->{order_lock} == 0) {
66 54
      $shop_order->{shop_order_items} = $items;
67 55

  
68 56
      my $order = $shop_order->convert_to_sales_order(customer => $customer, employee => $employee);
......
85 73
      push @{ $data->{shop_orders_ids} }, $shop_order->id;
86 74

  
87 75
      $job_obj->update_attributes(data_as_hash => $data);
88
      my $delivery_order = $order->convert_to_delivery_order(customer => $customer, employee => $employee);
89
      $delivery_order->save;
90
      my $snumbers = "deliveryordernumber_" . $delivery_order->donumber;
91
      SL::DB::History->new(
92
                        trans_id    => $delivery_order->id,
93
                        snumbers    => $snumbers,
94
                        employee_id => SL::DB::Manager::Employee->current->id,
95
                        addition    => 'SAVED',
96
                        what_done   => 'Shopimport->Order->Deliveryorder(MassTransfer)',
97
                      )->save();
98
      $order->link_to_record($delivery_order);
99
      my $delivery_order_items = $delivery_order->{orderitems};
100
      # Lagerentnahme
101
      # entsprechende defaults holen, falls standardlagerplatz verwendet werden soll
102
      my $test = $::instance_conf->get_transfer_default_use_master_default_bin;
103
      require SL::DB::Inventory;
104
      my $rose_db = SL::DB::Inventory->new->db;
105
      my $dbh = $db->dbh;
106
      my $default_warehouse_id;
107
      my $default_bin_id;
108
      my @parts_ids;
109
      my @transfers;
110
      my @errors;
111
      my $qty;
112
      my $stock_out;
113
      require SL::WH;
114
      require SL::IS;
115
      require SL::DB::DeliveryOrderItemsStock;
116
      foreach my $item (@{$delivery_order_items}) {
117
        my ($err, $wh_id, $bin_id) = IS->_determine_wh_and_bin($dbh, $::instance_conf,
118
                                                           $item->{parts_id},
119
                                                           $item->{qty},
120
                                                           $item->{unit}
121
                                                           );
122
        if (!@{ $err } && $wh_id && $bin_id) {
123
          my $delivery_order_items_stock = SL::DB::DeliveryOrderItemsStock->new;
124
          $delivery_order_items_stock->assign_attributes (
125
            'delivery_order_item_id'  => $item->{id},
126
            'qty'                     => $item->{qty},
127
            'unit'                    => $item->{unit},
128
            'warehouse_id'            => $wh_id,
129
            'bin_id'                  => $bin_id,
130
          );
131
          $delivery_order_items_stock->save;
132

  
133
          my ($trans_id) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT nextval('id')|);
134
          my $wh_transfer = SL::DB::Inventory->new;
135
          $wh_transfer->assign_attributes (
136
            'trans_id'                      => $trans_id,
137
            'employee'                      => $employee->{id},
138
            'bestbefore'                    => undef,
139
            'chargenumber'                  => '',
140
            'shippingdate'                  => DateTime->today,
141
            'delivery_order_items_stock_id' => $delivery_order_items_stock->id,
142
            'project_id'                    => '',
143
            'parts_id'                      => $item->{parts_id},
144
            'qty'                           => $item->{qty} * -1,
145
            'trans_type_id'              => 889,#hardcodiert
146
            'warehouse_id'                  => $wh_id,
147
            'bin_id'                        => $bin_id,
148
            'comment'                       => $main::locale->text("Default transfer delivery order"),
149
            'oe_id'                         => $delivery_order->{id},
150
          );
151
          $wh_transfer->save;
152
        }
153
        push @errors, @{ $err };
154
      }
155
      if (!@errors) {
156
          $delivery_order->delivered(1);
157
          $delivery_order->save;
158
      }
159 76
    }
160 77
  }
161 78
}
sql/Pg-upgrade2/customer_orderlock.sql
1
-- @tag: customer_orderlock
2
-- @description: Boolean Auftragssperre benötigt bei shoporders
3
-- @depends: release_3_4_1 shops
4
-- @ignore: 0
5
ALTER TABLE customer ADD COLUMN order_lock boolean default 0;
sql/Pg-upgrade2/df_shoporder.sql
1
-- @tag: df_shoporder
2
-- @description: Feld Auftragssperre in der shoporder Tabelle
3
-- @depends: release_3_4_0
4

  
5
ALTER TABLE shop_orders ADD COLUMN df_kivi_customer_order_lock boolean DEFAULT FALSE NOT NULL;
sql/Pg-upgrade2/df_shoporder3.sql
1
-- @tag: df_shoporder3
2
-- @description: Feld df_kivi_customer_order_lock in der shoporder Tabelle wieder gelösch da order_lock direkt aus den Kundendaten genommen wird. Tabellen customer und shop_order sind Verknüpft. Spalte obsolete hinzgefügt
3
-- @depends: release_3_4_0
4

  
5
ALTER TABLE shop_orders DROP COLUMN df_kivi_customer_order_lock;
6
ALTER TABLE shop_orders ADD COLUMN obsolete boolean DEFAULT FALSE NOT NULL;
sql/Pg-upgrade2/df_shoporder_2.sql
1
-- @tag: df_shoporder_2
2
-- @description: Feld Positionen in der shoporder Tabelle
3
-- @depends: release_3_4_0
4

  
5
ALTER TABLE shop_orders ADD COLUMN positions integer;
6

  
sql/Pg-upgrade2/shop_orders.sql
1 1
-- @tag: shop_orders
2 2
-- @description: Erstellen der Tabellen shop_orders und shop_order_items
3
-- @depends: release_3_3_0
3
-- @depends: release_3_4_1 shops
4 4

  
5 5
CREATE TABLE shop_orders (
6 6
  id SERIAL PRIMARY KEY,
......
20 20
  shop_id integer,               --welcher shop bei mehreren
21 21
  host TEXT,             --Hostname vom Shop
22 22
  remote_ip text,        --IP Besteller
23
  transferred boolean DEFAULT FALSE,    -- übernommen 
23
  transferred boolean DEFAULT FALSE,    -- übernommen
24 24
  transfer_date date, -- Zeit wann übernommen
25 25
  kivi_customer_id integer,  -- Kundenid von Tbl customer wenn übernommen
26
  oe_transid integer,  -- id to 
26
  oe_transid integer,  -- id to
27 27
-- Bestell-, Rechnungs- und Lieferadresse. !!Manche Shops bieten sowas!!
28 28
-- In der Regel ist aber die Rechnungsadresse die Kundenadresse
29 29
  -- Bestelldaten des Kunden
......
59 59
  billing_phone TEXT,
60 60
  billing_fax TEXT,
61 61
  billing_email TEXT,
62
  
62

  
63 63
  -- SEPA
64 64
  sepa_account_holder TEXT,
65 65
  sepa_iban TEXT,
......
82 82
  delivery_fax TEXT,
83 83
  delivery_email TEXT,
84 84

  
85
  obsolete boolean DEFAULT FALSE NOT NULL,
86
  positions integer,
87

  
85 88
  itime timestamp DEFAULT now(),
86 89
  mtime timestamp
87 90
);
......
92 95
  shop_order_id INTEGER REFERENCES shop_orders (id) ON DELETE CASCADE,
93 96
  description   TEXT,  -- Artikelbezeichnung
94 97
  partnumber    TEXT,
95
  shop_id       INTEGER,  --kann als Sortorder benutzt werden
98
  shop_id       INTEGER,
99
  position      INTEGER,
96 100
  tax_rate      NUMERIC(15,2),
97 101
  quantity      NUMERIC(25,5),   -- qty in invoice and orderitems is real, doi is numeric(25,5)
98 102
  price         NUMERIC(15,5)
sql/Pg-upgrade2/shop_orders_2.sql
1
-- @tag: shop_orders_2
2
-- @description: Hinzufügen der Spalte Position in der Tabelle shop_order_items
3
-- @depends: release_3_3_0
4
ALTER TABLE shop_order_items ADD COLUMN position integer;
sql/Pg-upgrade2/shop_parts.sql
1 1
-- @tag: shop_parts
2 2
-- @description: Add tables for part information for shop
3 3
-- @charset: UTF-8
4
-- @depends: release_3_3_0 shops
4
-- @depends: release_3_4_1 shops
5 5
-- @ignore: 0
6 6

  
7 7
CREATE TABLE shop_parts (
......
16 16
  sortorder        INTEGER,
17 17
  front_page       BOOLEAN NOT NULL DEFAULT false,
18 18
  active           BOOLEAN NOT NULL DEFAULT false,  -- rather than obsolete
19
  shop_category    TEXT,
20
  meta_tags        TEXT,
19
  shop_category TYPE TEXT[] USING array[shop_category;
20
  active_price_source TEXT,
21
  metatag_keywords TEXT,
22
  metatag_keywords TEXT,
23
  metatag_title TEXT,
21 24
  UNIQUE (part_id, shop_id)  -- make sure a shop_part appears only once per shop and part
22 25
);
23 26

  
24 27
CREATE TRIGGER mtime_shop_parts BEFORE UPDATE ON shop_parts
25 28
    FOR EACH ROW EXECUTE PROCEDURE set_mtime();
26

  
27
-- CREATE TABLE shop_meta_tags (
28
-- id integer NOT NULL DEFAULT nextval('shop_parts_id'),
29
 --  description
30
-- );
31

  
32
-- CREATE TABLE shop_categories (
33
-- );
sql/Pg-upgrade2/shop_parts_2.sql
1
-- @tag: shop_parts_2
2
-- @description: Add tables for part information for shop
3
-- @charset: UTF-8
4
-- @depends: release_3_3_0 shops
5
-- @ignore: 0
6
ALTER TABLE shop_parts ALTER COLUMN shop_category TYPE TEXT[] USING array[shop_category];
sql/Pg-upgrade2/shop_parts_4.sql
1
-- @tag: shop_parts_4
2
-- @description: Add tables for part information for shop
3
-- @charset: UTF-8
4
-- @depends: release_3_3_0 shops
5
-- @ignore: 0
6
ALTER TABLE shop_parts ADD COLUMN active_price_source text;
7
ALTER TABLE shop_parts ADD COLUMN metatag_keywords text;
8
ALTER TABLE shop_parts ADD COLUMN metatag_description text;
9
ALTER TABLE shop_parts ADD COLUMN metatag_title text;
10
ALTER TABLE shop_parts DROP COLUMN meta_tags;
sql/Pg-upgrade2/shops.sql
1 1
-- @tag: shops
2 2
-- @description: Tabelle für Shops
3
-- @depends: release_3_3_0
3
-- @depends: release_3_4_1 customer_klass_rename_to_pricegroup_id_and_foreign_key
4 4
-- @ignore: 0
5 5

  
6 6
CREATE TABLE shops (
......
11 11
  connector text,     -- hardcoded options, e.g. xtcommerce, shopware
12 12
  pricetype text,     -- netto/brutto
13 13
  price_source text,  -- sellprice/listprice/lastcost or pricegroup id
14
  taxzone_id INTEGER,
15
  last_order_number INTEGER,
16
  orders_to_fetch INTEGER,
14 17
  url text,
15 18
  port INTEGER,
16 19
  login text,  -- "user" is reserved
sql/Pg-upgrade2/shops2.sql
1
-- @tag: shops2
2
-- @description: Alter table shops more columns for configuration
3
-- @charset: UTF-8
4
-- @depends: release_3_4_0 shops
5
-- @ignore: 0
6

  
7
ALTER TABLE shops ADD COLUMN last_order_number integer;
8
ALTER TABLE shops ADD COLUMN orders_to_fetch integer;
sql/Pg-upgrade2/shops3.sql
1
-- @tag: shops3
2
-- @description: Alter table shops more columns for configuration
3
-- @charset: UTF-8
4
-- @depends: release_3_4_0 shops
5
-- @ignore: 0
6

  
7
ALTER TABLE shops ADD COLUMN taxzone_id integer;
templates/webpages/customer_vendor/tabs/billing.html
8 8
  <table width="100%">
9 9

  
10 10
    <tr height="5"></tr>
11
    <tr>
12
      <th align="right" valign="top" nowrap>[% 'Orderlock' | $T8 %]</th>
13
      <td>
14
        [% L.checkbox_tag('cv.order_lock', checked = SELF.cv.order_lock, for_submit=1) %]
15
      </td>
16
    </tr>
17

  
11 18

  
12 19
    [% IF ( INSTANCE_CONF.get_vertreter ) %]
13 20
      <tr>

Auch abrufbar als: Unified diff