Revision 457bbae4
Von Werner Hahn vor mehr als 8 Jahren hinzugefügt
SL/BackgroundJob/ShopOrderMassTransfer.pm | ||
---|---|---|
36 | 36 |
my $job_obj = $self->{job_obj}; |
37 | 37 |
my $db = $job_obj->db; |
38 | 38 |
|
39 |
$job_obj->set_data(CONVERTING_TO_DELIVERY_ORDER())->save; |
|
40 |
|
|
39 | 41 |
foreach my $shop_order_id (@{ $job_obj->data_as_hash->{shop_order_record_ids} }) { |
40 | 42 |
my $shop_order = SL::DB::ShopOrder->new(id => $shop_order_id)->load; |
41 | 43 |
die "can't find shoporder with id $shop_order_id" unless $shop_order; |
42 |
$::lxdebug->dump(0, 'WH: CREATE:I ', \$shop_order); |
|
43 | 44 |
#TODO Kundenabfrage so ändern, dass es nicht abricht |
44 | 45 |
my $customer = SL::DB::Manager::Customer->find_by(id => $shop_order->{kivi_customer_id}); |
45 | 46 |
die "Can't find customer" unless $customer; |
46 | 47 |
my $employee = SL::DB::Manager::Employee->current; |
47 | 48 |
my $items = SL::DB::Manager::ShopOrderItem->get_all( where => [shop_order_id => $shop_order_id], |
48 | 49 |
sort_by => 'partnumber::int' ); |
49 |
$::lxdebug->dump(0, 'WH: CREATE:I ', \$shop_order); |
|
50 |
$::lxdebug->dump(0, 'WH: CREATE:II ', \$items); |
|
51 |
|
|
52 | 50 |
# check inventory onhand > 0 |
53 | 51 |
my $onhand = 0; |
54 | 52 |
foreach my $item (@$items) { |
55 | 53 |
my $qty = SL::DB::Manager::Part->find_by(partnumber => $item->{partnumber})->onhand; # > 0 ? $onhand = 1 : 0; |
56 | 54 |
$qty >= $item->{quantity} ? $onhand = 1 : 0; |
57 |
$main::lxdebug->message(0, "WH: STOCK: $qty -- $onhand"); |
|
58 | 55 |
last if $onhand == 0; |
59 | 56 |
} |
60 |
$main::lxdebug->message(0, "WH:ONHAND: $onhand "); |
|
61 | 57 |
if ($onhand == 1) { |
62 | 58 |
$shop_order->{shop_order_items} = $items; |
63 |
$main::lxdebug->dump(0, 'WH: TRANSFER SHOPORDER', \$shop_order); |
|
64 | 59 |
|
65 | 60 |
my $order = $shop_order->convert_to_sales_order(customer => $customer, employee => $employee); |
66 | 61 |
$order->save; |
... | ... | |
76 | 71 |
my $delivery_order_items = $delivery_order->{orderitems}; |
77 | 72 |
# Lagerentnahme |
78 | 73 |
# entsprechende defaults holen, falls standardlagerplatz verwendet werden soll |
79 |
$main::lxdebug->dump(0, 'WH: LAGER: ', \$delivery_order_items); |
|
80 | 74 |
my $test = $::instance_conf->get_transfer_default_use_master_default_bin; |
81 |
$main::lxdebug->message(0, "WH: TEST $test "); |
|
82 |
$main::lxdebug->dump(0, 'WH: KONF ',$::instance_conf); |
|
83 |
$main::lxdebug->message(0, "WH:NACH "); |
|
84 | 75 |
require SL::DB::Inventory; |
85 | 76 |
my $rose_db = SL::DB::Inventory->new->db; |
86 | 77 |
my $dbh = $db->dbh; |
... | ... | |
133 | 124 |
} |
134 | 125 |
push @errors, @{ $err }; |
135 | 126 |
} |
136 |
$main::lxdebug->dump(0, 'WH: LAGER II ', \@transfers); |
|
137 |
$main::lxdebug->dump(0, 'WH: LAGER III ', \@errors); |
|
138 | 127 |
if (!@errors) { |
139 | 128 |
$delivery_order->delivered(1); |
140 | 129 |
$delivery_order->save; |
... | ... | |
143 | 132 |
} |
144 | 133 |
} |
145 | 134 |
|
146 |
sub create_delivery_order { |
|
147 |
my ( $self ) = @_; |
|
148 |
} |
|
149 |
|
|
150 | 135 |
sub run { |
151 |
$main::lxdebug->message(0, "WH: RUN"); |
|
152 | 136 |
my ($self, $job_obj) = @_; |
153 |
$::lxdebug->dump(0, 'WH: RUN: ', \$self); |
|
154 | 137 |
|
155 | 138 |
$self->{job_obj} = $job_obj; |
156 | 139 |
$self->create_order; |
SL/Controller/MassInvoiceCreatePrint.pm | ||
---|---|---|
144 | 144 |
SL::System::TaskServer->new->wake_up; |
145 | 145 |
|
146 | 146 |
my $html = $self->render('mass_invoice_create_print_from_do/_create_print_all_status', { output => 0 }, job => $job); |
147 |
|
|
148 | 147 |
$self->js |
149 | 148 |
->html('#create_print_all_dialog', $html) |
150 | 149 |
->run('kivi.MassInvoiceCreatePrint.massConversionStarted') |
SL/Controller/ShopOrder.pm | ||
---|---|---|
11 | 11 |
use SL::DB::Shop; |
12 | 12 |
use SL::Shop; |
13 | 13 |
use SL::Presenter; |
14 |
use SL::Helper::Flash; |
|
14 | 15 |
use SL::Locale::String; |
15 | 16 |
use SL::Controller::Helper::ParseFilter; |
16 | 17 |
use Rose::Object::MakeMethods::Generic |
17 | 18 |
( |
18 |
'scalar --get_set_init' => [ qw(shop_order transferred) ], |
|
19 |
'scalar --get_set_init' => [ qw(shop_order transferred js) ],
|
|
19 | 20 |
); |
21 |
|
|
22 |
__PACKAGE__->run_before('setup'); |
|
23 |
|
|
20 | 24 |
use Data::Dumper; |
21 | 25 |
|
22 | 26 |
sub action_get_orders { |
... | ... | |
32 | 36 |
|
33 | 37 |
sub action_list { |
34 | 38 |
my ( $self ) = @_; |
35 |
$::lxdebug->dump(0, "WH: LIST ", \$::form); |
|
36 | 39 |
my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0 ]); |
37 | 40 |
my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : ''; |
38 |
#$::lxdebug->dump(0, "WH: FILTER ", $::form->{filter}->{_eq_ignore_empty}." - ".$transferred); |
|
39 |
#$::lxdebug->dump(0, "WH: FILTER2 ", \%filter); |
|
40 | 41 |
my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'order_date'; |
41 | 42 |
$sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC'; |
42 | 43 |
my $shop_orders = SL::DB::Manager::ShopOrder->get_all( %filter, sort_by => $sort_by, |
43 | 44 |
with_objects => ['shop_order_items'], |
44 | 45 |
); |
45 |
$::lxdebug->dump(0, "WH: IMPORTS I ", \$shop_orders); |
|
46 | 46 |
foreach my $shop_order ( @$shop_orders ) { |
47 |
# $::lxdebug->dump(0, "WH: IMPORTS II ", $shop_order); |
|
48 | 47 |
my %billing_address = ( 'name' => $shop_order->billing_lastname, |
49 | 48 |
'company' => $shop_order->billing_company, |
50 | 49 |
'street' => $shop_order->billing_street, |
... | ... | |
53 | 52 |
); |
54 | 53 |
my $b_address = $self->check_address(%billing_address); |
55 | 54 |
if ($b_address) { |
56 |
$main::lxdebug->message(0, "WH: SAVE "); |
|
57 | 55 |
$shop_order->{kivi_customer_id} = $b_address->{id}; |
58 | 56 |
$shop_order->save; |
59 | 57 |
} |
60 | 58 |
$shop_order->{kivi_cv_id} = $b_address; |
61 | 59 |
} |
62 |
#$::lxdebug->dump(0, "WH: IMPORTS III ", \$shop_orders); |
|
63 | 60 |
$self->render('shop_order/list', |
64 | 61 |
title => t8('ShopOrders'), |
65 | 62 |
SHOPORDERS => $shop_orders, |
... | ... | |
72 | 69 |
my $id = $::form->{id} || {}; |
73 | 70 |
my $shop_order = SL::DB::Manager::ShopOrder->find_by( id => $id ); |
74 | 71 |
die "can't find shoporder with id $id" unless $shop_order; |
75 |
#$main::lxdebug->dump(0, 'WH:ORDER: ', \$shop_order); |
|
76 | 72 |
# the different importaddresscheck if there complete in the customer table to prevent duplicats inserts |
77 | 73 |
my %customer_address = ( 'name' => $shop_order->customer_lastname, |
78 | 74 |
'company' => $shop_order->customer_company, |
... | ... | |
98 | 94 |
#### |
99 | 95 |
|
100 | 96 |
my $lastname = $shop_order->customer_lastname; |
97 |
$main::lxdebug->message(0, "WH: HIER"); |
|
101 | 98 |
my $proposals = SL::DB::Manager::Customer->get_all( |
102 | 99 |
where => [ |
103 | 100 |
or => [ |
... | ... | |
157 | 154 |
shop_order_record_ids => [ @shop_orders ], |
158 | 155 |
num_order_created => 0, |
159 | 156 |
num_delivery_order_created => 0, |
157 |
status => SL::BackgroundJob::ShopOrderMassTransfer->WAITING_FOR_EXECUTION(), |
|
160 | 158 |
conversation_errors => [ ], |
161 | 159 |
)->update_next_run_at; |
162 | 160 |
|
163 | 161 |
SL::System::TaskServer->new->wake_up; |
164 |
$main::lxdebug->message(0, "WH: ACTION"); |
|
162 |
|
|
163 |
my $html = $self->render('shop_order/_transfer_status', { output => 0 }, job => $job); |
|
164 |
|
|
165 |
$main::lxdebug->dump(0, 'WH: iHTML: ',\$html); |
|
166 |
$self->js |
|
167 |
->html('#status_mass_transfer', $html) |
|
168 |
->run('kivi.ShopOrder.massTransferStarted') |
|
169 |
->render; |
|
165 | 170 |
} |
166 | 171 |
|
172 |
sub action_transfer_status { |
|
173 |
my ($self) = @_; |
|
174 |
$main::lxdebug->dump(0, 'WH: STATUS1 ',\$self); |
|
175 |
$main::lxdebug->dump(0, 'WH: STATUS2 ',\$::form); |
|
176 |
my $job = SL::DB::BackgroundJob->new(id => $::form->{job_id})->load; |
|
177 |
my $html = $self->render('shop_order/_transfer_status', { output => 0 }, job => $job); |
|
178 |
|
|
179 |
$self->js->html('#status_mass_transfer', $html); |
|
180 |
$self->js->run('kivi.ShopOrder.massTransferFinished') if $job->data_as_hash->{status} == SL::BackgroundJob::ShopOrderMassTransfer->DONE(); |
|
181 |
$self->js->render; |
|
182 |
|
|
183 |
} |
|
167 | 184 |
sub action_apply_customer { |
168 | 185 |
my ( $self ) = @_; |
169 |
$::lxdebug->dump(0, "WH: CUSTOMER ", \$::form); |
|
170 | 186 |
my $what = $::form->{create_customer}; # billing, customer or delivery |
171 |
$::lxdebug->dump(0, "WH: WHAT ",$what); |
|
172 | 187 |
my %address = ( 'name' => $::form->{$what.'_name'}, |
173 | 188 |
'street' => $::form->{$what.'_street'}, |
174 | 189 |
'zipcode' => $::form->{$what.'_zipcode'}, |
... | ... | |
180 | 195 |
'currency' => 1, # hardcoded |
181 | 196 |
); |
182 | 197 |
$address{contact} = ($address{name} ne $::form->{$what.'_firstname'} . " " . $::form->{$what.'_lastname'} ? $::form->{$what.'_firstname'} . " " . $::form->{$what.'_lastname'} : ''); |
183 |
$::lxdebug->dump(0, "WH: ADDRESS ",\%address); |
|
184 | 198 |
my $customer = SL::DB::Customer->new(%address); |
185 | 199 |
$customer->save; |
186 | 200 |
if($::form->{$what.'_country'} ne "Deutschland") { # hardcoded |
... | ... | |
189 | 203 |
$self->redirect_to(action => 'show', id => $::form->{import_id}); |
190 | 204 |
} |
191 | 205 |
} |
206 |
|
|
207 |
sub setup { |
|
208 |
my ($self) = @_; |
|
209 |
$::auth->assert('invoice_edit'); |
|
210 |
|
|
211 |
$::request->layout->use_javascript("${_}.js") for qw(kivi.ShopOrder); |
|
212 |
} |
|
213 |
|
|
192 | 214 |
# |
193 | 215 |
# Helper |
194 | 216 |
# |
... | ... | |
201 | 223 |
'zipcode'=> { like => $address{'zipcode'} }, |
202 | 224 |
'city' => { like => $address{'city'} }, |
203 | 225 |
]); |
204 |
$::lxdebug->dump(0, "WH: CUSTOMER ", \$addressdata); |
|
205 | 226 |
return @{$addressdata}[0]; |
206 | 227 |
} |
207 | 228 |
|
SL/DB/ShopOrder.pm | ||
---|---|---|
36 | 36 |
foreach my $items (@{$self->shop_order_items}) { |
37 | 37 |
my $item = SL::DB::OrderItem->new; |
38 | 38 |
my $part = SL::DB::Manager::Part->find_by( partnumber => $items->{partnumber} ); |
39 |
die "can't find PART with partnumber $items->{partnumber}" unless $part; |
|
39 | 40 |
$main::lxdebug->dump(0, 'WH: SO PART',\$part); |
40 | 41 |
$item->assign_attributes( |
41 | 42 |
parts_id => $part->id, |
SL/ShopConnector/Shopware.pm | ||
---|---|---|
20 | 20 |
my ($self, $id) = @_; |
21 | 21 |
|
22 | 22 |
my $url = $self->url; |
23 |
my $ordnumber = 61141;
|
|
23 |
my $ordnumber = 63641;
|
|
24 | 24 |
# Muss noch angepasst werden |
25 |
for(my $i=1;$i<=50;$i++) { |
|
25 |
for(my $i=1;$i<=350;$i++) {
|
|
26 | 26 |
my $data = $self->connector->get("http://$url/api/orders/$ordnumber?useNumberAsId=true"); |
27 | 27 |
$ordnumber++; |
28 | 28 |
$::lxdebug->dump(0, "WH: DATA ", \$data); |
... | ... | |
41 | 41 |
billing_greeting => ($import->{data}->{billing}->{salutation} eq 'mr' ? 'Herr' : 'Frau'), |
42 | 42 |
billing_lastname => $import->{data}->{billing}->{lastName}, |
43 | 43 |
billing_phone => $import->{data}->{billing}->{phone}, |
44 |
billing_street => $import->{data}->{billing}->{street} . " " . $import->{data}->{billing}->{streetNumber}, |
|
44 |
billing_street => $import->{data}->{billing}->{street}, # . " " . $import->{data}->{billing}->{streetNumber},
|
|
45 | 45 |
billing_vat => $import->{data}->{billing}->{vatId}, |
46 | 46 |
billing_zipcode => $import->{data}->{billing}->{zipCode}, |
47 | 47 |
customer_city => $import->{data}->{billing}->{city}, |
... | ... | |
54 | 54 |
customer_greeting => ($import->{data}->{billing}->{salutation} eq 'mr' ? 'Herr' : 'Frau'), |
55 | 55 |
customer_lastname => $import->{data}->{billing}->{lastName}, |
56 | 56 |
customer_phone => $import->{data}->{billing}->{phone}, |
57 |
customer_street => $import->{data}->{billing}->{street} . " " . $import->{data}->{billing}->{streetNumber}, |
|
57 |
customer_street => $import->{data}->{billing}->{street}, # . " " . $import->{data}->{billing}->{streetNumber},
|
|
58 | 58 |
customer_vat => $import->{data}->{billing}->{vatId}, |
59 | 59 |
customer_zipcode => $import->{data}->{billing}->{zipCode}, |
60 | 60 |
customer_newsletter => $import->{data}->{customer}->{newsletter}, |
... | ... | |
68 | 68 |
delivery_greeting => ($import->{data}->{shipping}->{salutation} eq 'mr' ? 'Herr' : 'Frau'), |
69 | 69 |
delivery_lastname => $import->{data}->{shipping}->{lastName}, |
70 | 70 |
delivery_phone => $import->{data}->{shipping}->{phone}, |
71 |
delivery_street => $import->{data}->{shipping}->{street} . " " . $import->{data}->{shipping}->{streetNumber}, |
|
71 |
delivery_street => $import->{data}->{shipping}->{street}, # . " " . $import->{data}->{shipping}->{streetNumber},
|
|
72 | 72 |
delivery_vat => $import->{data}->{shipping}->{vatId}, |
73 | 73 |
delivery_zipcode => $import->{data}->{shipping}->{zipCode}, |
74 | 74 |
host => $import->{data}->{shop}->{hosts}, |
... | ... | |
155 | 155 |
|
156 | 156 |
sub init_connector { |
157 | 157 |
my ($self) = @_; |
158 |
$main::lxdebug->dump(0, 'WH: CONNECTOR: ',\$self); |
|
158 | 159 |
my $ua = LWP::UserAgent->new; |
159 | 160 |
$ua->credentials( |
160 | 161 |
$self->url, |
161 |
"Shopware4 REST-API",
|
|
162 |
"Shopware REST-API", |
|
162 | 163 |
$self->config->login => $self->config->password |
163 | 164 |
); |
165 |
$main::lxdebug->dump(0, 'WH: UA: ',\$ua); |
|
164 | 166 |
return $ua; |
165 | 167 |
}; |
166 | 168 |
|
js/kivi.MassInvoiceCreatePrint.js | ||
---|---|---|
75 | 75 |
$('#action_print').click(kivi.MassInvoiceCreatePrint.checkInvoiceSelection); |
76 | 76 |
}; |
77 | 77 |
}); |
78 |
|
|
79 | 78 |
$(kivi.MassInvoiceCreatePrint.setup); |
templates/webpages/shop_order/list.html | ||
---|---|---|
4 | 4 |
<h1>[% title %]</h1> |
5 | 5 |
[%- PROCESS 'shop_order/_filter.html' filter=SELF.models.filtered.laundered %] |
6 | 6 |
<hr> |
7 |
<form method="post" action="controller.pl"> |
|
7 |
<form method="post" action="controller.pl" name="shop_orders" id="shoporders">
|
|
8 | 8 |
<table id="shoplist"> |
9 | 9 |
<thead> |
10 | 10 |
<tr class="listheading"> |
... | ... | |
157 | 157 |
<td>[% IF shop_order.transferred == 1 %]<a href="controller.pl?id=[% shop_order.id %]&action=ShopOrder/show">[% 'Show order' | $T8 %]<br>[% shop_order.transferred_date_as_date %]</a> |
158 | 158 |
[% ELSE %] |
159 | 159 |
[% IF transferable == 1 %] |
160 |
[% L.checkbox_tag('id[]', checked = transferable, value=shop_order.id) %]<br>
|
|
160 |
[% L.checkbox_tag('id[]', checked = '', value=shop_order.id) %]<br>
|
|
161 | 161 |
[% END %] |
162 | 162 |
<a href="controller.pl?id=[% shop_order.id %]&action=ShopOrder/show">[% 'Create order' | $T8 %][% END %]</a></td> |
163 | 163 |
</tr> |
... | ... | |
165 | 165 |
</table> |
166 | 166 |
<hr> |
167 | 167 |
<p> |
168 |
[% L.hidden_tag("action", "ShopOrder/mass_transfer") %] |
|
169 |
[% L.submit_tag("", LxERP.t8("Transfer all marked")) %] |
|
168 |
<!-- [% L.hidden_tag("action", "ShopOrder/mass_transfer") %] |
|
169 |
[% L.submit_tag("mass_transfer", LxERP.t8("Transfer all marked")) %] --> |
|
170 |
[% L.button_tag("kivi.ShopOrder.setup();", LxERP.t8("Transfer all marked"), id="mass_transfer") %] |
|
170 | 171 |
</p> |
172 |
<div id="status_mass_transfer" style="display: none;"> |
|
173 |
[%- INCLUDE 'shop_order/_transfer_status.html' %] |
|
174 |
</div> |
|
171 | 175 |
</form> |
Auch abrufbar als: Unified diff
Shopmasstransfer: geht soweit muss noch Fehlermeldungen hübschen
Conflicts:
SL/Controller/ShopOrder.pm