4aa29251d051300d2225cd6805aad4a6990a2f01
[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   get($_[0]->c->type, "right");
55 }
56
57 sub is_quotation {
58   get3($_[0]->c->type, "properties", "is_quotation");
59 }
60
61 sub customervendor {
62   get3($_[0]->c->type, "properties", "customervendor");
63 }
64
65 sub is_customer {
66   get3($_[0]->c->type, "properties", "is_customer");
67 }
68
69 sub nr_key {
70   get3($_[0]->c->type, "properties", "nr_key");
71 }
72
73 sub transfer {
74   get3($_[0]->c->type, "properties", "transfer");
75 }
76
77 sub part_classification_query {
78   my ($self, $string) = @_;
79   get($self->c->type, "part_classification_query");
80 }
81
82 sub set_reqdate_by_type {
83   my ($self) = @_;
84
85   if (!$self->c->order->reqdate) {
86     $self->c->order->reqdate(DateTime->today_local->next_workday(extra_days => 1));
87   }
88 }
89
90 sub get_reqdate_by_type {
91   my ($self, $reqdate, $saved_reqdate) = @_;
92
93   if ($reqdate == $saved_reqdate) {
94     return DateTime->today_local->next_workday(extra_days => 1);
95   } else {
96     return $reqdate;
97   }
98 }
99
100 1;