Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7a803ab2

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 7a803ab255e99cc8c3170fbada0569c5bdeefda5
  • Vorgänger 39c1eba1
  • Nachfolger c48baedf

Angebotsflag/Intakeflag aus Datenbankzugriffen entfernt

Unterschiede anzeigen:

SL/BackgroundJob/CloseProjectsBelongingToClosedSalesOrders.pm
SELECT oe.globalproject_id
FROM oe
WHERE (oe.globalproject_id IS NOT NULL)
AND (oe.customer_id IS NOT NULL)
AND NOT COALESCE(oe.quotation, FALSE)
AND oe.record_type = 'sales_order'
AND COALESCE(oe.closed, FALSE)
)
EOSQL
SL/BackgroundJob/ConvertTimeRecordings.pm
}
$orders = SL::DB::Manager::Order->get_all(where => [customer_id => $tr->customer_id,
or => [quotation => undef, quotation => 0],
record_type => 'sales_order',
globalproject_id => $project_id, ],
with_objects => ['orderitems']);
SL/BackgroundJob/SelfTest/NovoclonStrict.pm
my $title = "Alle offenen Auftragsbestätigungen mit Liefertermin vor mindestens $days_delta Werktagen haben eine Lieferung.";
my $latest_reqdate = DateTime->today_local->subtract_businessdays(days => $days_delta);
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef,
or => [quotation => undef, quotation => 0],
or => [intake => undef, intake => 0],
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'sales_order',
or => [closed => undef, closed => 0],
reqdate => {le => $latest_reqdate},
transdate => {ge => $self->start_date},]);
......
my $latest_transdate = DateTime->today_local->subtract_businessdays(days => $days_delta);
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef,
intake => 1,
or => [quotation => undef, quotation => 0],
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'sales_order_intake',
or => [closed => undef, closed => 0],
transdate => {le => $latest_transdate},
transdate => {ge => $self->start_date},]);
......
my $latest_transdate = DateTime->today_local->subtract_businessdays(days => $days_delta);
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef,
or => [quotation => undef, quotation => 0],
or => [intake => undef, intake => 0],
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'sales_order',
or => [closed => undef, closed => 0],
transdate => {le => $latest_transdate},
transdate => {ge => $self->start_date},]);
......
my $latest_transdate = DateTime->today_local->subtract_businessdays(days => $days_delta);
my $orders = SL::DB::Manager::Order->get_all_sorted(where => ['!customer_id' => undef,
quotation => 1,
or => [intake => undef, intake => 0],
my $orders = SL::DB::Manager::Order->get_all_sorted(where => [record_type => 'request_quotion',
or => [closed => undef, closed => 0],
transdate => {le => $latest_transdate},
transdate => {ge => $self->start_date},]);
SL/CT.pm
qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | .
$pg_join .
qq|WHERE $where AND (o.quotation = '0')|;
qq|WHERE $where AND ((o.record_type = 'sales_order') OR (o.record_type = 'purcharse_order'))|;
}
if ( $form->{l_quonumber} ) {
......
qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|LEFT JOIN payment_terms pt ON (ct.payment_id = pt.id) | .
$pg_join .
qq|WHERE $where AND (o.quotation = '1')|;
qq|WHERE $where AND ((o.record_type = 'sales_quotation') OR (o.record_type = 'request_quotation'))|;
}
}
SL/Controller/CustomerVendorTurnover.pm
use SL::DB::AccTransaction;
use SL::DB::Invoice;
use SL::DB::Order;
use SL::DB::Order::TypeData qw(:types);
use SL::DB::EmailJournal;
use SL::DB::Letter;
use SL::DB;
......
$orders = SL::DB::Manager::Order->get_all(
query => [
customer_id => $cv,
quotation => ($type eq 'quotation' ? 'T' : 'F')
record_type => ($type eq 'quotation' ? SALES_QUOTATION_TYPE() : SALES_ORDER_TYPE())
],
sort_by => 'transdate DESC',
);
......
$orders = SL::DB::Manager::Order->get_all(
query => [
vendor_id => $cv,
quotation => ($type eq 'quotation' ? 'T' : 'F')
record_type => ($type eq 'quotation' ? REQUEST_QUOTATION_TYPE() : PURCHASE_ORDER_TYPE())
],
sort_by => 'transdate DESC',
);
......
$query = <<SQL;
WITH
oe_emails_customer
AS (SELECT rc.to_id, rc.from_id, oe.quotation, oe.quonumber, oe.ordnumber, c.id
AS (SELECT rc.to_id, rc.from_id, oe.record_type, oe.quonumber, oe.ordnumber, c.id
FROM record_links rc
LEFT JOIN oe oe ON rc.from_id = oe.id
LEFT JOIN customer c ON oe.customer_id = c.id
......
SELECT ej.*,
CASE
oec.quotation WHEN 'F' THEN 'Sales Order'
ELSE 'Quotation'
oec.record_type WHEN 'sales_order' THEN 'Sales Order'
ELSE 'Quotation'
END AS type,
CASE
oec.quotation WHEN 'F' THEN oec.ordnumber
ELSE oec.quonumber
oec.record_type WHEN 'sales_order' THEN oec.ordnumber
ELSE oec.quonumber
END AS recordnumber,
oec.id AS record_id
FROM email_journal ej
......
$query = <<SQL;
WITH
oe_emails_vendor
AS (SELECT rc.to_id, rc.from_id, oe.quotation, oe.quonumber, oe.ordnumber, c.id
AS (SELECT rc.to_id, rc.from_id, oe.record_type, oe.quonumber, oe.ordnumber, c.id
FROM record_links rc
LEFT JOIN oe oe ON rc.from_id = oe.id
LEFT JOIN vendor c ON oe.vendor_id = c.id
......
SELECT ej.*,
CASE
oec.quotation WHEN 'F' THEN 'Purchase Order'
ELSE 'Request quotation'
oec.record_type WHEN 'purchase_order' THEN 'Purchase Order'
ELSE 'Request quotation'
END AS type,
CASE
oec.quotation WHEN 'F' THEN oec.ordnumber
ELSE oec.quonumber
oec.record_type WHEN 'purchase_order' THEN oec.ordnumber
ELSE oec.quonumber
END AS recordnumber,
oec.id AS record_id
FROM email_journal ej
SL/Controller/DeliveryPlan.pm
sub delivery_plan_query_linked_items {
my ($self) = @_;
my $vc = $self->vc;
my $record_type = ($self->vc eq 'customer' ? SALES_ORDER_TYPE() : PURCHASE_ORDER_TYPE());
my $employee_id = SL::DB::Manager::Employee->current->id;
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND";
[
"order.${vc}_id" => { gt => 0 },
record_type => $record_type,
'order.closed' => 0,
or => [ 'order.quotation' => 0, 'order.quotation' => undef ],
# filter by shipped_qty < qty, read from innermost to outermost
'id' => [ \"
......
FROM orderitems oi, oe, record_links rl, delivery_order_items doi
WHERE
oe.id = oi.trans_id AND
oe.${vc}_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
oe.record_type = '$record_type' AND
NOT oe.closed AND
$oe_owner
doi.id = rl.to_id AND
......
SELECT oi.id FROM orderitems oi, oe
WHERE
oe.id = oi.trans_id AND
oe.${vc}_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
oe.record_type = '$record_type' AND
NOT oe.closed AND
$oe_owner
NOT EXISTS (
SL/Controller/Order.pm
my $sales_quotations = SL::DB::Manager::Order->get_all(where => [id => $::form->{ids},
or => [closed => 0, closed => undef],
quotation => 1,
'!customer_id' => undef]);
record_type => SALES_QUOTATION_TYPE()]);
my $request_quotations = SL::DB::Manager::Order->get_all(where => [id => $::form->{ids},
or => [closed => 0, closed => undef],
quotation => 1,
'!vendor_id' => undef]);
record_type => REQUEST_QUOTATION_TYPE()]);
$::auth->assert('sales_quotation_edit') if scalar @$sales_quotations;
$::auth->assert('request_quotation_edit') if scalar @$request_quotations;
......
$order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
$order ||= SL::DB::Order->new(orderitems => [],
record_type => $self->type,
quotation => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE(), PURCHASE_QUOTATION_INTAKE_TYPE())),
intake => (any { $self->type eq $_ } (SALES_ORDER_INTAKE_TYPE(), PURCHASE_QUOTATION_INTAKE_TYPE())),
currency_id => $::instance_conf->get_currency_id(),);
my $cv_id_method = $self->cv . '_id';
......
my $is_new = !$self->order->id;
my $objects_to_close = scalar @converted_from_oe_ids
? SL::DB::Manager::Order->get_all(where => [id => \@converted_from_oe_ids, quotation => 1])
? SL::DB::Manager::Order->get_all(where => [
id => \@converted_from_oe_ids,
or => [ record_type => SALES_QUOTATION_TYPE(),
record_type => REQUEST_QUOTATION_TYPE()]
])
: undef;
my $items_to_delete = scalar @{ $self->item_ids_to_delete || [] }
SL/Controller/RequirementSpecOrder.pm
my $order = $self->rs_order->order;
my $sections = $self->requirement_spec->sections_sorted;
if (!$::auth->assert($order->quotation ? 'sales_quotation_edit' : 'sales_order_edit', 1)) {
if (!$::auth->assert($order->type_data->rights('edit'), 1)) {
return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render;
}
......
globalproject_id => $self->requirement_spec->project_id,
transdate => DateTime->today_local,
reqdate => $reqdate,
quotation => !!$::form->{quotation},
orderitems => [ @orderitems, @add_items ],
customer_id => $customer->id,
taxincluded => $customer->taxincluded,
SL/Controller/TimeRecording.pm
sub init_all_orders {
my $orders = SL::DB::Manager::Order->get_all(query => [or => [ closed => 0, closed => undef, id => $_[0]->time_recording->order_id ],
or => [ quotation => 0, quotation => undef ],
'!customer_id' => undef]);
record_type => 'sales_order',
]);
return [ map { [$_->id, sprintf("%s %s", $_->number, $_->customervendor->name) ] } sort { $a->number <=> $b->number } @{$orders||[]} ];
}
SL/DB/Helper/LinkedRecords.pm
$sort_dir = $sort_dir * 1 ? 1 : -1;
my %numbers = ( 'SL::DB::SalesProcess' => sub { $_[0]->id },
'SL::DB::Order' => sub { $_[0]->quotation ? $_[0]->quonumber : $_[0]->ordnumber },
'SL::DB::Order' => sub { $_[0]->record_number },
'SL::DB::DeliveryOrder' => sub { $_[0]->donumber },
'SL::DB::Invoice' => sub { $_[0]->invnumber },
'SL::DB::PurchaseInvoice' => sub { $_[0]->invnumber },
SL/DB/Manager/Part.pm
FROM orderitems oi
LEFT JOIN oe ON (oi.trans_id = oe.id)
WHERE (oi.parts_id IN ($placeholders))
AND (NOT COALESCE(oe.quotation, FALSE))
AND oe.record_type = 'purchase_order'
AND (NOT COALESCE(oe.closed, FALSE))
AND (NOT COALESCE(oe.delivered, FALSE))
AND (COALESCE(oe.vendor_id, 0) <> 0)
GROUP BY oi.parts_id
SQL
SL/DB/VC.pm
AND e.transdate = o.transdate)
FROM oe o
WHERE (o.${type}_id = ?)
AND NOT COALESCE(o.quotation, FALSE)
AND ((o.record_type = 'sales_order') OR (o.record_type = 'purchase_order'))
AND NOT COALESCE(o.closed, FALSE)
SQL
SL/DO.pm
$form->{DO} = selectall_hashref_query($form, $dbh, $query, @values);
my $record_type = $vc eq 'customer' ? 'sales_order' : 'purchase_order';
if (scalar @{ $form->{DO} }) {
$query =
qq|SELECT id
FROM oe
WHERE NOT COALESCE(quotation, FALSE)
AND (ordnumber = ?)
AND (COALESCE(${vc}_id, 0) != 0)|;
WHERE (record_type = '$record_type'
AND (ordnumber = ?)|;
my $sth = prepare_query($form, $dbh, $query);
SL/Dev/Record.pm
sub _create_sales_order_or_quotation {
my (%params) = @_;
my $record_type = $params{type};
my $record_type = delete $params{type};
die "illegal type" unless $record_type eq SALES_ORDER_TYPE() or $record_type eq SALES_QUOTATION_TYPE();
my $orderitems = delete $params{orderitems} // _create_two_items($record_type);
......
die "illegal customer" unless ref($customer) eq 'SL::DB::Customer';
my $record = SL::DB::Order->new(
record_type => delete $params{type},
record_type => $record_type,
customer_id => delete $params{customer_id} // $customer->id,
taxzone_id => delete $params{taxzone_id} // $customer->taxzone->id,
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id,
......
employee_id => delete $params{employee_id} // SL::DB::Manager::Employee->current->id,
salesman_id => delete $params{employee_id} // SL::DB::Manager::Employee->current->id,
transdate => delete $params{transdate} // DateTime->today,
quotation => $record_type eq 'sales_quotation' ? 1 : 0,
orderitems => $orderitems,
);
$record->assign_attributes(%params) if %params;
......
sub _create_purchase_order_or_quotation {
my (%params) = @_;
my $record_type = $params{type};
my $record_type = delete $params{type};
die "illegal type" unless $record_type eq PURCHASE_ORDER_TYPE() or $record_type eq REQUEST_QUOTATION_TYPE();
my $orderitems = delete $params{orderitems} // _create_two_items($record_type);
_check_items($orderitems, $record_type);
......
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor';
my $record = SL::DB::Order->new(
record_type => delete $params{type},
record_type => $record_type,
vendor_id => delete $params{vendor_id} // $vendor->id,
taxzone_id => delete $params{taxzone_id} // $vendor->taxzone->id,
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id,
taxincluded => delete $params{taxincluded} // 0,
transdate => delete $params{transdate} // DateTime->today,
'closed' => undef,
quotation => $record_type eq REQUEST_QUOTATION_TYPE() ? 1 : 0,
orderitems => $orderitems,
);
$record->assign_attributes(%params) if %params;
SL/IC.pm
) AS ioi ON ioi.parts_id = p.id|,
apoe =>
q|LEFT JOIN (
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
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
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
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
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
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
) AS apoe ON ((ioi.trans_id = apoe.id) AND (ioi.ioi = apoe.ioi))|,
cv =>
q|LEFT JOIN (
......
description => 'p.',
qty => 'ioi.',
serialnumber => 'ioi.',
quotation => 'apoe.',
record_type => 'apoe.',
cv => 'cv.',
"ioi.id" => ' ',
"ioi.ioi" => ' ',
......
my $bsooqr = any { $form->{$_} } @oe_flags;
my @bsooqr_tokens = ();
push @select_tokens, @qsooqr_flags, 'quotation', 'cv', 'ioi.id', 'ioi.ioi' if $bsooqr;
push @select_tokens, @qsooqr_flags, 'record_type', 'cv', 'ioi.id', 'ioi.ioi' if $bsooqr;
push @select_tokens, @deliverydate_flags if $bsooqr && $form->{l_deliverydate};
push @select_tokens, $q_assembly_lastcost if $form->{l_assembly} && $form->{l_lastcost};
push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem| if $form->{bought};
push @bsooqr_tokens, q|module = 'is' AND NOT ioi.assemblyitem| if $form->{sold};
push @bsooqr_tokens, q|module = 'oe' AND NOT quotation AND cv = 'customer'| if $form->{ordered};
push @bsooqr_tokens, q|module = 'oe' AND NOT quotation AND cv = 'vendor'| if $form->{onorder};
push @bsooqr_tokens, q|module = 'oe' AND quotation AND cv = 'customer'| if $form->{quoted};
push @bsooqr_tokens, q|module = 'oe' AND quotation AND cv = 'vendor'| if $form->{rfq};
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'sales_order'| if $form->{ordered};
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'purchase_order'| if $form->{onorder};
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'sales_quotation'| if $form->{quoted};
push @bsooqr_tokens, q|module = 'oe' AND record_type = 'request_quotation'| if $form->{rfq};
push @where_tokens, join ' OR ', map { "($_)" } @bsooqr_tokens if $bsooqr;
$joins_needed{partsgroup} = 1;
SL/IR.pm
WHERE (e.currency_id = o.currency_id)
AND (e.transdate = o.transdate)) AS exch
FROM oe o
WHERE (o.vendor_id = ?) AND (o.quotation = '0') AND (o.closed = '0')|;
WHERE (o.vendor_id = ?) AND (o.record_type = 'purchase_order') AND (o.closed = '0')|;
my $sth = prepare_execute_query($form, $dbh, $query, $vid);
while (my ($amount, $exch) = $sth->fetchrow_array()) {
$exch = 1 unless $exch;
SL/IS.pm
AND e.transdate = o.transdate)
FROM oe o
WHERE o.customer_id = ?
AND o.quotation = '0'
AND o.record_type = 'sales_order'
AND o.closed = '0'|;
my $sth = prepare_execute_query($form, $dbh, $query, $cid);
SL/LiquidityProjection.pm
LEFT JOIN buchungsgruppen bg ON (p.buchungsgruppen_id = bg.id)
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id)
LEFT JOIN employee e ON (COALESCE(oe.salesman_id, oe.employee_id) = e.id)
WHERE (oe.customer_id IS NOT NULL)
AND NOT COALESCE(oe.quotation, FALSE)
WHERE oe.record_type = 'sales_order'
AND NOT COALESCE(oe.closed, FALSE)
AND (oe.id NOT IN (SELECT oe_id FROM periodic_invoices_configs WHERE periodicity <> 'o'))
SQL
......
}
my @where = (
'!customer_id' => undef,
or => [ quotation => undef, quotation => 0, ],
record_type => 'sales_order',
or => [ closed => undef, closed => 0, ],
);
push @where, (reqdate => { ge => $params{after}->clone }) if $params{after};
SL/OE.pm
my $query;
my $ordnumber = 'ordnumber';
my $quotation = '0';
my $intake = '0';
my $record_type = $form->{type};
my @values;
my $where;
......
my $rate = ($form->{vc} eq 'customer') ? 'buy' : 'sell';
if ($form->{type} =~ /_quotation$/) {
$quotation = '1';
$ordnumber = 'quonumber';
} elsif ($form->{type} eq 'purchase_quotation_intake') {
$intake = '1';
$quotation = '1';
$ordnumber = 'quonumber';
} elsif ($form->{type} =~ /_order_intake$/) {
$intake = '1';
} elsif ($form->{type} eq 'sales_order') {
$periodic_invoices_columns = qq| , COALESCE(pcfg.active, 'f') AS periodic_invoices |;
$periodic_invoices_joins = qq| LEFT JOIN periodic_invoices_configs pcfg ON (o.id = pcfg.oe_id) |;
......
)| .
qq|$periodic_invoices_joins | .
$phone_notes_join .
qq|WHERE (o.quotation = ?) | .
qq| AND (o.intake = ?) |;
push(@values, $quotation);
push(@values, $intake);
qq|WHERE (o.record_type = ?) |;
push(@values, $record_type);
if ($form->{department_id}) {
$query .= qq| AND o.department_id = ?|;
......
LEFT JOIN customer c ON (oe.customer_id = c.id)
LEFT JOIN vendor v ON (oe.vendor_id = v.id)
LEFT JOIN employee e ON (oe.employee_id = e.id)
WHERE (COALESCE(quotation, FALSE) = TRUE)
WHERE ((oe.record_type = 'sales_quotation') OR (oe.record_type = 'request_quotation'))
AND (COALESCE(closed, FALSE) = FALSE)
AND ((oe.employee_id = ?) OR (oe.salesman_id = ?))
AND NOT (oe.reqdate ISNULL)
......
SL::DB->client->with_transaction(sub {
my $query = qq|SELECT quotation FROM oe WHERE id = ?|;
my $query = qq|SELECT record_type FROM oe WHERE id = ?|;
my $sth = prepare_query($form, $dbh, $query);
do_statement($form, $sth, $query, conv_i($params{to_id}));
my ($quotation) = $sth->fetchrow_array();
my ($record_type) = $sth->fetchrow_array();
if ($quotation) {
if ($record_type =~ /_quotation$/) {
return 1;
}
......
foreach my $from_id (@{ $params{from_id} }) {
$from_id = conv_i($from_id);
do_statement($form, $sth, $query, $from_id);
($quotation) = $sth->fetchrow_array();
push @close_ids, $from_id if ($quotation);
($record_type) = $sth->fetchrow_array();
push @close_ids, $from_id if ($record_type =~ /_quotation$/);
}
$sth->finish();
SL/Presenter.pm
use SL::DB::Order;
use SL::Presenter::Record qw(grouped_record_list);
my $quotation = SL::DB::Manager::Order->get_first(where => { quotation => 1 });
my $quotation = SL::DB::Manager::Order->get_first(
where => [ or => ['record_type' => 'sales_quotation',
'record_type' => 'request_quotation' ]]);
my $records = $quotation->linked_records(direction => 'to');
my $html = grouped_record_list($records);
SL/Presenter/Order.pm
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
my $number_method = $order->quotation ? 'quonumber' : 'ordnumber';
my $text = escape($order->$number_method);
my $text = escape($order->record_number);
if (! delete $params{no_link}) {
my $action = $::instance_conf->get_feature_experimental_order
? 'controller.pl?action=Order/edit'
t/db_helper/record_links.t
sub new_order {
my %params = @_;
my $record_type = delete $params{record_type};
$record_type ||= SALES_ORDER_TYPE();
return SL::DB::Order->new(
record_type => SALES_ORDER_TYPE(),
record_type => $record_type,
customer_id => $customer->id,
currency_id => $currency_id,
employee_id => $employee->id,
salesman_id => $employee->id,
taxzone_id => $taxzone->id,
quotation => 0,
%params,
)->save;
}
......
is @$links, 0, 'no dangling link after delete';
# can we distinguish between types?
$o1 = new_order(quotation => 1);
$o1 = new_order(record_type => SALES_QUOTATION_TYPE());
$o2 = new_order();
$o1->link_to_record($o2);
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ quotation => 1 ]);
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ record_type => SALES_QUOTATION_TYPE() ]);
is $links->[0]->id, $o1->id, 'query restricted retrieve 1';
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ quotation => 0 ]);
$links = $o2->linked_records(direction => 'from', from => 'Order', query => [ record_type => SALES_ORDER_TYPE() ]);
is @$links, 0, 'query restricted retrieve 2';
# try bidirectional linking
t/model/records.t
reset_basic_sales_records();
reset_basic_purchase_records();
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 1 ]), 2, 'number of quotations before delete ok');
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 0 ]), 2, 'number of orders before delete ok');
is(SL::DB::Manager::Order->get_all_count(
where => [ or => ['record_type' => 'sales_quotation', 'record_type' => 'request_quotation' ]]),
2, 'number of quotations before delete ok');
is(SL::DB::Manager::Order->get_all_count(
where => [ and => ['!record_type' => 'sales_quotation', '!record_type' => 'request_quotation' ]]),
2, 'number of orders before delete ok');
is(SL::DB::Manager::DeliveryOrder->get_all_count(), 2, 'number of delivery orders before delete ok');
is(SL::DB::Manager::Reclamation->get_all_count(), 2, 'number of reclamations before delete ok');
# is(SL::DB::Manager::Invoice->get_all_count(), 1, 'number of invoices before delete ok'); # no purchase_invoice was created
......
ok($record_history->snumbers =~ m/_/, "history snumbers of record " . $record_history->snumbers . " ok");
};
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 1 ]), 0, 'number of quotations after delete ok');
is(SL::DB::Manager::Order->get_all_count(where => [ quotation => 0 ]), 0, 'number of orders after delete ok');
is(SL::DB::Manager::Order->get_all_count(
where => [ or => ['record_type' => 'sales_quotation', 'record_type' => 'request_quotation' ]]),
0, 'number of quotations after delete ok');
is(SL::DB::Manager::Order->get_all_count(
where => [ and => ['!record_type' => 'sales_quotation', '!record_type' => 'request_quotation' ]]),
0, 'number of orders after delete ok');
# is(SL::DB::Manager::Invoice->get_all_count(), 0, 'number of invoices after delete ok');
is(SL::DB::Manager::Reclamation->get_all_count(), 0, 'number of orders after delete ok');
......
SL::DB::OrderVersion->new(oe_id => $sales_order1->id, version => 1, final_version => 1)->save;
SL::Model::Record->increment_subversion($sales_order1);
is($sales_order1->ordnumber, "ord-01-2", "ordnumber after increment_subversion ok");
is(SL::DB::Manager::Order->get_all_count(where => [quotation => 0]), 2, 'number of orders after incremented subversion ok');
is(SL::DB::Manager::Order->get_all_count(
where => [ and => ['!record_type' => 'sales_quotation', '!record_type' => 'request_quotation' ]]),
2, 'number of orders after incremented subversion ok');
note "testing new_from_workflow for quotation";
templates/design40_webpages/custom_data_export_designer/edit.html
SELECT extract(YEAR FROM oe.transdate) AS &quot;Jahr&quot;, SUM(oe.amount) AS &quot;Angebotssumme&quot;
FROM oe
LEFT JOIN employee ON (oe.employee_id = employee.id)
WHERE (oe.customer_id IS NOT NULL)
AND COALESCE(oe.quotation, FALSE)
WHERE record_type = 'sales_quotation'
AND (employee.login = &lt;%Benutzer-Login%&gt;)
GROUP BY &quot;Jahr&quot;
ORDER BY &quot;Jahr&quot;
templates/webpages/custom_data_export_designer/edit.html
SELECT extract(YEAR FROM oe.transdate) AS &quot;Jahr&quot;, SUM(oe.amount) AS &quot;Angebotssumme&quot;
FROM oe
LEFT JOIN employee ON (oe.employee_id = employee.id)
WHERE (oe.customer_id IS NOT NULL)
AND COALESCE(oe.quotation, FALSE)
WHERE oe.record_type = 'sales_quotation'
AND (employee.login = &lt;%Benutzer-Login%&gt;)
GROUP BY &quot;Jahr&quot;
ORDER BY &quot;Jahr&quot;

Auch abrufbar als: Unified diff