Revision 6ff3e807
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/BackgroundJob/CloseProjectsBelongingToClosedSalesOrders.pm | ||
---|---|---|
24 | 24 |
SELECT oe.globalproject_id |
25 | 25 |
FROM oe |
26 | 26 |
WHERE (oe.globalproject_id IS NOT NULL) |
27 |
AND (oe.customer_id IS NOT NULL) |
|
28 |
AND NOT COALESCE(oe.quotation, FALSE) |
|
27 |
AND oe.record_type = 'sales_order' |
|
29 | 28 |
AND COALESCE(oe.closed, FALSE) |
30 | 29 |
) |
31 | 30 |
EOSQL |
SL/BackgroundJob/ConvertTimeRecordings.pm | ||
---|---|---|
287 | 287 |
} |
288 | 288 |
|
289 | 289 |
$orders = SL::DB::Manager::Order->get_all(where => [customer_id => $tr->customer_id, |
290 |
or => [quotation => undef, quotation => 0],
|
|
290 |
record_type => 'sales_order',
|
|
291 | 291 |
globalproject_id => $project_id, ], |
292 | 292 |
with_objects => ['orderitems']); |
293 | 293 |
|
SL/CT.pm | ||
---|---|---|
341 | 341 |
qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | . |
342 | 342 |
qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | . |
343 | 343 |
$pg_join . |
344 |
qq|WHERE $where AND (o.quotation = '0')|;
|
|
344 |
qq|WHERE $where AND ((o.record_type = 'sales_order') OR (o.record_type = 'purcharse_order'))|;
|
|
345 | 345 |
} |
346 | 346 |
|
347 | 347 |
if ( $form->{l_quonumber} ) { |
... | ... | |
360 | 360 |
qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | . |
361 | 361 |
qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | . |
362 | 362 |
$pg_join . |
363 |
qq|WHERE $where AND (o.quotation = '1')|;
|
|
363 |
qq|WHERE $where AND ((o.record_type = 'sales_quotation') OR (o.record_type = 'request_quotation'))|;
|
|
364 | 364 |
} |
365 | 365 |
} |
366 | 366 |
|
SL/Controller/CustomerVendorTurnover.pm | ||
---|---|---|
8 | 8 |
use SL::DB::AccTransaction; |
9 | 9 |
use SL::DB::Invoice; |
10 | 10 |
use SL::DB::Order; |
11 |
use SL::DB::Order::TypeData qw(:types); |
|
11 | 12 |
use SL::DB::EmailJournal; |
12 | 13 |
use SL::DB::Letter; |
13 | 14 |
use SL::DB; |
... | ... | |
282 | 283 |
$orders = SL::DB::Manager::Order->get_all( |
283 | 284 |
query => [ |
284 | 285 |
customer_id => $cv, |
285 |
quotation => ($type eq 'quotation' ? 'T' : 'F')
|
|
286 |
record_type => ($type eq 'quotation' ? SALES_QUOTATION_TYPE() : SALES_ORDER_TYPE())
|
|
286 | 287 |
], |
287 | 288 |
sort_by => 'transdate DESC', |
288 | 289 |
); |
... | ... | |
290 | 291 |
$orders = SL::DB::Manager::Order->get_all( |
291 | 292 |
query => [ |
292 | 293 |
vendor_id => $cv, |
293 |
quotation => ($type eq 'quotation' ? 'T' : 'F')
|
|
294 |
record_type => ($type eq 'quotation' ? REQUEST_QUOTATION_TYPE() : PURCHASE_ORDER_TYPE())
|
|
294 | 295 |
], |
295 | 296 |
sort_by => 'transdate DESC', |
296 | 297 |
); |
... | ... | |
346 | 347 |
$query = <<SQL; |
347 | 348 |
WITH |
348 | 349 |
oe_emails_customer |
349 |
AS (SELECT rc.to_id, rc.from_id, oe.quotation, oe.quonumber, oe.ordnumber, c.id
|
|
350 |
AS (SELECT rc.to_id, rc.from_id, oe.record_type, oe.quonumber, oe.ordnumber, c.id
|
|
350 | 351 |
FROM record_links rc |
351 | 352 |
LEFT JOIN oe oe ON rc.from_id = oe.id |
352 | 353 |
LEFT JOIN customer c ON oe.customer_id = c.id |
... | ... | |
379 | 380 |
|
380 | 381 |
SELECT ej.*, |
381 | 382 |
CASE |
382 |
oec.quotation WHEN 'F' THEN 'Sales Order'
|
|
383 |
ELSE 'Quotation' |
|
383 |
oec.record_type WHEN 'sales_order' THEN 'Sales Order'
|
|
384 |
ELSE 'Quotation'
|
|
384 | 385 |
END AS type, |
385 | 386 |
CASE |
386 |
oec.quotation WHEN 'F' THEN oec.ordnumber
|
|
387 |
ELSE oec.quonumber |
|
387 |
oec.record_type WHEN 'sales_order' THEN oec.ordnumber
|
|
388 |
ELSE oec.quonumber
|
|
388 | 389 |
END AS recordnumber, |
389 | 390 |
oec.id AS record_id |
390 | 391 |
FROM email_journal ej |
... | ... | |
425 | 426 |
$query = <<SQL; |
426 | 427 |
WITH |
427 | 428 |
oe_emails_vendor |
428 |
AS (SELECT rc.to_id, rc.from_id, oe.quotation, oe.quonumber, oe.ordnumber, c.id
|
|
429 |
AS (SELECT rc.to_id, rc.from_id, oe.record_type, oe.quonumber, oe.ordnumber, c.id
|
|
429 | 430 |
FROM record_links rc |
430 | 431 |
LEFT JOIN oe oe ON rc.from_id = oe.id |
431 | 432 |
LEFT JOIN vendor c ON oe.vendor_id = c.id |
... | ... | |
458 | 459 |
|
459 | 460 |
SELECT ej.*, |
460 | 461 |
CASE |
461 |
oec.quotation WHEN 'F' THEN 'Purchase Order'
|
|
462 |
ELSE 'Request quotation' |
|
462 |
oec.record_type WHEN 'purchase_order' THEN 'Purchase Order'
|
|
463 |
ELSE 'Request quotation'
|
|
463 | 464 |
END AS type, |
464 | 465 |
CASE |
465 |
oec.quotation WHEN 'F' THEN oec.ordnumber
|
|
466 |
ELSE oec.quonumber |
|
466 |
oec.record_type WHEN 'purchase_order' THEN oec.ordnumber
|
|
467 |
ELSE oec.quonumber
|
|
467 | 468 |
END AS recordnumber, |
468 | 469 |
oec.id AS record_id |
469 | 470 |
FROM email_journal ej |
SL/Controller/DeliveryPlan.pm | ||
---|---|---|
160 | 160 |
|
161 | 161 |
sub delivery_plan_query_linked_items { |
162 | 162 |
my ($self) = @_; |
163 |
my $vc = $self->vc;
|
|
163 |
my $record_type = ($self->vc eq 'customer' ? SALES_ORDER_TYPE() : PURCHASE_ORDER_TYPE());
|
|
164 | 164 |
my $employee_id = SL::DB::Manager::Employee->current->id; |
165 | 165 |
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND"; |
166 | 166 |
|
167 | 167 |
[ |
168 |
"order.${vc}_id" => { gt => 0 },
|
|
168 |
record_type => $record_type,
|
|
169 | 169 |
'order.closed' => 0, |
170 |
or => [ 'order.quotation' => 0, 'order.quotation' => undef ], |
|
171 | 170 |
|
172 | 171 |
# filter by shipped_qty < qty, read from innermost to outermost |
173 | 172 |
'id' => [ \" |
... | ... | |
176 | 175 |
FROM orderitems oi, oe, record_links rl, delivery_order_items doi |
177 | 176 |
WHERE |
178 | 177 |
oe.id = oi.trans_id AND |
179 |
oe.${vc}_id IS NOT NULL AND |
|
180 |
(oe.quotation = 'f' OR oe.quotation IS NULL) AND |
|
178 |
oe.record_type = '$record_type' AND |
|
181 | 179 |
NOT oe.closed AND |
182 | 180 |
$oe_owner |
183 | 181 |
doi.id = rl.to_id AND |
... | ... | |
195 | 193 |
SELECT oi.id FROM orderitems oi, oe |
196 | 194 |
WHERE |
197 | 195 |
oe.id = oi.trans_id AND |
198 |
oe.${vc}_id IS NOT NULL AND |
|
199 |
(oe.quotation = 'f' OR oe.quotation IS NULL) AND |
|
196 |
oe.record_type = '$record_type' AND |
|
200 | 197 |
NOT oe.closed AND |
201 | 198 |
$oe_owner |
202 | 199 |
NOT EXISTS ( |
SL/Controller/Order.pm | ||
---|---|---|
1439 | 1439 |
|
1440 | 1440 |
my $sales_quotations = SL::DB::Manager::Order->get_all(where => [id => $::form->{ids}, |
1441 | 1441 |
or => [closed => 0, closed => undef], |
1442 |
quotation => 1, |
|
1443 |
'!customer_id' => undef]); |
|
1442 |
record_type => SALES_QUOTATION_TYPE()]); |
|
1444 | 1443 |
|
1445 | 1444 |
my $request_quotations = SL::DB::Manager::Order->get_all(where => [id => $::form->{ids}, |
1446 | 1445 |
or => [closed => 0, closed => undef], |
1447 |
quotation => 1, |
|
1448 |
'!vendor_id' => undef]); |
|
1446 |
record_type => REQUEST_QUOTATION_TYPE()]); |
|
1449 | 1447 |
|
1450 | 1448 |
$::auth->assert('sales_quotation_edit') if scalar @$sales_quotations; |
1451 | 1449 |
$::auth->assert('request_quotation_edit') if scalar @$request_quotations; |
... | ... | |
1861 | 1859 |
$order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id}; |
1862 | 1860 |
$order ||= SL::DB::Order->new(orderitems => [], |
1863 | 1861 |
record_type => $self->type, |
1864 |
quotation => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE())), |
|
1865 | 1862 |
currency_id => $::instance_conf->get_currency_id(),); |
1866 | 1863 |
|
1867 | 1864 |
my $cv_id_method = $self->cv . '_id'; |
... | ... | |
2114 | 2111 |
} |
2115 | 2112 |
|
2116 | 2113 |
my $objects_to_close = scalar @converted_from_oe_ids |
2117 |
? SL::DB::Manager::Order->get_all(where => [id => \@converted_from_oe_ids, quotation => 1]) |
|
2114 |
? SL::DB::Manager::Order->get_all(where => [ |
|
2115 |
id => \@converted_from_oe_ids, |
|
2116 |
or => [ record_type => SALES_QUOTATION_TYPE(), |
|
2117 |
record_type => REQUEST_QUOTATION_TYPE()] |
|
2118 |
]) |
|
2118 | 2119 |
: undef; |
2119 | 2120 |
|
2120 | 2121 |
my $items_to_delete = scalar @{ $self->item_ids_to_delete || [] } |
SL/Controller/RequirementSpecOrder.pm | ||
---|---|---|
94 | 94 |
my $order = $self->rs_order->order; |
95 | 95 |
my $sections = $self->requirement_spec->sections_sorted; |
96 | 96 |
|
97 |
if (!$::auth->assert($order->quotation ? 'sales_quotation_edit' : 'sales_order_edit', 1)) {
|
|
97 |
if (!$::auth->assert($order->type_data->rights('edit'), 1)) {
|
|
98 | 98 |
return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render; |
99 | 99 |
} |
100 | 100 |
|
... | ... | |
375 | 375 |
globalproject_id => $self->requirement_spec->project_id, |
376 | 376 |
transdate => DateTime->today_local, |
377 | 377 |
reqdate => $reqdate, |
378 |
quotation => !!$::form->{quotation}, |
|
379 | 378 |
orderitems => [ @orderitems, @add_items ], |
380 | 379 |
customer_id => $customer->id, |
381 | 380 |
taxincluded => $customer->taxincluded, |
SL/Controller/TimeRecording.pm | ||
---|---|---|
274 | 274 |
|
275 | 275 |
sub init_all_orders { |
276 | 276 |
my $orders = SL::DB::Manager::Order->get_all(query => [or => [ closed => 0, closed => undef, id => $_[0]->time_recording->order_id ], |
277 |
or => [ quotation => 0, quotation => undef ],
|
|
278 |
'!customer_id' => undef]);
|
|
277 |
record_type => 'sales_order',
|
|
278 |
]); |
|
279 | 279 |
return [ map { [$_->id, sprintf("%s %s", $_->number, $_->customervendor->name) ] } sort { $a->number <=> $b->number } @{$orders||[]} ]; |
280 | 280 |
} |
281 | 281 |
|
SL/DB/Helper/LinkedRecords.pm | ||
---|---|---|
306 | 306 |
$sort_dir = $sort_dir * 1 ? 1 : -1; |
307 | 307 |
|
308 | 308 |
my %numbers = ( 'SL::DB::SalesProcess' => sub { $_[0]->id }, |
309 |
'SL::DB::Order' => sub { $_[0]->quotation ? $_[0]->quonumber : $_[0]->ordnumber },
|
|
309 |
'SL::DB::Order' => sub { $_[0]->record_number },
|
|
310 | 310 |
'SL::DB::DeliveryOrder' => sub { $_[0]->donumber }, |
311 | 311 |
'SL::DB::Invoice' => sub { $_[0]->invnumber }, |
312 | 312 |
'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber }, |
SL/DB/Manager/Part.pm | ||
---|---|---|
78 | 78 |
FROM orderitems oi |
79 | 79 |
LEFT JOIN oe ON (oi.trans_id = oe.id) |
80 | 80 |
WHERE (oi.parts_id IN ($placeholders)) |
81 |
AND (NOT COALESCE(oe.quotation, FALSE))
|
|
81 |
AND oe.record_type = 'purchase_order'
|
|
82 | 82 |
AND (NOT COALESCE(oe.closed, FALSE)) |
83 | 83 |
AND (NOT COALESCE(oe.delivered, FALSE)) |
84 |
AND (COALESCE(oe.vendor_id, 0) <> 0) |
|
85 | 84 |
GROUP BY oi.parts_id |
86 | 85 |
SQL |
87 | 86 |
|
SL/DB/VC.pm | ||
---|---|---|
32 | 32 |
AND e.transdate = o.transdate) |
33 | 33 |
FROM oe o |
34 | 34 |
WHERE (o.${type}_id = ?) |
35 |
AND NOT COALESCE(o.quotation, FALSE)
|
|
35 |
AND ((o.record_type = 'sales_order') OR (o.record_type = 'purchase_order'))
|
|
36 | 36 |
AND NOT COALESCE(o.closed, FALSE) |
37 | 37 |
SQL |
38 | 38 |
|
SL/DO.pm | ||
---|---|---|
273 | 273 |
|
274 | 274 |
$form->{DO} = selectall_hashref_query($form, $dbh, $query, @values); |
275 | 275 |
|
276 |
my $record_type = $vc eq 'customer' ? 'sales_order' : 'purchase_order'; |
|
276 | 277 |
if (scalar @{ $form->{DO} }) { |
277 | 278 |
$query = |
278 | 279 |
qq|SELECT id |
279 | 280 |
FROM oe |
280 |
WHERE NOT COALESCE(quotation, FALSE) |
|
281 |
AND (ordnumber = ?) |
|
282 |
AND (COALESCE(${vc}_id, 0) != 0)|; |
|
281 |
WHERE (record_type = '$record_type' |
|
282 |
AND (ordnumber = ?)|; |
|
283 | 283 |
|
284 | 284 |
my $sth = prepare_query($form, $dbh, $query); |
285 | 285 |
|
SL/Dev/Record.pm | ||
---|---|---|
743 | 743 |
sub _create_sales_order_or_quotation { |
744 | 744 |
my (%params) = @_; |
745 | 745 |
|
746 |
my $record_type = $params{type}; |
|
746 |
my $record_type = delete $params{type};
|
|
747 | 747 |
die "illegal type" unless $record_type eq SALES_ORDER_TYPE() or $record_type eq SALES_QUOTATION_TYPE(); |
748 | 748 |
|
749 | 749 |
my $orderitems = delete $params{orderitems} // _create_two_items($record_type); |
... | ... | |
755 | 755 |
die "illegal customer" unless ref($customer) eq 'SL::DB::Customer'; |
756 | 756 |
|
757 | 757 |
my $record = SL::DB::Order->new( |
758 |
record_type => delete $params{type},
|
|
758 |
record_type => $record_type,
|
|
759 | 759 |
customer_id => delete $params{customer_id} // $customer->id, |
760 | 760 |
taxzone_id => delete $params{taxzone_id} // $customer->taxzone->id, |
761 | 761 |
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id, |
... | ... | |
763 | 763 |
employee_id => delete $params{employee_id} // SL::DB::Manager::Employee->current->id, |
764 | 764 |
salesman_id => delete $params{employee_id} // SL::DB::Manager::Employee->current->id, |
765 | 765 |
transdate => delete $params{transdate} // DateTime->today, |
766 |
quotation => $record_type eq 'sales_quotation' ? 1 : 0, |
|
767 | 766 |
orderitems => $orderitems, |
768 | 767 |
); |
769 | 768 |
$record->assign_attributes(%params) if %params; |
... | ... | |
777 | 776 |
sub _create_purchase_order_or_quotation { |
778 | 777 |
my (%params) = @_; |
779 | 778 |
|
780 |
my $record_type = $params{type}; |
|
779 |
my $record_type = delete $params{type};
|
|
781 | 780 |
die "illegal type" unless $record_type eq PURCHASE_ORDER_TYPE() or $record_type eq REQUEST_QUOTATION_TYPE(); |
782 | 781 |
my $orderitems = delete $params{orderitems} // _create_two_items($record_type); |
783 | 782 |
_check_items($orderitems, $record_type); |
... | ... | |
788 | 787 |
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor'; |
789 | 788 |
|
790 | 789 |
my $record = SL::DB::Order->new( |
791 |
record_type => delete $params{type},
|
|
790 |
record_type => $record_type,
|
|
792 | 791 |
vendor_id => delete $params{vendor_id} // $vendor->id, |
793 | 792 |
taxzone_id => delete $params{taxzone_id} // $vendor->taxzone->id, |
794 | 793 |
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id, |
795 | 794 |
taxincluded => delete $params{taxincluded} // 0, |
796 | 795 |
transdate => delete $params{transdate} // DateTime->today, |
797 | 796 |
'closed' => undef, |
798 |
quotation => $record_type eq REQUEST_QUOTATION_TYPE() ? 1 : 0, |
|
799 | 797 |
orderitems => $orderitems, |
800 | 798 |
); |
801 | 799 |
$record->assign_attributes(%params) if %params; |
SL/IC.pm | ||
---|---|---|
216 | 216 |
) AS ioi ON ioi.parts_id = p.id|, |
217 | 217 |
apoe => |
218 | 218 |
q|LEFT JOIN ( |
219 |
SELECT id, transdate, 'ir' AS module, ordnumber, quonumber, invnumber, FALSE AS quotation, NULL AS customer_id, vendor_id, NULL AS deliverydate, globalproject_id, 'invoice' AS ioi FROM ap UNION
|
|
220 |
SELECT id, transdate, 'is' AS module, ordnumber, quonumber, invnumber, FALSE AS quotation, customer_id, NULL AS vendor_id, deliverydate, globalproject_id, 'invoice' AS ioi FROM ar UNION
|
|
221 |
SELECT id, transdate, 'oe' AS module, ordnumber, quonumber, NULL AS invnumber, quotation, customer_id, vendor_id, reqdate AS deliverydate, globalproject_id, 'orderitems' AS ioi FROM oe
|
|
219 |
SELECT id, transdate, 'ir' AS module, ordnumber, quonumber, invnumber, 'purchase_invoice' AS record_type, NULL AS customer_id, vendor_id, NULL AS deliverydate, globalproject_id, 'invoice' AS ioi FROM ap UNION
|
|
220 |
SELECT id, transdate, 'is' AS module, ordnumber, quonumber, invnumber, 'sales_invoice' AS record_type, customer_id, NULL AS vendor_id, deliverydate, globalproject_id, 'invoice' AS ioi FROM ar UNION
|
|
221 |
SELECT id, transdate, 'oe' AS module, ordnumber, quonumber, NULL AS invnumber, record_type, customer_id, vendor_id, reqdate AS deliverydate, globalproject_id, 'orderitems' AS ioi FROM oe
|
|
222 | 222 |
) AS apoe ON ((ioi.trans_id = apoe.id) AND (ioi.ioi = apoe.ioi))|, |
223 | 223 |
cv => |
224 | 224 |
q|LEFT JOIN ( |
... | ... | |
244 | 244 |
description => 'p.', |
245 | 245 |
qty => 'ioi.', |
246 | 246 |
serialnumber => 'ioi.', |
247 |
quotation => 'apoe.',
|
|
247 |
record_type => 'apoe.',
|
|
248 | 248 |
cv => 'cv.', |
249 | 249 |
"ioi.id" => ' ', |
250 | 250 |
"ioi.ioi" => ' ', |
... | ... | |
441 | 441 |
my $bsooqr = any { $form->{$_} } @oe_flags; |
442 | 442 |
my @bsooqr_tokens = (); |
443 | 443 |
|
444 |
push @select_tokens, @qsooqr_flags, 'quotation', 'cv', 'ioi.id', 'ioi.ioi' if $bsooqr;
|
|
444 |
push @select_tokens, @qsooqr_flags, 'record_type', 'cv', 'ioi.id', 'ioi.ioi' if $bsooqr;
|
|
445 | 445 |
push @select_tokens, @deliverydate_flags if $bsooqr && $form->{l_deliverydate}; |
446 | 446 |
push @select_tokens, $q_assembly_lastcost if $form->{l_assembly} && $form->{l_lastcost}; |
447 | 447 |
push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem| if $form->{bought}; |
448 | 448 |
push @bsooqr_tokens, q|module = 'is' AND NOT ioi.assemblyitem| if $form->{sold}; |
449 |
push @bsooqr_tokens, q|module = 'oe' AND NOT quotation AND cv = 'customer'| if $form->{ordered};
|
|
450 |
push @bsooqr_tokens, q|module = 'oe' AND NOT quotation AND cv = 'vendor'| if $form->{onorder};
|
|
451 |
push @bsooqr_tokens, q|module = 'oe' AND quotation AND cv = 'customer'| if $form->{quoted};
|
|
452 |
push @bsooqr_tokens, q|module = 'oe' AND quotation AND cv = 'vendor'| if $form->{rfq};
|
|
449 |
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'sales_order'| if $form->{ordered};
|
|
450 |
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'purchase_order'| if $form->{onorder};
|
|
451 |
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'sales_quotation'| if $form->{quoted};
|
|
452 |
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'request_quotation'| if $form->{rfq};
|
|
453 | 453 |
push @where_tokens, join ' OR ', map { "($_)" } @bsooqr_tokens if $bsooqr; |
454 | 454 |
|
455 | 455 |
$joins_needed{partsgroup} = 1; |
SL/IR.pm | ||
---|---|---|
1245 | 1245 |
WHERE (e.currency_id = o.currency_id) |
1246 | 1246 |
AND (e.transdate = o.transdate)) AS exch |
1247 | 1247 |
FROM oe o |
1248 |
WHERE (o.vendor_id = ?) AND (o.quotation = '0') AND (o.closed = '0')|;
|
|
1248 |
WHERE (o.vendor_id = ?) AND (o.record_type = 'purchase_order') AND (o.closed = '0')|;
|
|
1249 | 1249 |
my $sth = prepare_execute_query($form, $dbh, $query, $vid); |
1250 | 1250 |
while (my ($amount, $exch) = $sth->fetchrow_array()) { |
1251 | 1251 |
$exch = 1 unless $exch; |
SL/IS.pm | ||
---|---|---|
2572 | 2572 |
AND e.transdate = o.transdate) |
2573 | 2573 |
FROM oe o |
2574 | 2574 |
WHERE o.customer_id = ? |
2575 |
AND o.quotation = '0'
|
|
2575 |
AND o.record_type = 'sales_order'
|
|
2576 | 2576 |
AND o.closed = '0'|; |
2577 | 2577 |
my $sth = prepare_execute_query($form, $dbh, $query, $cid); |
2578 | 2578 |
|
SL/LiquidityProjection.pm | ||
---|---|---|
200 | 200 |
LEFT JOIN buchungsgruppen bg ON (p.buchungsgruppen_id = bg.id) |
201 | 201 |
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) |
202 | 202 |
LEFT JOIN employee e ON (COALESCE(oe.salesman_id, oe.employee_id) = e.id) |
203 |
WHERE (oe.customer_id IS NOT NULL) |
|
204 |
AND NOT COALESCE(oe.quotation, FALSE) |
|
203 |
WHERE oe.record_type = 'sales_order' |
|
205 | 204 |
AND NOT COALESCE(oe.closed, FALSE) |
206 | 205 |
AND (oe.id NOT IN (SELECT oe_id FROM periodic_invoices_configs WHERE periodicity <> 'o')) |
207 | 206 |
SQL |
... | ... | |
357 | 356 |
} |
358 | 357 |
|
359 | 358 |
my @where = ( |
360 |
'!customer_id' => undef, |
|
361 |
or => [ quotation => undef, quotation => 0, ], |
|
359 |
record_type => 'sales_order', |
|
362 | 360 |
or => [ closed => undef, closed => 0, ], |
363 | 361 |
); |
364 | 362 |
push @where, (reqdate => { ge => $params{after}->clone }) if $params{after}; |
SL/OE.pm | ||
---|---|---|
68 | 68 |
|
69 | 69 |
my $query; |
70 | 70 |
my $ordnumber = 'ordnumber'; |
71 |
my $quotation = '0';
|
|
71 |
my $record_type = $form->{type};
|
|
72 | 72 |
|
73 | 73 |
my @values; |
74 | 74 |
my $where; |
... | ... | |
78 | 78 |
my $rate = ($form->{vc} eq 'customer') ? 'buy' : 'sell'; |
79 | 79 |
|
80 | 80 |
if ($form->{type} =~ /_quotation$/) { |
81 |
$quotation = '1'; |
|
82 | 81 |
$ordnumber = 'quonumber'; |
83 | 82 |
|
84 | 83 |
} elsif ($form->{type} eq 'sales_order') { |
... | ... | |
157 | 156 |
qq|LEFT JOIN order_statuses ON (o.order_status_id = order_statuses.id) | . |
158 | 157 |
qq|$periodic_invoices_joins | . |
159 | 158 |
$phone_notes_join . |
160 |
qq|WHERE (o.quotation = ?) |;
|
|
161 |
push(@values, $quotation);
|
|
159 |
qq|WHERE (o.record_type = ?) |;
|
|
160 |
push(@values, $record_type);
|
|
162 | 161 |
|
163 | 162 |
if ($form->{department_id}) { |
164 | 163 |
$query .= qq| AND o.department_id = ?|; |
... | ... | |
519 | 518 |
LEFT JOIN customer c ON (oe.customer_id = c.id) |
520 | 519 |
LEFT JOIN vendor v ON (oe.vendor_id = v.id) |
521 | 520 |
LEFT JOIN employee e ON (oe.employee_id = e.id) |
522 |
WHERE (COALESCE(quotation, FALSE) = TRUE)
|
|
521 |
WHERE ((oe.record_type = 'sales_quotation') OR (oe.record_type = 'request_quotation'))
|
|
523 | 522 |
AND (COALESCE(closed, FALSE) = FALSE) |
524 | 523 |
AND ((oe.employee_id = ?) OR (oe.salesman_id = ?)) |
525 | 524 |
AND NOT (oe.reqdate ISNULL) |
... | ... | |
1042 | 1041 |
|
1043 | 1042 |
SL::DB->client->with_transaction(sub { |
1044 | 1043 |
|
1045 |
my $query = qq|SELECT quotation FROM oe WHERE id = ?|;
|
|
1044 |
my $query = qq|SELECT record_type FROM oe WHERE id = ?|;
|
|
1046 | 1045 |
my $sth = prepare_query($form, $dbh, $query); |
1047 | 1046 |
|
1048 | 1047 |
do_statement($form, $sth, $query, conv_i($params{to_id})); |
1049 | 1048 |
|
1050 |
my ($quotation) = $sth->fetchrow_array();
|
|
1049 |
my ($record_type) = $sth->fetchrow_array();
|
|
1051 | 1050 |
|
1052 |
if ($quotation) {
|
|
1051 |
if ($record_type =~ /_quotation$/) {
|
|
1053 | 1052 |
return 1; |
1054 | 1053 |
} |
1055 | 1054 |
|
... | ... | |
1058 | 1057 |
foreach my $from_id (@{ $params{from_id} }) { |
1059 | 1058 |
$from_id = conv_i($from_id); |
1060 | 1059 |
do_statement($form, $sth, $query, $from_id); |
1061 |
($quotation) = $sth->fetchrow_array();
|
|
1062 |
push @close_ids, $from_id if ($quotation);
|
|
1060 |
($record_type) = $sth->fetchrow_array();
|
|
1061 |
push @close_ids, $from_id if ($record_type =~ /_quotation$/);
|
|
1063 | 1062 |
} |
1064 | 1063 |
|
1065 | 1064 |
$sth->finish(); |
SL/Presenter.pm | ||
---|---|---|
153 | 153 |
use SL::DB::Order; |
154 | 154 |
use SL::Presenter::Record qw(grouped_record_list); |
155 | 155 |
|
156 |
my $quotation = SL::DB::Manager::Order->get_first(where => { quotation => 1 }); |
|
156 |
my $quotation = SL::DB::Manager::Order->get_first( |
|
157 |
where => [ or => ['record_type' => 'sales_quotation', |
|
158 |
'record_type' => 'request_quotation' ]]); |
|
157 | 159 |
my $records = $quotation->linked_records(direction => 'to'); |
158 | 160 |
my $html = grouped_record_list($records); |
159 | 161 |
|
SL/Presenter/Order.pm | ||
---|---|---|
41 | 41 |
|
42 | 42 |
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; |
43 | 43 |
|
44 |
my $number_method = $order->quotation ? 'quonumber' : 'ordnumber'; |
|
45 |
|
|
46 |
my $text = escape($order->$number_method); |
|
44 |
my $text = escape($order->record_number); |
|
47 | 45 |
if (! delete $params{no_link}) { |
48 | 46 |
my $action = $::instance_conf->get_feature_experimental_order |
49 | 47 |
? 'controller.pl?action=Order/edit' |
t/db_helper/record_links.t | ||
---|---|---|
67 | 67 |
|
68 | 68 |
sub new_order { |
69 | 69 |
my %params = @_; |
70 |
my $record_type = delete $params{record_type}; |
|
71 |
$record_type ||= SALES_ORDER_TYPE(); |
|
70 | 72 |
|
71 | 73 |
return SL::DB::Order->new( |
72 |
record_type => SALES_ORDER_TYPE(),
|
|
74 |
record_type => $record_type,
|
|
73 | 75 |
customer_id => $customer->id, |
74 | 76 |
currency_id => $currency_id, |
75 | 77 |
employee_id => $employee->id, |
76 | 78 |
salesman_id => $employee->id, |
77 | 79 |
taxzone_id => $taxzone->id, |
78 |
quotation => 0, |
|
79 | 80 |
%params, |
80 | 81 |
)->save; |
81 | 82 |
} |
... | ... | |
152 | 153 |
is @$links, 0, 'no dangling link after delete'; |
153 | 154 |
|
154 | 155 |
# can we distinguish between types? |
155 |
$o1 = new_order(quotation => 1);
|
|
156 |
$o1 = new_order(record_type => SALES_QUOTATION_TYPE());
|
|
156 | 157 |
$o2 = new_order(); |
157 | 158 |
$o1->link_to_record($o2); |
158 | 159 |
|
159 |
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ quotation => 1 ]);
|
|
160 |
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ record_type => SALES_QUOTATION_TYPE() ]);
|
|
160 | 161 |
is $links->[0]->id, $o1->id, 'query restricted retrieve 1'; |
161 | 162 |
|
162 |
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ quotation => 0 ]);
|
|
163 |
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ record_type => SALES_ORDER_TYPE() ]);
|
|
163 | 164 |
is @$links, 0, 'query restricted retrieve 2'; |
164 | 165 |
|
165 | 166 |
# try bidirectional linking |
t/model/records.t | ||
---|---|---|
33 | 33 |
reset_basic_sales_records(); |
34 | 34 |
reset_basic_purchase_records(); |
35 | 35 |
|
36 |
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 1 ]), 2, 'number of quotations before delete ok'); |
|
37 |
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 0 ]), 2, 'number of orders before delete ok'); |
|
36 |
is(SL::DB::Manager::Order->get_all_count( |
|
37 |
where => [ or => ['record_type' => 'sales_quotation', 'record_type' => 'request_quotation' ]]), |
|
38 |
2, 'number of quotations before delete ok'); |
|
39 |
is(SL::DB::Manager::Order->get_all_count( |
|
40 |
where => [ and => ['!record_type' => 'sales_quotation', '!record_type' => 'request_quotation' ]]), |
|
41 |
2, 'number of orders before delete ok'); |
|
38 | 42 |
is(SL::DB::Manager::DeliveryOrder->get_all_count(), 2, 'number of delivery orders before delete ok'); |
39 | 43 |
is(SL::DB::Manager::Reclamation->get_all_count(), 2, 'number of reclamations before delete ok'); |
40 | 44 |
# is(SL::DB::Manager::Invoice->get_all_count(), 1, 'number of invoices before delete ok'); # no purchase_invoice was created |
... | ... | |
54 | 58 |
ok($record_history->snumbers =~ m/_/, "history snumbers of record " . $record_history->snumbers . " ok"); |
55 | 59 |
}; |
56 | 60 |
|
57 |
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 1 ]), 0, 'number of quotations after delete ok'); |
|
58 |
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 0 ]), 0, 'number of orders after delete ok'); |
|
61 |
is(SL::DB::Manager::Order->get_all_count( |
|
62 |
where => [ or => ['record_type' => 'sales_quotation', 'record_type' => 'request_quotation' ]]), |
|
63 |
0, 'number of quotations after delete ok'); |
|
64 |
is(SL::DB::Manager::Order->get_all_count( |
|
65 |
where => [ and => ['!record_type' => 'sales_quotation', '!record_type' => 'request_quotation' ]]), |
|
66 |
0, 'number of orders after delete ok'); |
|
59 | 67 |
# is(SL::DB::Manager::Invoice->get_all_count(), 0, 'number of invoices after delete ok'); |
60 | 68 |
is(SL::DB::Manager::Reclamation->get_all_count(), 0, 'number of orders after delete ok'); |
61 | 69 |
|
... | ... | |
70 | 78 |
SL::DB::OrderVersion->new(oe_id => $sales_order1->id, version => 1, final_version => 1)->save; |
71 | 79 |
SL::Model::Record->increment_subversion($sales_order1); |
72 | 80 |
is($sales_order1->ordnumber, "ord-01-2", "ordnumber after increment_subversion ok"); |
73 |
is(SL::DB::Manager::Order->get_all_count(where => [quotation => 0]), 2, 'number of orders after incremented subversion ok'); |
|
81 |
is(SL::DB::Manager::Order->get_all_count( |
|
82 |
where => [ and => ['!record_type' => 'sales_quotation', '!record_type' => 'request_quotation' ]]), |
|
83 |
2, 'number of orders after incremented subversion ok'); |
|
74 | 84 |
|
75 | 85 |
|
76 | 86 |
note "testing new_from_workflow for quotation"; |
templates/design40_webpages/custom_data_export_designer/edit.html | ||
---|---|---|
39 | 39 |
SELECT extract(YEAR FROM oe.transdate) AS "Jahr", SUM(oe.amount) AS "Angebotssumme" |
40 | 40 |
FROM oe |
41 | 41 |
LEFT JOIN employee ON (oe.employee_id = employee.id) |
42 |
WHERE (oe.customer_id IS NOT NULL) |
|
43 |
AND COALESCE(oe.quotation, FALSE) |
|
42 |
WHERE record_type = 'sales_quotation' |
|
44 | 43 |
AND (employee.login = <%Benutzer-Login%>) |
45 | 44 |
GROUP BY "Jahr" |
46 | 45 |
ORDER BY "Jahr" |
templates/webpages/custom_data_export_designer/edit.html | ||
---|---|---|
41 | 41 |
SELECT extract(YEAR FROM oe.transdate) AS "Jahr", SUM(oe.amount) AS "Angebotssumme" |
42 | 42 |
FROM oe |
43 | 43 |
LEFT JOIN employee ON (oe.employee_id = employee.id) |
44 |
WHERE (oe.customer_id IS NOT NULL) |
|
45 |
AND COALESCE(oe.quotation, FALSE) |
|
44 |
WHERE oe.record_type = 'sales_quotation' |
|
46 | 45 |
AND (employee.login = <%Benutzer-Login%>) |
47 | 46 |
GROUP BY "Jahr" |
48 | 47 |
ORDER BY "Jahr" |
Auch abrufbar als: Unified diff
Angebotsflag aus Datenbankzugriffen entfernt