Revision 9071cd97
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
| SL/DB/Manager/Order.pm | ||
|---|---|---|
|
|
||
|
use parent qw(SL::DB::Helper::Manager);
|
||
|
|
||
|
use SL::DB::Order::TypeData qw(:types);
|
||
|
use SL::DB::Helper::Paginated;
|
||
|
use SL::DB::Helper::Sorted;
|
||
|
use SL::DB::Helper::Filtered;
|
||
|
|
||
|
use List::MoreUtils qw(any);
|
||
|
|
||
|
sub object_class { 'SL::DB::Order' }
|
||
|
|
||
|
__PACKAGE__->make_manager_methods;
|
||
| ... | ... | |
|
my $type = lc(shift || '');
|
||
|
my $prefix = shift || '';
|
||
|
|
||
|
return (and => [ "!${prefix}customer_id" => undef, "${prefix}quotation" => 1 ]) if $type eq 'sales_quotation';
|
||
|
return (and => [ "!${prefix}vendor_id" => undef, "${prefix}quotation" => 1, "${prefix}intake" => 0 ]) if $type eq 'request_quotation';
|
||
|
return (and => [ "!${prefix}customer_id" => undef, "${prefix}intake" => 1 ]) if $type eq 'sales_order_intake';
|
||
|
return (and => [ "!${prefix}vendor_id" => undef, "${prefix}intake" => 1, "${prefix}quotation" => 1 ]) if $type eq 'purchase_quotation_intake';
|
||
|
return (and => [ "!${prefix}customer_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ], "${prefix}intake" => 0 ]) if $type eq 'sales_order';
|
||
|
return (and => [ "!${prefix}vendor_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'purchase_order';
|
||
|
return ("${prefix}record_type" => $type) if( any {$type eq $_} (
|
||
|
SALES_ORDER_INTAKE_TYPE(),
|
||
|
SALES_ORDER_TYPE(),
|
||
|
SALES_QUOTATION_TYPE(),
|
||
|
PURCHASE_ORDER_TYPE(),
|
||
|
REQUEST_QUOTATION_TYPE(),
|
||
|
PURCHASE_QUOTATION_INTAKE_TYPE(),
|
||
|
));
|
||
|
|
||
|
die "Unknown type $type";
|
||
|
}
|
||
| SL/DB/Order.pm | ||
|---|---|---|
|
# least an empty string, even if we're saving a quotation.
|
||
|
$self->ordnumber('') if !$self->ordnumber;
|
||
|
|
||
|
my $field = $self->quotation ? 'quonumber' : 'ordnumber';
|
||
|
$self->create_trans_number if !$self->$field;
|
||
|
$self->create_trans_number if !$self->record_number;
|
||
|
|
||
|
return 1;
|
||
|
}
|
||
| ... | ... | |
|
return shift->type eq shift;
|
||
|
}
|
||
|
|
||
|
sub quotation {
|
||
|
my $type = shift->type();
|
||
|
if (any { $type eq $_ } (
|
||
|
SALES_ORDER_INTAKE_TYPE(),
|
||
|
SALES_QUOTATION_TYPE(),
|
||
|
REQUEST_QUOTATION_TYPE(),
|
||
|
PURCHASE_QUOTATION_INTAKE_TYPE(),
|
||
|
)) {
|
||
|
return 1;
|
||
|
};
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
sub intake {
|
||
|
my $type = shift->type();
|
||
|
if (any { $type eq $_ } (
|
||
|
SALES_ORDER_INTAKE_TYPE(),
|
||
|
PURCHASE_QUOTATION_INTAKE_TYPE(),
|
||
|
)) {
|
||
|
return 1;
|
||
|
};
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
sub deliverydate {
|
||
|
# oe doesn't have deliverydate, but it does have reqdate.
|
||
|
# But this has a different meaning for sales quotations.
|
||
| ... | ... | |
|
ordnumber payment_id quonumber reqdate salesman_id shippingpoint shipvia taxincluded tax_point taxzone_id
|
||
|
transaction_description vendor_id billing_address_id
|
||
|
)),
|
||
|
quotation => !!(($destination_type =~ m{quotation$}) || ($destination_type eq 'purchase_quotation_intake')),
|
||
|
intake => !!($destination_type =~ m{intake$}),
|
||
|
closed => 0,
|
||
|
delivered => 0,
|
||
|
transdate => DateTime->today_local,
|
||
Auch abrufbar als: Unified diff
DB::Order: Funktionen angepasst (kein Angebotsflag/Intakeflag)