Revision 1c77d03f
Von Tamino Steinert vor etwa 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/BackgroundJob/SelfTest/NovoclonStrict.pm | ||
---|---|---|
66 | 66 |
my $title = "Alle offenen Auftragsbestätigungen mit Liefertermin vor mindestens $days_delta Werktagen haben eine Lieferung."; |
67 | 67 |
|
68 | 68 |
my $latest_reqdate = DateTime->today_local->subtract_businessdays(days => $days_delta); |
69 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef, |
|
70 |
or => [quotation => undef, quotation => 0], |
|
71 |
or => [intake => undef, intake => 0], |
|
69 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'sales_order', |
|
72 | 70 |
or => [closed => undef, closed => 0], |
73 | 71 |
reqdate => {le => $latest_reqdate}, |
74 | 72 |
transdate => {ge => $self->start_date},]); |
... | ... | |
122 | 120 |
|
123 | 121 |
my $latest_transdate = DateTime->today_local->subtract_businessdays(days => $days_delta); |
124 | 122 |
|
125 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef, |
|
126 |
intake => 1, |
|
127 |
or => [quotation => undef, quotation => 0], |
|
123 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'sales_order_intake', |
|
128 | 124 |
or => [closed => undef, closed => 0], |
129 | 125 |
transdate => {le => $latest_transdate}, |
130 | 126 |
transdate => {ge => $self->start_date},]); |
... | ... | |
179 | 175 |
|
180 | 176 |
my $latest_transdate = DateTime->today_local->subtract_businessdays(days => $days_delta); |
181 | 177 |
|
182 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef, |
|
183 |
or => [quotation => undef, quotation => 0], |
|
184 |
or => [intake => undef, intake => 0], |
|
178 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'sales_order', |
|
185 | 179 |
or => [closed => undef, closed => 0], |
186 | 180 |
transdate => {le => $latest_transdate}, |
187 | 181 |
transdate => {ge => $self->start_date},]); |
... | ... | |
203 | 197 |
|
204 | 198 |
my $latest_transdate = DateTime->today_local->subtract_businessdays(days => $days_delta); |
205 | 199 |
|
206 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef, |
|
207 |
quotation => 1, |
|
208 |
or => [intake => undef, intake => 0], |
|
200 |
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'request_quotion', |
|
209 | 201 |
or => [closed => undef, closed => 0], |
210 | 202 |
transdate => {le => $latest_transdate}, |
211 | 203 |
transdate => {ge => $self->start_date},]); |
SL/CT.pm | ||
---|---|---|
361 | 361 |
qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | . |
362 | 362 |
qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | . |
363 | 363 |
$pg_join . |
364 |
qq|WHERE $where AND (o.quotation = '0')|;
|
|
364 |
qq|WHERE $where AND ((o.record_type = 'sales_order') OR (o.record_type = 'purcharse_order'))|;
|
|
365 | 365 |
} |
366 | 366 |
|
367 | 367 |
if ( $form->{l_quonumber} ) { |
... | ... | |
380 | 380 |
qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | . |
381 | 381 |
qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | . |
382 | 382 |
$pg_join . |
383 |
qq|WHERE $where AND (o.quotation = '1')|;
|
|
383 |
qq|WHERE $where AND ((o.record_type = 'sales_quotation') OR (o.record_type = 'request_quotation'))|;
|
|
384 | 384 |
} |
385 | 385 |
} |
386 | 386 |
|
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 | ||
---|---|---|
163 | 163 |
|
164 | 164 |
sub delivery_plan_query_linked_items { |
165 | 165 |
my ($self) = @_; |
166 |
my $vc = $self->vc;
|
|
166 |
my $record_type = ($self->vc eq 'customer' ? SALES_ORDER_TYPE() : PURCHASE_ORDER_TYPE());
|
|
167 | 167 |
my $employee_id = SL::DB::Manager::Employee->current->id; |
168 | 168 |
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND"; |
169 | 169 |
|
170 | 170 |
[ |
171 |
"order.${vc}_id" => { gt => 0 },
|
|
171 |
record_type => $record_type,
|
|
172 | 172 |
'order.closed' => 0, |
173 |
or => [ 'order.quotation' => 0, 'order.quotation' => undef ], |
|
174 | 173 |
|
175 | 174 |
# filter by shipped_qty < qty, read from innermost to outermost |
176 | 175 |
'id' => [ \" |
... | ... | |
179 | 178 |
FROM orderitems oi, oe, record_links rl, delivery_order_items doi |
180 | 179 |
WHERE |
181 | 180 |
oe.id = oi.trans_id AND |
182 |
oe.${vc}_id IS NOT NULL AND |
|
183 |
(oe.quotation = 'f' OR oe.quotation IS NULL) AND |
|
181 |
oe.record_type = '$record_type' AND |
|
184 | 182 |
NOT oe.closed AND |
185 | 183 |
$oe_owner |
186 | 184 |
doi.id = rl.to_id AND |
... | ... | |
198 | 196 |
SELECT oi.id FROM orderitems oi, oe |
199 | 197 |
WHERE |
200 | 198 |
oe.id = oi.trans_id AND |
201 |
oe.${vc}_id IS NOT NULL AND |
|
202 |
(oe.quotation = 'f' OR oe.quotation IS NULL) AND |
|
199 |
oe.record_type = '$record_type' AND |
|
203 | 200 |
NOT oe.closed AND |
204 | 201 |
$oe_owner |
205 | 202 |
NOT EXISTS ( |
SL/Controller/Order.pm | ||
---|---|---|
1451 | 1451 |
|
1452 | 1452 |
my $sales_quotations = SL::DB::Manager::Order->get_all(where => [id => $::form->{ids}, |
1453 | 1453 |
or => [closed => 0, closed => undef], |
1454 |
quotation => 1, |
|
1455 |
'!customer_id' => undef]); |
|
1454 |
record_type => SALES_QUOTATION_TYPE()]); |
|
1456 | 1455 |
|
1457 | 1456 |
my $request_quotations = SL::DB::Manager::Order->get_all(where => [id => $::form->{ids}, |
1458 | 1457 |
or => [closed => 0, closed => undef], |
1459 |
quotation => 1, |
|
1460 |
'!vendor_id' => undef]); |
|
1458 |
record_type => REQUEST_QUOTATION_TYPE()]); |
|
1461 | 1459 |
|
1462 | 1460 |
$::auth->assert('sales_quotation_edit') if scalar @$sales_quotations; |
1463 | 1461 |
$::auth->assert('request_quotation_edit') if scalar @$request_quotations; |
... | ... | |
1877 | 1875 |
$order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id}; |
1878 | 1876 |
$order ||= SL::DB::Order->new(orderitems => [], |
1879 | 1877 |
record_type => $self->type, |
1880 |
quotation => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE(), PURCHASE_QUOTATION_INTAKE_TYPE())), |
|
1881 |
intake => (any { $self->type eq $_ } (SALES_ORDER_INTAKE_TYPE(), PURCHASE_QUOTATION_INTAKE_TYPE())), |
|
1882 | 1878 |
currency_id => $::instance_conf->get_currency_id(),); |
1883 | 1879 |
|
1884 | 1880 |
my $cv_id_method = $self->cv . '_id'; |
... | ... | |
2137 | 2133 |
my $is_new = !$self->order->id; |
2138 | 2134 |
|
2139 | 2135 |
my $objects_to_close = scalar @converted_from_oe_ids |
2140 |
? SL::DB::Manager::Order->get_all(where => [id => \@converted_from_oe_ids, quotation => 1]) |
|
2136 |
? SL::DB::Manager::Order->get_all(where => [ |
|
2137 |
id => \@converted_from_oe_ids, |
|
2138 |
or => [ record_type => SALES_QUOTATION_TYPE(), |
|
2139 |
record_type => REQUEST_QUOTATION_TYPE()] |
|
2140 |
]) |
|
2141 | 2141 |
: undef; |
2142 | 2142 |
|
2143 | 2143 |
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 | ||
---|---|---|
301 | 301 |
|
302 | 302 |
$form->{DO} = selectall_hashref_query($form, $dbh, $query, @values); |
303 | 303 |
|
304 |
my $record_type = $vc eq 'customer' ? 'sales_order' : 'purchase_order'; |
|
304 | 305 |
if (scalar @{ $form->{DO} }) { |
305 | 306 |
$query = |
306 | 307 |
qq|SELECT id |
307 | 308 |
FROM oe |
308 |
WHERE NOT COALESCE(quotation, FALSE) |
|
309 |
AND (ordnumber = ?) |
|
310 |
AND (COALESCE(${vc}_id, 0) != 0)|; |
|
309 |
WHERE (record_type = '$record_type' |
|
310 |
AND (ordnumber = ?)|; |
|
311 | 311 |
|
312 | 312 |
my $sth = prepare_query($form, $dbh, $query); |
313 | 313 |
|
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 | ||
---|---|---|
1247 | 1247 |
WHERE (e.currency_id = o.currency_id) |
1248 | 1248 |
AND (e.transdate = o.transdate)) AS exch |
1249 | 1249 |
FROM oe o |
1250 |
WHERE (o.vendor_id = ?) AND (o.quotation = '0') AND (o.closed = '0')|;
|
|
1250 |
WHERE (o.vendor_id = ?) AND (o.record_type = 'purchase_order') AND (o.closed = '0')|;
|
|
1251 | 1251 |
my $sth = prepare_execute_query($form, $dbh, $query, $vid); |
1252 | 1252 |
while (my ($amount, $exch) = $sth->fetchrow_array()) { |
1253 | 1253 |
$exch = 1 unless $exch; |
SL/IS.pm | ||
---|---|---|
2573 | 2573 |
AND e.transdate = o.transdate) |
2574 | 2574 |
FROM oe o |
2575 | 2575 |
WHERE o.customer_id = ? |
2576 |
AND o.quotation = '0'
|
|
2576 |
AND o.record_type = 'sales_order'
|
|
2577 | 2577 |
AND o.closed = '0'|; |
2578 | 2578 |
my $sth = prepare_execute_query($form, $dbh, $query, $cid); |
2579 | 2579 |
|
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'; |
|
72 |
my $intake = '0'; |
|
71 |
my $record_type = $form->{type}; |
|
73 | 72 |
|
74 | 73 |
my @values; |
75 | 74 |
my $where; |
... | ... | |
79 | 78 |
my $rate = ($form->{vc} eq 'customer') ? 'buy' : 'sell'; |
80 | 79 |
|
81 | 80 |
if ($form->{type} =~ /_quotation$/) { |
82 |
$quotation = '1'; |
|
83 | 81 |
$ordnumber = 'quonumber'; |
84 | 82 |
|
85 | 83 |
} elsif ($form->{type} eq 'purchase_quotation_intake') { |
86 |
$intake = '1'; |
|
87 |
$quotation = '1'; |
|
88 | 84 |
$ordnumber = 'quonumber'; |
89 |
|
|
90 |
} elsif ($form->{type} =~ /_order_intake$/) { |
|
91 |
$intake = '1'; |
|
92 |
|
|
93 | 85 |
} elsif ($form->{type} eq 'sales_order') { |
94 | 86 |
$periodic_invoices_columns = qq| , COALESCE(pcfg.active, 'f') AS periodic_invoices |; |
95 | 87 |
$periodic_invoices_joins = qq| LEFT JOIN periodic_invoices_configs pcfg ON (o.id = pcfg.oe_id) |; |
... | ... | |
172 | 164 |
)| . |
173 | 165 |
qq|$periodic_invoices_joins | . |
174 | 166 |
$phone_notes_join . |
175 |
qq|WHERE (o.quotation = ?) | . |
|
176 |
qq| AND (o.intake = ?) |; |
|
177 |
push(@values, $quotation); |
|
178 |
push(@values, $intake); |
|
167 |
qq|WHERE (o.record_type = ?) |; |
|
168 |
push(@values, $record_type); |
|
179 | 169 |
|
180 | 170 |
if ($form->{department_id}) { |
181 | 171 |
$query .= qq| AND o.department_id = ?|; |
... | ... | |
565 | 555 |
LEFT JOIN customer c ON (oe.customer_id = c.id) |
566 | 556 |
LEFT JOIN vendor v ON (oe.vendor_id = v.id) |
567 | 557 |
LEFT JOIN employee e ON (oe.employee_id = e.id) |
568 |
WHERE (COALESCE(quotation, FALSE) = TRUE)
|
|
558 |
WHERE ((oe.record_type = 'sales_quotation') OR (oe.record_type = 'request_quotation'))
|
|
569 | 559 |
AND (COALESCE(closed, FALSE) = FALSE) |
570 | 560 |
AND ((oe.employee_id = ?) OR (oe.salesman_id = ?)) |
571 | 561 |
AND NOT (oe.reqdate ISNULL) |
... | ... | |
1088 | 1078 |
|
1089 | 1079 |
SL::DB->client->with_transaction(sub { |
1090 | 1080 |
|
1091 |
my $query = qq|SELECT quotation FROM oe WHERE id = ?|;
|
|
1081 |
my $query = qq|SELECT record_type FROM oe WHERE id = ?|;
|
|
1092 | 1082 |
my $sth = prepare_query($form, $dbh, $query); |
1093 | 1083 |
|
1094 | 1084 |
do_statement($form, $sth, $query, conv_i($params{to_id})); |
1095 | 1085 |
|
1096 |
my ($quotation) = $sth->fetchrow_array();
|
|
1086 |
my ($record_type) = $sth->fetchrow_array();
|
|
1097 | 1087 |
|
1098 |
if ($quotation) {
|
|
1088 |
if ($record_type =~ /_quotation$/) {
|
|
1099 | 1089 |
return 1; |
1100 | 1090 |
} |
1101 | 1091 |
|
... | ... | |
1104 | 1094 |
foreach my $from_id (@{ $params{from_id} }) { |
1105 | 1095 |
$from_id = conv_i($from_id); |
1106 | 1096 |
do_statement($form, $sth, $query, $from_id); |
1107 |
($quotation) = $sth->fetchrow_array();
|
|
1108 |
push @close_ids, $from_id if ($quotation);
|
|
1097 |
($record_type) = $sth->fetchrow_array();
|
|
1098 |
push @close_ids, $from_id if ($record_type =~ /_quotation$/);
|
|
1109 | 1099 |
} |
1110 | 1100 |
|
1111 | 1101 |
$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 | ||
---|---|---|
53 | 53 |
|
54 | 54 |
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; |
55 | 55 |
|
56 |
my $number_method = $order->quotation ? 'quonumber' : 'ordnumber'; |
|
57 |
|
|
58 |
my $text = escape($order->$number_method); |
|
56 |
my $text = escape($order->record_number); |
|
59 | 57 |
if (! delete $params{no_link}) { |
60 | 58 |
my $action = $::instance_conf->get_feature_experimental_order |
61 | 59 |
? '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/Intakeflag aus Datenbankzugriffen entfernt