0650e08b355d3bd67464804e3a5fe76fb60e05f7
[kivitendo-erp.git] / SL / Controller / DeliveryOrder / TypeData.pm
1 package SL::Controller::DeliveryOrder::TypeData;
2
3 use strict;
4 use Exporter qw(import);
5 use Scalar::Util qw(weaken);
6 use SL::Locale::String qw(t8);
7 use SL::DB::DeliveryOrder::TypeData qw(:types :subs);
8
9 my @export_types = qw(SALES_DELIVERY_ORDER_TYPE PURCHASE_DELIVERY_ORDER_TYPE SUPPLIER_DELIVERY_ORDER_TYPE RMA_DELIVERY_ORDER_TYPE);
10
11 our @EXPORT_OK = (@export_types);
12 our %EXPORT_TAGS = (types => \@export_types);
13
14 use Rose::Object::MakeMethods::Generic scalar => [ qw(c) ];
15
16 sub new {
17   my ($class, $controller) = @_;
18   my $o = bless {}, $class;
19
20   if ($controller) {
21     $o->c($controller);
22     weaken($o->{c});
23   }
24
25   return $o;
26 }
27
28 sub validate {
29   my ($self, $string) = @_;
30   validate_type($string);
31 }
32
33 sub text {
34   my ($self, $string) = @_;
35   get3($self->c->type, "text", $string);
36 }
37
38 sub show_menu {
39   my ($self, $string) = @_;
40   get3($self->c->type, "show_menu", $string);
41 }
42
43 sub workflow {
44   my ($self, $string) = @_;
45   get3($self->c->type, "workflow", $string);
46 }
47
48 sub properties {
49   my ($self, $string) = @_;
50   get3($self->c->type, "properties", $string);
51 }
52
53 sub access {
54   my ($self, $string) = @_;
55   get3($_[0]->c->type, "rights", $string);
56 }
57
58 sub is_quotation {
59   get3($_[0]->c->type, "properties", "is_quotation");
60 }
61
62 sub customervendor {
63   get3($_[0]->c->type, "properties", "customervendor");
64 }
65
66 sub is_customer {
67   get3($_[0]->c->type, "properties", "is_customer");
68 }
69
70 sub nr_key {
71   get3($_[0]->c->type, "properties", "nr_key");
72 }
73
74 sub transfer {
75   get3($_[0]->c->type, "properties", "transfer");
76 }
77
78 sub part_classification_query {
79   my ($self, $string) = @_;
80   get($self->c->type, "part_classification_query");
81 }
82
83 sub set_reqdate_by_type {
84   my ($self) = @_;
85
86   if (!$self->c->order->reqdate) {
87     $self->c->order->reqdate(DateTime->today_local->next_workday(extra_days => 1));
88   }
89 }
90
91 sub get_reqdate_by_type {
92   my ($self, $reqdate, $saved_reqdate) = @_;
93
94   if ($reqdate == $saved_reqdate) {
95     return DateTime->today_local->next_workday(extra_days => 1);
96   } else {
97     return $reqdate;
98   }
99 }
100
101 1;