Revision ac05693f
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
182 | 182 |
# make new order from given orders |
183 | 183 |
my @multi_orders = map { SL::DB::DeliveryOrder->new(id => $_)->load } @multi_ids; |
184 | 184 |
$self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders; |
185 |
my $target_type = "sales_delivery_order";
|
|
185 |
my $target_type = SALES_DELIVERY_ORDER_TYPE();
|
|
186 | 186 |
my $delivery_order = SL::Model::Record->new_from_workflow_multi(\@multi_orders, $target_type, sort_sources_by => 'transdate'); |
187 | 187 |
$self->order($delivery_order); |
188 | 188 |
|
SL/Controller/Order.pm | ||
---|---|---|
35 | 35 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions); |
36 | 36 |
use SL::DB::Helper::TypeDataProxy; |
37 | 37 |
use SL::Model::Record; |
38 |
use SL::DB::Order::TypeData qw(:types); |
|
39 |
use SL::DB::Reclamation::TypeData qw(:types); |
|
38 | 40 |
|
39 | 41 |
use SL::Helper::CreatePDF qw(:all); |
40 | 42 |
use SL::Helper::PrintOptions; |
... | ... | |
98 | 100 |
|
99 | 101 |
my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load; |
100 | 102 |
my %params; |
101 |
my $target_type = $reclamation->is_sales ? 'sales_order'
|
|
102 |
: 'purchase_order';
|
|
103 |
my $target_type = $reclamation->is_sales ? SALES_ORDER_TYPE()
|
|
104 |
: PURCHASE_ORDER_TYPE();
|
|
103 | 105 |
my $order = SL::Model::Record->new_from_workflow($reclamation, $target_type); |
104 | 106 |
$self->{converted_from_reclamation_id} = $::form->{from_id}; |
105 | 107 |
|
... | ... | |
189 | 191 |
my ($self) = @_; |
190 | 192 |
|
191 | 193 |
SL::Model::Record->delete($self->order); |
192 |
my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been deleted')
|
|
193 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been deleted')
|
|
194 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been deleted')
|
|
195 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been deleted')
|
|
194 |
my $text = $self->type eq SALES_ORDER_TYPE() ? $::locale->text('The order has been deleted')
|
|
195 |
: $self->type eq PURCHASE_ORDER_TYPE() ? $::locale->text('The order has been deleted')
|
|
196 |
: $self->type eq SALES_QUOTATION_TYPE() ? $::locale->text('The quotation has been deleted')
|
|
197 |
: $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been deleted')
|
|
196 | 198 |
: ''; |
197 | 199 |
flash_later('info', $text); |
198 | 200 |
|
... | ... | |
210 | 212 |
|
211 | 213 |
$self->save(); |
212 | 214 |
|
213 |
my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
|
|
214 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
|
|
215 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
|
|
216 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
|
|
215 |
my $text = $self->type eq SALES_ORDER_TYPE() ? $::locale->text('The order has been saved')
|
|
216 |
: $self->type eq PURCHASE_ORDER_TYPE() ? $::locale->text('The order has been saved')
|
|
217 |
: $self->type eq SALES_QUOTATION_TYPE() ? $::locale->text('The quotation has been saved')
|
|
218 |
: $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been saved')
|
|
217 | 219 |
: ''; |
218 | 220 |
flash_later('info', $text); |
219 | 221 |
|
... | ... | |
740 | 742 |
$config ||= SL::DB::Manager::PeriodicInvoicesConfig->find_by(oe_id => $::form->{id}) if $::form->{id}; |
741 | 743 |
|
742 | 744 |
my $has_active_periodic_invoices = |
743 |
$self->type eq sales_order_type()
|
|
745 |
$self->type eq SALES_ORDER_TYPE()
|
|
744 | 746 |
&& $config |
745 | 747 |
&& $config->active |
746 | 748 |
&& (!$config->end_date || ($config->end_date > DateTime->today_local)) |
... | ... | |
777 | 779 |
# can't use save_and_redirect_to, because id is set! |
778 | 780 |
$self->save(); |
779 | 781 |
|
780 |
my $to_type = $self->order->is_sales ? 'sales_reclamation'
|
|
781 |
: 'purchase_reclamation';
|
|
782 |
my $to_type = $self->order->is_sales ? SALES_RECLAMATION_TYPE()
|
|
783 |
: PURCHASE_RECLAMATION_TYPE();
|
|
782 | 784 |
$self->redirect_to( |
783 | 785 |
controller => 'Reclamation', |
784 | 786 |
action => 'add_from_order', |
... | ... | |
846 | 848 |
my $destination_type = $::form->{to_type} ? $::form->{to_type} : ''; |
847 | 849 |
|
848 | 850 |
my $from_side = $self->order->is_sales ? 'sales' : 'purchase'; |
849 |
my $to_side = (any { $destination_type eq $_ } (sales_order_type(), sales_quotation_type())) ? 'sales' : 'purchase';
|
|
851 |
my $to_side = (any { $destination_type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE())) ? 'sales' : 'purchase';
|
|
850 | 852 |
|
851 | 853 |
# check for direct delivery |
852 | 854 |
# copy shipto in custom shipto (custom shipto will be copied by new_from() in case) |
... | ... | |
859 | 861 |
$self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type)); |
860 | 862 |
|
861 | 863 |
# no linked records to quotations from the same side (sales -> sales or purchase -> purchase) |
862 |
if ( (any { $destination_type eq $_ } (sales_quotation_type(), request_quotation_type()))
|
|
864 |
if ( (any { $destination_type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE()))
|
|
863 | 865 |
&& $from_side eq $to_side) { |
864 | 866 |
delete $::form->{id}; |
865 | 867 |
delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids); |
... | ... | |
1578 | 1580 |
# |
1579 | 1581 |
|
1580 | 1582 |
sub init_valid_types { |
1581 |
[ sales_order_type(), purchase_order_type(), sales_quotation_type(), request_quotation_type() ];
|
|
1583 |
$_[0]->type_data->valid_types;
|
|
1582 | 1584 |
} |
1583 | 1585 |
|
1584 | 1586 |
sub init_type { |
... | ... | |
1594 | 1596 |
sub init_cv { |
1595 | 1597 |
my ($self) = @_; |
1596 | 1598 |
|
1597 |
my $cv = (any { $self->type eq $_ } (sales_order_type(), sales_quotation_type())) ? 'customer'
|
|
1598 |
: (any { $self->type eq $_ } (purchase_order_type(), request_quotation_type())) ? 'vendor'
|
|
1599 |
my $cv = (any { $self->type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE())) ? 'customer'
|
|
1600 |
: (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())) ? 'vendor'
|
|
1599 | 1601 |
: die "Not a valid type for order"; |
1600 | 1602 |
|
1601 | 1603 |
return $cv; |
... | ... | |
1815 | 1817 |
my $order; |
1816 | 1818 |
$order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id}; |
1817 | 1819 |
$order ||= SL::DB::Order->new(orderitems => [], |
1818 |
quotation => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type())),
|
|
1820 |
quotation => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE())),
|
|
1819 | 1821 |
currency_id => $::instance_conf->get_currency_id(),); |
1820 | 1822 |
|
1821 | 1823 |
my $cv_id_method = $self->cv . '_id'; |
... | ... | |
2129 | 2131 |
$item->active_discount_source($price_source->discount_from_source($item->active_discount_source)); |
2130 | 2132 |
} |
2131 | 2133 |
|
2132 |
if (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) {
|
|
2134 |
if (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE())) {
|
|
2133 | 2135 |
# Calculate shipped qtys here to prevent calling calculate for every item via the items method. |
2134 | 2136 |
# Do not use write_to_objects to prevent order->delivered to be set, because this should be |
2135 | 2137 |
# the value from db, which can be set manually or is set when linked delivery orders are saved. |
... | ... | |
2148 | 2150 |
} } @all_objects; |
2149 | 2151 |
} |
2150 | 2152 |
|
2151 |
if ( (any { $self->type eq $_ } (sales_quotation_type(), sales_order_type()))
|
|
2153 |
if ( (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), SALES_ORDER_TYPE()))
|
|
2152 | 2154 |
&& $::instance_conf->get_transport_cost_reminder_article_number_id ) { |
2153 | 2155 |
$self->{template_args}->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load; |
2154 | 2156 |
} |
... | ... | |
2166 | 2168 |
sub setup_edit_action_bar { |
2167 | 2169 |
my ($self, %params) = @_; |
2168 | 2170 |
|
2169 |
my $deletion_allowed = (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type()))
|
|
2170 |
|| (($self->type eq sales_order_type()) && $::instance_conf->get_sales_order_show_delete)
|
|
2171 |
|| (($self->type eq purchase_order_type()) && $::instance_conf->get_purchase_order_show_delete);
|
|
2171 |
my $deletion_allowed = (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE()))
|
|
2172 |
|| (($self->type eq SALES_ORDER_TYPE()) && $::instance_conf->get_sales_order_show_delete)
|
|
2173 |
|| (($self->type eq PURCHASE_ORDER_TYPE()) && $::instance_conf->get_purchase_order_show_delete);
|
|
2172 | 2174 |
|
2173 | 2175 |
my @req_trans_cost_art = qw(kivi.Order.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id; |
2174 |
my @req_cusordnumber = qw(kivi.Order.check_cusordnumber_presence) x($self->type eq sales_order_type() && $::instance_conf->get_order_warn_no_cusordnumber);
|
|
2176 |
my @req_cusordnumber = qw(kivi.Order.check_cusordnumber_presence) x($self->type eq SALES_ORDER_TYPE() && $::instance_conf->get_order_warn_no_cusordnumber);
|
|
2175 | 2177 |
|
2176 | 2178 |
my $has_invoice_for_advance_payment; |
2177 |
if ($self->order->id && $self->type eq sales_order_type()) {
|
|
2179 |
if ($self->order->id && $self->type eq SALES_ORDER_TYPE()) {
|
|
2178 | 2180 |
my $lr = $self->order->linked_records(direction => 'to', to => ['Invoice']); |
2179 | 2181 |
$has_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr; |
2180 | 2182 |
} |
2181 | 2183 |
|
2182 | 2184 |
my $has_final_invoice; |
2183 |
if ($self->order->id && $self->type eq sales_order_type()) {
|
|
2185 |
if ($self->order->id && $self->type eq SALES_ORDER_TYPE()) {
|
|
2184 | 2186 |
my $lr = $self->order->linked_records(direction => 'to', to => ['Invoice']); |
2185 | 2187 |
$has_final_invoice = any {'SL::DB::Invoice' eq ref $_ && "final_invoice" eq $_->type} @$lr; |
2186 | 2188 |
} |
... | ... | |
2248 | 2250 |
], |
2249 | 2251 |
action => [ |
2250 | 2252 |
t8('Save and Quotation'), |
2251 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_quotation_type()), '#order_form' ],
|
|
2253 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => SALES_QUOTATION_TYPE()), '#order_form' ],
|
|
2252 | 2254 |
checks => [ @req_trans_cost_art, @req_cusordnumber ], |
2253 |
only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())),
|
|
2255 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())),
|
|
2254 | 2256 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2255 | 2257 |
], |
2256 | 2258 |
action => [ |
2257 | 2259 |
t8('Save and RFQ'), |
2258 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => request_quotation_type() } ],
|
|
2259 |
only_if => (any { $self->type eq $_ } (sales_order_type(), sales_quotation_type(), purchase_order_type())),
|
|
2260 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => REQUEST_QUOTATION_TYPE() } ],
|
|
2261 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())),
|
|
2260 | 2262 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2261 | 2263 |
], |
2262 | 2264 |
action => [ |
2263 | 2265 |
t8('Save and Sales Order'), |
2264 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_order_type()), '#order_form' ],
|
|
2266 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => SALES_ORDER_TYPE()), '#order_form' ],
|
|
2265 | 2267 |
checks => [ @req_trans_cost_art ], |
2266 |
only_if => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type(), purchase_order_type())),
|
|
2268 |
only_if => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())),
|
|
2267 | 2269 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2268 | 2270 |
], |
2269 | 2271 |
action => [ |
2270 | 2272 |
t8('Save and Purchase Order'), |
2271 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => purchase_order_type() } ],
|
|
2273 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => PURCHASE_ORDER_TYPE() } ],
|
|
2272 | 2274 |
checks => [ @req_trans_cost_art, @req_cusordnumber ], |
2273 |
only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())),
|
|
2275 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())),
|
|
2274 | 2276 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2275 | 2277 |
], |
2276 | 2278 |
action => [ |
... | ... | |
2282 | 2284 |
checks => [ 'kivi.Order.check_save_active_periodic_invoices', |
2283 | 2285 |
@req_trans_cost_art, @req_cusordnumber, |
2284 | 2286 |
], |
2285 |
only_if => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())),
|
|
2287 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE())),
|
|
2286 | 2288 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2287 | 2289 |
], |
2288 | 2290 |
action => [ |
... | ... | |
2294 | 2296 |
checks => [ 'kivi.Order.check_save_active_periodic_invoices', |
2295 | 2297 |
@req_trans_cost_art, @req_cusordnumber, |
2296 | 2298 |
], |
2297 |
only_if => (any { $self->type eq $_ } (purchase_order_type())),
|
|
2299 |
only_if => (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE())),
|
|
2298 | 2300 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2299 | 2301 |
], |
2300 | 2302 |
action => [ |
... | ... | |
2302 | 2304 |
call => [ 'kivi.Order.save', { action => 'save_and_reclamation', |
2303 | 2305 |
warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts }, |
2304 | 2306 |
], |
2305 |
only_if => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type()))
|
|
2307 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE()))
|
|
2306 | 2308 |
], |
2307 | 2309 |
action => [ |
2308 | 2310 |
t8('Save and Invoice'), |
... | ... | |
2325 | 2327 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') |
2326 | 2328 |
: $has_final_invoice ? t8('This order has already a final invoice.') |
2327 | 2329 |
: undef, |
2328 |
only_if => (any { $self->type eq $_ } (sales_order_type())),
|
|
2330 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE())),
|
|
2329 | 2331 |
], |
2330 | 2332 |
action => [ |
2331 | 2333 |
t8('Save and Final Invoice'), |
... | ... | |
2338 | 2340 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') |
2339 | 2341 |
: $has_final_invoice ? t8('This order has already a final invoice.') |
2340 | 2342 |
: undef, |
2341 |
only_if => (any { $self->type eq $_ } (sales_order_type())) && $has_invoice_for_advance_payment,
|
|
2343 |
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE())) && $has_invoice_for_advance_payment,
|
|
2342 | 2344 |
], |
2343 | 2345 |
action => [ |
2344 | 2346 |
t8('Save and AP Transaction'), |
2345 | 2347 |
call => [ 'kivi.Order.save', { action => 'save_and_ap_transaction', |
2346 | 2348 |
warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts }, |
2347 | 2349 |
], |
2348 |
only_if => (any { $self->type eq $_ } (purchase_order_type())),
|
|
2350 |
only_if => (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE())),
|
|
2349 | 2351 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
2350 | 2352 |
], |
2351 | 2353 |
|
... | ... | |
2535 | 2537 |
sub get_periodic_invoices_status { |
2536 | 2538 |
my ($self, $config) = @_; |
2537 | 2539 |
|
2538 |
return if $self->type ne sales_order_type();
|
|
2540 |
return if $self->type ne SALES_ORDER_TYPE();
|
|
2539 | 2541 |
return t8('not configured') if !$config; |
2540 | 2542 |
|
2541 | 2543 |
my $active = ('HASH' eq ref $config) ? $config->{active} |
... | ... | |
2561 | 2563 |
# $::locale->text("Edit Request for Quotation"); |
2562 | 2564 |
|
2563 | 2565 |
$action = ucfirst(lc($action)); |
2564 |
return $self->type eq sales_order_type() ? $::locale->text("$action Sales Order")
|
|
2565 |
: $self->type eq purchase_order_type() ? $::locale->text("$action Purchase Order")
|
|
2566 |
: $self->type eq sales_quotation_type() ? $::locale->text("$action Quotation")
|
|
2567 |
: $self->type eq request_quotation_type() ? $::locale->text("$action Request for Quotation")
|
|
2566 |
return $self->type eq SALES_ORDER_TYPE() ? $::locale->text("$action Sales Order")
|
|
2567 |
: $self->type eq PURCHASE_ORDER_TYPE() ? $::locale->text("$action Purchase Order")
|
|
2568 |
: $self->type eq SALES_QUOTATION_TYPE() ? $::locale->text("$action Quotation")
|
|
2569 |
: $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text("$action Request for Quotation")
|
|
2568 | 2570 |
: ''; |
2569 | 2571 |
} |
2570 | 2572 |
|
... | ... | |
2642 | 2644 |
return ($price_src, $discount_src); |
2643 | 2645 |
} |
2644 | 2646 |
|
2645 |
sub sales_order_type { |
|
2646 |
'sales_order'; |
|
2647 |
} |
|
2648 |
|
|
2649 |
sub purchase_order_type { |
|
2650 |
'purchase_order'; |
|
2651 |
} |
|
2652 |
|
|
2653 |
sub sales_quotation_type { |
|
2654 |
'sales_quotation'; |
|
2655 |
} |
|
2656 |
|
|
2657 |
sub request_quotation_type { |
|
2658 |
'request_quotation'; |
|
2659 |
} |
|
2660 |
|
|
2661 | 2647 |
sub nr_key { |
2662 |
return $_[0]->type eq sales_order_type() ? 'ordnumber'
|
|
2663 |
: $_[0]->type eq purchase_order_type() ? 'ordnumber'
|
|
2664 |
: $_[0]->type eq sales_quotation_type() ? 'quonumber'
|
|
2665 |
: $_[0]->type eq request_quotation_type() ? 'quonumber'
|
|
2648 |
return $_[0]->type eq SALES_ORDER_TYPE() ? 'ordnumber'
|
|
2649 |
: $_[0]->type eq PURCHASE_ORDER_TYPE() ? 'ordnumber'
|
|
2650 |
: $_[0]->type eq SALES_QUOTATION_TYPE() ? 'quonumber'
|
|
2651 |
: $_[0]->type eq REQUEST_QUOTATION_TYPE() ? 'quonumber'
|
|
2666 | 2652 |
: ''; |
2667 | 2653 |
} |
2668 | 2654 |
|
... | ... | |
2671 | 2657 |
|
2672 | 2658 |
$self->save(); |
2673 | 2659 |
|
2674 |
my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
|
|
2675 |
: $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
|
|
2676 |
: $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
|
|
2677 |
: $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
|
|
2660 |
my $text = $self->type eq SALES_ORDER_TYPE() ? $::locale->text('The order has been saved')
|
|
2661 |
: $self->type eq PURCHASE_ORDER_TYPE() ? $::locale->text('The order has been saved')
|
|
2662 |
: $self->type eq SALES_QUOTATION_TYPE() ? $::locale->text('The quotation has been saved')
|
|
2663 |
: $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been saved')
|
|
2678 | 2664 |
: ''; |
2679 | 2665 |
flash_later('info', $text); |
2680 | 2666 |
|
SL/Controller/Reclamation.pm | ||
---|---|---|
39 | 39 |
use SL::DB::DeliveryOrder; |
40 | 40 |
use SL::DB::Invoice; |
41 | 41 |
use SL::Model::Record; |
42 |
use SL::DB::Order::TypeData qw(:types); |
|
43 |
use SL::DB::Reclamation::TypeData qw(:types); |
|
42 | 44 |
|
43 | 45 |
use List::Util qw(first sum0); |
44 | 46 |
use List::UtilsBy qw(sort_by uniq_by); |
... | ... | |
123 | 125 |
} |
124 | 126 |
|
125 | 127 |
my $order = SL::DB::Order->new(id => $::form->{from_id})->load; |
126 |
my $target_type = $order->is_sales ? 'sales_reclamation'
|
|
127 |
: 'purchase_reclamation';
|
|
128 |
my $target_type = $order->is_sales ? SALES_RECLAMATION_TYPE()
|
|
129 |
: PURCHASE_RECLAMATION_TYPE();
|
|
128 | 130 |
my $reclamation = SL::Model::Record->new_from_workflow($order, $target_type); |
129 | 131 |
|
130 | 132 |
$self->reclamation($reclamation); |
... | ... | |
151 | 153 |
} |
152 | 154 |
|
153 | 155 |
my $delivery_order = SL::DB::DeliveryOrder->new(id => $::form->{from_id})->load; |
154 |
my $target_type = $delivery_order->is_sales ? 'sales_reclamation'
|
|
155 |
: 'purchase_reclamation';
|
|
156 |
my $target_type = $delivery_order->is_sales ? SALES_RECLAMATION_TYPE()
|
|
157 |
: PURCHASE_RECLAMATION_TYPE();
|
|
156 | 158 |
my $reclamation = SL::Model::Record->new_from_workflow($delivery_order, $target_type); |
157 | 159 |
|
158 | 160 |
$self->reclamation($reclamation); |
... | ... | |
179 | 181 |
} |
180 | 182 |
|
181 | 183 |
my $invoice = SL::DB::Invoice->new(id => $::form->{from_id})->load; |
182 |
my $target_type = 'sales_reclamation';
|
|
184 |
my $target_type = SALES_RECLAMATION_TYPE();
|
|
183 | 185 |
my $reclamation = SL::Model::Record->new_from_workflow($invoice, $target_type); |
184 | 186 |
|
185 | 187 |
$self->reclamation($reclamation); |
... | ... | |
208 | 210 |
require SL::DB::PurchaseInvoice; |
209 | 211 |
my $invoice = SL::DB::PurchaseInvoice->new(id => $::form->{from_id})->load; |
210 | 212 |
$invoice->{type} = $invoice->invoice_type; #can't add type → invoice_type in SL/DB/PurchaseInvoice |
211 |
my $target_type = 'purchase_reclamation';
|
|
213 |
my $target_type = PURCHASE_RECLAMATION_TYPE();
|
|
212 | 214 |
my $reclamation = SL::Model::Record->new_from_workflow($invoice, $target_type); |
213 | 215 |
|
214 | 216 |
$self->reclamation($reclamation); |
... | ... | |
583 | 585 |
sub action_save_and_order { |
584 | 586 |
my ($self) = @_; |
585 | 587 |
|
586 |
my $to_type = $self->reclamation->is_sales ? 'sales_order'
|
|
587 |
: 'purchase_order';
|
|
588 |
my $to_type = $self->reclamation->is_sales ? SALES_ORDER_TYPE()
|
|
589 |
: PURCHASE_ORDER_TYPE();
|
|
588 | 590 |
|
589 | 591 |
$self->save_with_render_error(); |
590 | 592 |
flash_later('info', t8('The reclamation has been saved')); |
... | ... | |
606 | 608 |
controller => 'Reclamation', |
607 | 609 |
action => 'add_from_reclamation', |
608 | 610 |
from_id => $self->reclamation->id, |
609 |
type => sales_reclamation_type(),
|
|
611 |
type => SALES_RECLAMATION_TYPE(),
|
|
610 | 612 |
); |
611 | 613 |
} |
612 | 614 |
|
... | ... | |
620 | 622 |
controller => 'Reclamation', |
621 | 623 |
action => 'add_from_reclamation', |
622 | 624 |
from_id => $self->reclamation->id, |
623 |
type => purchase_reclamation_type(),
|
|
625 |
type => PURCHASE_RECLAMATION_TYPE(),
|
|
624 | 626 |
); |
625 | 627 |
} |
626 | 628 |
|
... | ... | |
1213 | 1215 |
# |
1214 | 1216 |
|
1215 | 1217 |
sub init_valid_types { |
1216 |
[ sales_reclamation_type(), purchase_reclamation_type() ];
|
|
1218 |
$_[0]->type_data->valid_types;
|
|
1217 | 1219 |
} |
1218 | 1220 |
|
1219 | 1221 |
sub init_type { |
... | ... | |
1229 | 1231 |
sub init_cv { |
1230 | 1232 |
my ($self) = @_; |
1231 | 1233 |
|
1232 |
my $cv = (any { $self->type eq $_ } (sales_reclamation_type())) ? 'customer'
|
|
1233 |
: (any { $self->type eq $_ } (purchase_reclamation_type())) ? 'vendor'
|
|
1234 |
my $cv = (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())) ? 'customer'
|
|
1235 |
: (any { $self->type eq $_ } (PURCHASE_RECLAMATION_TYPE())) ? 'vendor'
|
|
1234 | 1236 |
: die "Not a valid type for reclamation"; |
1235 | 1237 |
|
1236 | 1238 |
return $cv; |
... | ... | |
1273 | 1275 |
language_id => t8('Language'), |
1274 | 1276 |
department_id => t8('Department'), |
1275 | 1277 |
globalproject_id => t8('Project Number'), |
1276 |
cv_record_number => ($self->type eq 'sales_reclamation' ? t8('Customer Record Number') : t8('Vendor Record Number')),
|
|
1278 |
cv_record_number => ($self->type eq SALES_RECLAMATION_TYPE() ? t8('Customer Record Number') : t8('Vendor Record Number')),
|
|
1277 | 1279 |
transaction_description => t8('Description'), |
1278 | 1280 |
notes => t8('Notes'), |
1279 | 1281 |
intnotes => t8('Internal Notes'), |
... | ... | |
1319 | 1321 |
|
1320 | 1322 |
sub init_part_picker_classification_ids { |
1321 | 1323 |
my ($self) = @_; |
1322 |
my $attribute = 'used_for_' . ($self->type eq sales_reclamation_type() ? 'sale' : 'purchase');
|
|
1324 |
my $attribute = 'used_for_' . ($self->type eq SALES_RECLAMATION_TYPE() ? 'sale' : 'purchase');
|
|
1323 | 1325 |
|
1324 | 1326 |
return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(where => [ $attribute => 1 ]) } ]; |
1325 | 1327 |
} |
... | ... | |
1767 | 1769 |
|
1768 | 1770 |
# check for direct delivery |
1769 | 1771 |
# copy shipto in custom shipto (custom shipto will be copied by new_from() in case) |
1770 |
if ($::form->{type} eq purchase_reclamation_type()) {
|
|
1772 |
if ($::form->{type} eq PURCHASE_RECLAMATION_TYPE()) {
|
|
1771 | 1773 |
if ($::form->{use_shipto}) { |
1772 | 1774 |
my $custom_shipto = $source_reclamation->shipto->clone('SL::DB::Reclamation'); |
1773 | 1775 |
$self->reclamation->custom_shipto($custom_shipto) if $custom_shipto; |
... | ... | |
2059 | 2061 |
sub => sub { $_[0]->closed ? t8('Yes') : t8('No') }, |
2060 | 2062 |
}, |
2061 | 2063 |
); |
2062 |
if ($self->type eq sales_reclamation_type()) {
|
|
2064 |
if ($self->type eq SALES_RECLAMATION_TYPE()) {
|
|
2063 | 2065 |
$column_defs{customer_id} = ({ |
2064 | 2066 |
raw_data => sub { $_[0]->customervendor->presenter->customer(display => 'table-cell', callback => $callback) }, |
2065 | 2067 |
sub => sub { $_[0]->customervendor->name }, |
... | ... | |
2074 | 2076 |
}, |
2075 | 2077 |
sub => sub { $_[0]->contact ? $_[0]->contact->cp_name : '' }, |
2076 | 2078 |
}); |
2077 |
} elsif ($self->type eq purchase_reclamation_type()) {
|
|
2079 |
} elsif ($self->type eq PURCHASE_RECLAMATION_TYPE()) {
|
|
2078 | 2080 |
$column_defs{vendor_id} = ({ |
2079 | 2081 |
raw_data => sub { $_[0]->customervendor->presenter->vendor(display => 'table-cell', callback => $callback) }, |
2080 | 2082 |
sub => sub { $_[0]->customervendor->name }, |
... | ... | |
2135 | 2137 |
{ output => 0 }, |
2136 | 2138 |
models => $self->models |
2137 | 2139 |
), |
2138 |
title => $self->type eq sales_reclamation_type() ? t8('Sales Reclamations') : t8('Purchase Reclamations'),
|
|
2140 |
title => $self->type eq SALES_RECLAMATION_TYPE() ? t8('Sales Reclamations') : t8('Purchase Reclamations'),
|
|
2139 | 2141 |
allow_pdf_export => 1, |
2140 | 2142 |
allow_csv_export => 1, |
2141 | 2143 |
); |
... | ... | |
2150 | 2152 |
sub _setup_edit_action_bar { |
2151 | 2153 |
my ($self, %params) = @_; |
2152 | 2154 |
|
2153 |
my $deletion_allowed = ($self->type eq sales_reclamation_type()
|
|
2155 |
my $deletion_allowed = ($self->type eq SALES_RECLAMATION_TYPE()
|
|
2154 | 2156 |
&& $::instance_conf->get_sales_reclamation_show_delete) |
2155 |
|| ($self->type eq purchase_reclamation_type()
|
|
2157 |
|| ($self->type eq PURCHASE_RECLAMATION_TYPE()
|
|
2156 | 2158 |
&& $::instance_conf->get_purchase_reclamation_show_delete); |
2157 | 2159 |
|
2158 | 2160 |
for my $bar ($::request->layout->get('actionbar')) { |
... | ... | |
2190 | 2192 |
$::instance_conf->get_reclamation_warn_duplicate_parts, |
2191 | 2193 |
$::instance_conf->get_reclamation_warn_no_reqdate, |
2192 | 2194 |
], |
2193 |
only_if => (any { $self->type eq $_ } (purchase_reclamation_type())),
|
|
2195 |
only_if => (any { $self->type eq $_ } (PURCHASE_RECLAMATION_TYPE())),
|
|
2194 | 2196 |
], |
2195 | 2197 |
action => [ |
2196 | 2198 |
t8('Save and Purchase Reclamation'), |
2197 | 2199 |
call => [ 'kivi.Reclamation.purchase_reclamation_check_for_direct_delivery' ], |
2198 |
only_if => (any { $self->type eq $_ } (sales_reclamation_type())),
|
|
2200 |
only_if => (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())),
|
|
2199 | 2201 |
], |
2200 | 2202 |
action => [ |
2201 | 2203 |
t8('Save and Order'), |
... | ... | |
2212 | 2214 |
$::instance_conf->get_reclamation_warn_duplicate_parts, |
2213 | 2215 |
$::instance_conf->get_reclamation_warn_no_reqdate, |
2214 | 2216 |
], |
2215 |
only_if => (any { $self->type eq $_ } (sales_reclamation_type())),
|
|
2217 |
only_if => (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())),
|
|
2216 | 2218 |
], |
2217 | 2219 |
action => [ |
2218 | 2220 |
t8('Save and Supplier Delivery Order'), |
... | ... | |
2221 | 2223 |
$::instance_conf->get_reclamation_warn_duplicate_parts, |
2222 | 2224 |
$::instance_conf->get_reclamation_warn_no_reqdate, |
2223 | 2225 |
], |
2224 |
only_if => (any { $self->type eq $_ } (purchase_reclamation_type())),
|
|
2226 |
only_if => (any { $self->type eq $_ } (PURCHASE_RECLAMATION_TYPE())),
|
|
2225 | 2227 |
], |
2226 | 2228 |
action => [ |
2227 | 2229 |
t8('Save and Credit Note'), |
... | ... | |
2230 | 2232 |
$::instance_conf->get_reclamation_warn_duplicate_parts, |
2231 | 2233 |
$::instance_conf->get_reclamation_warn_no_reqdate, |
2232 | 2234 |
], |
2233 |
only_if => (any { $self->type eq $_ } (sales_reclamation_type())),
|
|
2235 |
only_if => (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())),
|
|
2234 | 2236 |
], |
2235 | 2237 |
], # end of combobox "Workflow" |
2236 | 2238 |
|
... | ... | |
2445 | 2447 |
# t8("Edit Purchase Reclamation"); |
2446 | 2448 |
|
2447 | 2449 |
$action = ucfirst(lc($action)); |
2448 |
return $self->type eq sales_reclamation_type() ? t8("$action Sales Reclamation")
|
|
2449 |
: $self->type eq purchase_reclamation_type() ? t8("$action Purchase Reclamation")
|
|
2450 |
return $self->type eq SALES_RECLAMATION_TYPE() ? t8("$action Sales Reclamation")
|
|
2451 |
: $self->type eq PURCHASE_RECLAMATION_TYPE() ? t8("$action Purchase Reclamation")
|
|
2450 | 2452 |
: ''; |
2451 | 2453 |
} |
2452 | 2454 |
|
... | ... | |
2489 | 2491 |
return $texts; |
2490 | 2492 |
} |
2491 | 2493 |
|
2492 |
sub sales_reclamation_type { |
|
2493 |
'sales_reclamation'; |
|
2494 |
} |
|
2495 |
|
|
2496 |
sub purchase_reclamation_type { |
|
2497 |
'purchase_reclamation'; |
|
2498 |
} |
|
2499 |
|
|
2500 | 2494 |
sub save_history { |
2501 | 2495 |
my ($self, $addition) = @_; |
2502 | 2496 |
|
... | ... | |
2550 | 2544 |
} |
2551 | 2545 |
|
2552 | 2546 |
sub init_type_data { |
2553 |
SL::DB::Helper::TypeDataProxy->new('SL::DB::Reclamation', $_[0]->type);
|
|
2547 |
SL::DB::Helper::TypeDataProxy->new('SL::DB::Reclamation', $::form->{type});
|
|
2554 | 2548 |
} |
2555 | 2549 |
|
2556 | 2550 |
1; |
SL/DB/DeliveryOrder.pm | ||
---|---|---|
20 | 20 |
use SL::DB::Unit; |
21 | 21 |
|
22 | 22 |
use SL::DB::DeliveryOrder::TypeData qw(:types); |
23 |
use SL::DB::Reclamation::TypeData qw(:types); |
|
23 | 24 |
|
24 | 25 |
use SL::Helper::Number qw(_format_total _round_total); |
25 | 26 |
|
... | ... | |
93 | 94 |
], |
94 | 95 |
); |
95 | 96 |
|
96 |
return first { $_->is_type('sales_order') } @{ $orders };
|
|
97 |
return first { $_->is_type(SALES_ORDER_TYPE()) } @{ $orders };
|
|
97 | 98 |
} |
98 | 99 |
|
99 | 100 |
sub type { |
... | ... | |
107 | 108 |
sub displayable_type { |
108 | 109 |
my $type = shift->type; |
109 | 110 |
|
110 |
return $::locale->text('Sales Delivery Order') if $type eq 'sales_delivery_order';
|
|
111 |
return $::locale->text('Purchase Delivery Order') if $type eq 'purchase_delivery_order';
|
|
111 |
return $::locale->text('Sales Delivery Order') if $type eq SALES_DELIVERY_ORDER_TYPE();
|
|
112 |
return $::locale->text('Purchase Delivery Order') if $type eq PURCHASE_DELIVERY_ORDER_TYPE();
|
|
112 | 113 |
|
113 | 114 |
die 'invalid type'; |
114 | 115 |
} |
... | ... | |
145 | 146 |
sub convert_to_reclamation { |
146 | 147 |
my ($self, %params) = @_; |
147 | 148 |
|
148 |
$params{destination_type} = $self->is_sales ? 'sales_reclamation'
|
|
149 |
: 'purchase_reclamation';
|
|
149 |
$params{destination_type} = $self->is_sales ? SALES_RECLAMATION_TYPE()
|
|
150 |
: PURCHASE_RECLAMATION_TYPE();
|
|
150 | 151 |
|
151 | 152 |
my $reclamation = SL::DB::Reclamation->new_from($self, %params); |
152 | 153 |
|
... | ... | |
238 | 239 |
} |
239 | 240 |
|
240 | 241 |
# infer type from legacy fields if not given |
241 |
$record_args{order_type} //= $source->customer_id ? 'sales_delivery_order'
|
|
242 |
: $source->vendor_id ? 'purchase_delivery_order'
|
|
243 |
: $source->is_sales ? 'sales_delivery_order'
|
|
242 |
$record_args{order_type} //= $source->customer_id ? SALES_DELIVERY_ORDER_TYPE()
|
|
243 |
: $source->vendor_id ? PURCHASE_DELIVERY_ORDER_TYPE()
|
|
244 |
: $source->is_sales ? SALES_DELIVERY_ORDER_TYPE()
|
|
244 | 245 |
: croak "need some way to set delivery order type from source"; |
245 | 246 |
|
246 | 247 |
my $delivery_order = $class->new(%record_args); |
247 | 248 |
$delivery_order->assign_attributes(%{ $params{attributes} }) if $params{attributes}; |
248 | 249 |
|
249 | 250 |
my $items = delete($params{items}) || $source->items_sorted; |
250 |
my @items = ( $delivery_order->is_type(SUPPLIER_DELIVERY_ORDER_TYPE) && ref($source) ne 'SL::DB::Reclamation' ) ? |
|
251 |
my @items = ( $delivery_order->is_type(SUPPLIER_DELIVERY_ORDER_TYPE()) && ref($source) ne 'SL::DB::Reclamation' ) ?
|
|
251 | 252 |
() |
252 | 253 |
: map { SL::DB::DeliveryOrderItem->new_from($_, %params) } @{ $items }; |
253 | 254 |
|
SL/DB/Order.pm | ||
---|---|---|
26 | 26 |
use SL::RecordLinks; |
27 | 27 |
use Rose::DB::Object::Helpers qw(as_tree strip); |
28 | 28 |
|
29 |
use SL::DB::Order::TypeData qw(:types); |
|
30 |
use SL::DB::Reclamation::TypeData qw(:types); |
|
31 |
|
|
29 | 32 |
__PACKAGE__->meta->add_relationship( |
30 | 33 |
orderitems => { |
31 | 34 |
type => 'one to many', |
... | ... | |
99 | 102 |
my ($self) = @_; |
100 | 103 |
|
101 | 104 |
# force new project, if not set yet |
102 |
if ($::instance_conf->get_order_always_project && !$self->globalproject_id && ($self->type eq 'sales_order')) {
|
|
105 |
if ($::instance_conf->get_order_always_project && !$self->globalproject_id && ($self->type eq SALES_ORDER_TYPE())) {
|
|
103 | 106 |
|
104 | 107 |
die t8("Error while creating project with project number of new order number, project number #1 already exists!", $self->ordnumber) |
105 | 108 |
if SL::DB::Manager::Project->find_by(projectnumber => $self->ordnumber); |
... | ... | |
161 | 164 |
sub type { |
162 | 165 |
my $self = shift; |
163 | 166 |
|
164 |
return 'sales_order' if $self->customer_id && ! $self->quotation;
|
|
165 |
return 'purchase_order' if $self->vendor_id && ! $self->quotation;
|
|
166 |
return 'sales_quotation' if $self->customer_id && $self->quotation;
|
|
167 |
return 'request_quotation' if $self->vendor_id && $self->quotation;
|
|
167 |
return SALES_ORDER_TYPE() if $self->customer_id && ! $self->quotation;
|
|
168 |
return PURCHASE_ORDER_TYPE() if $self->vendor_id && ! $self->quotation;
|
|
169 |
return SALES_QUOTATION_TYPE() if $self->customer_id && $self->quotation;
|
|
170 |
return REQUEST_QUOTATION_TYPE() if $self->vendor_id && $self->quotation;
|
|
168 | 171 |
|
169 | 172 |
return; |
170 | 173 |
} |
... | ... | |
178 | 181 |
# But this has a different meaning for sales quotations. |
179 | 182 |
# deliverydate can be used to determine tax if tax_point isn't set. |
180 | 183 |
|
181 |
return $_[0]->reqdate if $_[0]->type ne 'sales_quotation';
|
|
184 |
return $_[0]->reqdate if $_[0]->type ne SALES_QUOTATION_TYPE();
|
|
182 | 185 |
} |
183 | 186 |
|
184 | 187 |
sub effective_tax_point { |
... | ... | |
190 | 193 |
sub displayable_type { |
191 | 194 |
my $type = shift->type; |
192 | 195 |
|
193 |
return $::locale->text('Sales quotation') if $type eq 'sales_quotation';
|
|
194 |
return $::locale->text('Request quotation') if $type eq 'request_quotation';
|
|
195 |
return $::locale->text('Sales Order') if $type eq 'sales_order';
|
|
196 |
return $::locale->text('Purchase Order') if $type eq 'purchase_order';
|
|
196 |
return $::locale->text('Sales quotation') if $type eq SALES_QUOTATION_TYPE();
|
|
197 |
return $::locale->text('Request quotation') if $type eq REQUEST_QUOTATION_TYPE();
|
|
198 |
return $::locale->text('Sales Order') if $type eq SALES_ORDER_TYPE();
|
|
199 |
return $::locale->text('Purchase Order') if $type eq PURCHASE_ORDER_TYPE();
|
|
197 | 200 |
|
198 | 201 |
die 'invalid type'; |
199 | 202 |
} |
... | ... | |
212 | 215 |
|
213 | 216 |
return 1 if $self->currency_id == $::instance_conf->get_currency_id; |
214 | 217 |
|
215 |
my $rate = (any { $self->is_type($_) } qw(sales_quotation sales_order)) ? 'buy'
|
|
216 |
: (any { $self->is_type($_) } qw(request_quotation purchase_order)) ? 'sell'
|
|
218 |
my $rate = (any { $self->is_type($_) } (SALES_QUOTATION_TYPE(), SALES_ORDER_TYPE())) ? 'buy'
|
|
219 |
: (any { $self->is_type($_) } (REQUEST_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())) ? 'sell'
|
|
217 | 220 |
: undef; |
218 | 221 |
return if !$rate; |
219 | 222 |
|
... | ... | |
303 | 306 |
|
304 | 307 |
sub convert_to_reclamation { |
305 | 308 |
my ($self, %params) = @_; |
306 |
$params{destination_type} = $self->is_sales ? 'sales_reclamation'
|
|
307 |
: 'purchase_reclamation';
|
|
309 |
$params{destination_type} = $self->is_sales ? SALES_RECLAMATION_TYPE()
|
|
310 |
: PURCHASE_RECLAMATION_TYPE();
|
|
308 | 311 |
|
309 | 312 |
require SL::DB::Reclamation; |
310 | 313 |
my $reclamation = SL::DB::Reclamation->new_from($self, %params); |
... | ... | |
335 | 338 |
my $destination_type = delete $params{destination_type}; |
336 | 339 |
|
337 | 340 |
my @from_tos = ( |
338 |
{ from => 'sales_quotation', to => 'sales_order', abbr => 'sqso' },
|
|
339 |
{ from => 'request_quotation', to => 'purchase_order', abbr => 'rqpo' },
|
|
340 |
{ from => 'sales_quotation', to => 'sales_quotation', abbr => 'sqsq' },
|
|
341 |
{ from => 'sales_order', to => 'sales_order', abbr => 'soso' },
|
|
342 |
{ from => 'request_quotation', to => 'request_quotation', abbr => 'rqrq' },
|
|
343 |
{ from => 'purchase_order', to => 'purchase_order', abbr => 'popo' },
|
|
344 |
{ from => 'sales_order', to => 'purchase_order', abbr => 'sopo' },
|
|
345 |
{ from => 'purchase_order', to => 'sales_order', abbr => 'poso' },
|
|
346 |
{ from => 'sales_order', to => 'sales_quotation', abbr => 'sosq' },
|
|
347 |
{ from => 'purchase_order', to => 'request_quotation', abbr => 'porq' },
|
|
348 |
{ from => 'request_quotation', to => 'sales_quotation', abbr => 'rqsq' },
|
|
349 |
{ from => 'request_quotation', to => 'sales_order', abbr => 'rqso' },
|
|
350 |
{ from => 'sales_quotation', to => 'request_quotation', abbr => 'sqrq' },
|
|
351 |
{ from => 'sales_order', to => 'request_quotation', abbr => 'sorq' },
|
|
352 |
{ from => 'sales_reclamation', to => 'sales_order', abbr => 'srso' },
|
|
353 |
{ from => 'purchase_reclamation', to => 'purchase_order', abbr => 'prpo' },
|
|
341 |
{ from => SALES_QUOTATION_TYPE(), to => SALES_ORDER_TYPE(), abbr => 'sqso' },
|
|
342 |
{ from => REQUEST_QUOTATION_TYPE(), to => PURCHASE_ORDER_TYPE(), abbr => 'rqpo' },
|
|
343 |
{ from => SALES_QUOTATION_TYPE(), to => SALES_QUOTATION_TYPE(), abbr => 'sqsq' },
|
|
344 |
{ from => SALES_ORDER_TYPE(), to => SALES_ORDER_TYPE(), abbr => 'soso' },
|
|
345 |
{ from => REQUEST_QUOTATION_TYPE(), to => REQUEST_QUOTATION_TYPE(), abbr => 'rqrq' },
|
|
346 |
{ from => PURCHASE_ORDER_TYPE(), to => PURCHASE_ORDER_TYPE(), abbr => 'popo' },
|
|
347 |
{ from => SALES_ORDER_TYPE(), to => PURCHASE_ORDER_TYPE(), abbr => 'sopo' },
|
|
348 |
{ from => PURCHASE_ORDER_TYPE(), to => SALES_ORDER_TYPE(), abbr => 'poso' },
|
|
349 |
{ from => SALES_ORDER_TYPE(), to => SALES_QUOTATION_TYPE(), abbr => 'sosq' },
|
|
350 |
{ from => PURCHASE_ORDER_TYPE(), to => REQUEST_QUOTATION_TYPE(), abbr => 'porq' },
|
|
351 |
{ from => REQUEST_QUOTATION_TYPE(), to => SALES_QUOTATION_TYPE(), abbr => 'rqsq' },
|
|
352 |
{ from => REQUEST_QUOTATION_TYPE(), to => SALES_ORDER_TYPE(), abbr => 'rqso' },
|
|
353 |
{ from => SALES_QUOTATION_TYPE(), to => REQUEST_QUOTATION_TYPE(), abbr => 'sqrq' },
|
|
354 |
{ from => SALES_ORDER_TYPE(), to => REQUEST_QUOTATION_TYPE(), abbr => 'sorq' },
|
|
355 |
{ from => SALES_RECLAMATION_TYPE(), to => SALES_ORDER_TYPE(), abbr => 'srso' },
|
|
356 |
{ from => PURCHASE_RECLAMATION_TYPE(), to => PURCHASE_ORDER_TYPE(), abbr => 'prpo' },
|
|
354 | 357 |
); |
355 | 358 |
my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0]; |
356 | 359 |
croak("Cannot convert from '" . $source->type . "' to '" . $destination_type . "'") if !$from_to; |
... | ... | |
571 | 574 |
push @items, @{$_->items_sorted} for @$sources; |
572 | 575 |
# make order from first source and all items |
573 | 576 |
my $order = $class->new_from($sources->[0], |
574 |
destination_type => 'sales_order',
|
|
577 |
destination_type => SALES_ORDER_TYPE(),
|
|
575 | 578 |
attributes => \%attributes, |
576 | 579 |
items => \@items, |
577 | 580 |
%params); |
... | ... | |
585 | 588 |
return if !$self->type; |
586 | 589 |
|
587 | 590 |
my %number_method = ( |
588 |
sales_order => 'ordnumber',
|
|
589 |
sales_quotation => 'quonumber',
|
|
590 |
purchase_order => 'ordnumber',
|
|
591 |
request_quotation => 'quonumber',
|
|
591 |
SALES_ORDER_TYPE() => 'ordnumber',
|
|
592 |
SALES_QUOTATION_TYPE() => 'quonumber',
|
|
593 |
PURCHASE_ORDER_TYPE() => 'ordnumber',
|
|
594 |
REQUEST_QUOTATION_TYPE() => 'quonumber',
|
|
592 | 595 |
); |
593 | 596 |
|
594 | 597 |
return $self->${ \ $number_method{$self->type} }(@_); |
SL/DB/Reclamation.pm | ||
---|---|---|
8 | 8 |
use List::Util qw(max sum0); |
9 | 9 |
use List::MoreUtils qw(any); |
10 | 10 |
|
11 |
use SL::DB::DeliveryOrder::TypeData qw(:types); |
|
12 |
use SL::DB::Reclamation::TypeData qw(:types); |
|
11 | 13 |
use SL::DB::MetaSetup::Reclamation; |
12 | 14 |
use SL::DB::Manager::Reclamation; |
13 | 15 |
use SL::DB::Helper::Attr; |
... | ... | |
107 | 109 |
sub type { |
108 | 110 |
my ($self) = @_; |
109 | 111 |
|
110 |
return 'sales_reclamation' if $self->customer_id;
|
|
111 |
return 'purchase_reclamation' if $self->vendor_id;
|
|
112 |
return SALES_RECLAMATION_TYPE() if $self->customer_id;
|
|
113 |
return PURCHASE_RECLAMATION_TYPE() if $self->vendor_id;
|
|
112 | 114 |
|
113 | 115 |
return; |
114 | 116 |
} |
... | ... | |
127 | 129 |
sub displayable_type { |
128 | 130 |
my $type = shift->type; |
129 | 131 |
|
130 |
return $::locale->text('Sales Reclamation') if $type eq 'sales_reclamation';
|
|
131 |
return $::locale->text('Purchase Reclamation') if $type eq 'purchase_reclamation';
|
|
132 |
return $::locale->text('Sales Reclamation') if $type eq SALES_RECLAMATION_TYPE();
|
|
133 |
return $::locale->text('Purchase Reclamation') if $type eq PURCHASE_RECLAMATION_TYPE();
|
|
132 | 134 |
|
133 | 135 |
die 'invalid type'; |
134 | 136 |
} |
... | ... | |
147 | 149 |
|
148 | 150 |
return 1 if $self->currency_id == $::instance_conf->get_currency_id; |
149 | 151 |
|
150 |
my $rate = (any { $self->is_type($_) } qw(sales_reclamation)) ? 'buy'
|
|
151 |
: (any { $self->is_type($_) } qw(purchase_reclamation)) ? 'sell'
|
|
152 |
my $rate = (any { $self->is_type($_) } (SALES_RECLAMATION_TYPE())) ? 'buy'
|
|
153 |
: (any { $self->is_type($_) } (PURCHASE_RECLAMATION_TYPE())) ? 'sell'
|
|
152 | 154 |
: undef; |
153 | 155 |
return if !$rate; |
154 | 156 |
|
... | ... | |
201 | 203 |
my ($self, %params) = @_; |
202 | 204 |
|
203 | 205 |
my $order; |
204 |
$params{destination_type} = $self->is_sales ? 'sales_order'
|
|
205 |
: 'purchase_order';
|
|
206 |
$params{destination_type} = $self->is_sales ? SALES_ORDER_TYPE()
|
|
207 |
: PURCHASE_ORDER_TYPE();
|
|
206 | 208 |
if (!$self->db->with_transaction(sub { |
207 | 209 |
require SL::DB::Order; |
208 | 210 |
$order = SL::DB::Order->new_from($self, %params); |
... | ... | |
253 | 255 |
|
254 | 256 |
my @from_tos = ( |
255 | 257 |
#Reclamation |
256 |
{ from => 'sales_reclamation', to => 'sales_reclamation', abbr => 'srsr', },
|
|
257 |
{ from => 'purchase_reclamation', to => 'purchase_reclamation', abbr => 'prpr', },
|
|
258 |
{ from => 'sales_reclamation', to => 'purchase_reclamation', abbr => 'srpr', },
|
|
259 |
{ from => 'purchase_reclamation', to => 'sales_reclamation', abbr => 'prsr', },
|
|
258 |
{ from => SALES_RECLAMATION_TYPE(), to => SALES_RECLAMATION_TYPE(), abbr => 'srsr', },
|
|
259 |
{ from => PURCHASE_RECLAMATION_TYPE(), to => PURCHASE_RECLAMATION_TYPE(), abbr => 'prpr', },
|
|
260 |
{ from => SALES_RECLAMATION_TYPE(), to => PURCHASE_RECLAMATION_TYPE(), abbr => 'srpr', },
|
|
261 |
{ from => PURCHASE_RECLAMATION_TYPE(), to => SALES_RECLAMATION_TYPE(), abbr => 'prsr', },
|
|
260 | 262 |
#Order |
261 |
{ from => 'sales_order', to => 'sales_reclamation', abbr => 'sosr', },
|
|
262 |
{ from => 'purchase_order', to => 'purchase_reclamation', abbr => 'popr', },
|
|
263 |
{ from => SALES_ORDER_TYPE(), to => SALES_RECLAMATION_TYPE(), abbr => 'sosr', },
|
|
264 |
{ from => PURCHASE_ORDER_TYPE(), to => PURCHASE_RECLAMATION_TYPE(), abbr => 'popr', },
|
|
263 | 265 |
#Delivery Order |
264 |
{ from => 'sales_delivery_order', to => 'sales_reclamation', abbr => 'sdsr', },
|
|
265 |
{ from => 'purchase_delivery_order', to => 'purchase_reclamation', abbr => 'pdpr', },
|
|
266 |
{ from => SALES_DELIVERY_ORDER_TYPE(), to => SALES_RECLAMATION_TYPE(), abbr => 'sdsr', },
|
|
267 |
{ from => PURCHASE_DELIVERY_ORDER_TYPE(), to => PURCHASE_RECLAMATION_TYPE(), abbr => 'pdpr', },
|
|
266 | 268 |
#Invoice |
267 |
{ from => 'invoice', to => 'sales_reclamation', abbr => 'sisr', },
|
|
268 |
{ from => 'purchase_invoice', to => 'purchase_reclamation', abbr => 'pipr', },
|
|
269 |
{ from => 'invoice', to => SALES_RECLAMATION_TYPE(), abbr => 'sisr', },
|
|
270 |
{ from => 'purchase_invoice', to => PURCHASE_RECLAMATION_TYPE(), abbr => 'pipr', },
|
|
269 | 271 |
); |
270 | 272 |
my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0]; |
271 | 273 |
if (!$from_to) { |
SL/Model/Record.pm | ||
---|---|---|
14 | 14 |
use SL::DB::Status; |
15 | 15 |
use SL::DB::ValidityToken; |
16 | 16 |
use SL::DB::Helper::TypeDataProxy; |
17 |
use SL::DB::Order::TypeData qw(:types); |
|
18 |
use SL::DB::DeliveryOrder::TypeData qw(:types); |
|
19 |
use SL::DB::Reclamation::TypeData qw(:types); |
|
17 | 20 |
|
18 | 21 |
use SL::Util qw(trim); |
19 | 22 |
use SL::Locale::String qw(t8); |
... | ... | |
63 | 66 |
|
64 | 67 |
my %subtype_to_type = ( |
65 | 68 |
# Order |
66 |
"request_quotation" => "SL::DB::Order",
|
|
67 |
"purchase_order" => "SL::DB::Order",
|
|
68 |
"sales_quotation" => "SL::DB::Order",
|
|
69 |
"sales_order" => "SL::DB::Order",
|
|
69 |
REQUEST_QUOTATION_TYPE() => "SL::DB::Order",
|
|
70 |
PURCHASE_ORDER_TYPE() => "SL::DB::Order",
|
|
71 |
SALES_QUOTATION_TYPE() => "SL::DB::Order",
|
|
72 |
SALES_ORDER_TYPE() => "SL::DB::Order",
|
|
70 | 73 |
# DeliveryOrder |
71 |
"sales_delivery_order" => "SL::DB::DeliveryOrder",
|
|
72 |
"purchase_delivery_order" => "SL::DB::DeliveryOrder",
|
|
73 |
"rma_delivery_order" => "SL::DB::DeliveryOrder",
|
|
74 |
"supplier_delivery_order" => "SL::DB::DeliveryOrder",
|
|
74 |
SALES_DELIVERY_ORDER_TYPE() => "SL::DB::DeliveryOrder",
|
|
75 |
PURCHASE_DELIVERY_ORDER_TYPE() => "SL::DB::DeliveryOrder",
|
|
76 |
RMA_DELIVERY_ORDER_TYPE() => "SL::DB::DeliveryOrder",
|
|
77 |
SUPPLIER_DELIVERY_ORDER_TYPE() => "SL::DB::DeliveryOrder",
|
|
75 | 78 |
# Reclamation |
76 |
"sales_reclamation" => "SL::DB::Reclamation",
|
|
77 |
"purchase_reclamation" => "SL::DB::Reclamation",
|
|
79 |
SALES_RECLAMATION_TYPE() => "SL::DB::Reclamation",
|
|
80 |
PURCHASE_RECLAMATION_TYPE() => "SL::DB::Reclamation",
|
|
78 | 81 |
); |
79 | 82 |
my $target_type = $subtype_to_type{$target_subtype}; |
80 | 83 |
unless ($target_type) { |
... | ... | |
102 | 105 |
|
103 | 106 |
my %subtype_to_type = ( |
104 | 107 |
# Order |
105 |
"sales_order" => "SL::DB::Order",
|
|
108 |
SALES_ORDER_TYPE() => "SL::DB::Order",
|
|
106 | 109 |
); |
107 | 110 |
my $target_type = $subtype_to_type{$target_subtype}; |
108 | 111 |
unless ($target_type) { |
Auch abrufbar als: Unified diff
TypeData: nutzte Konstanten anstatt String für Typen