1 package SL::DB::Letter;
5 use SL::DB::Helper::AttrHTML;
6 use SL::DB::Helper::LinkedRecords;
7 use SL::DB::MetaSetup::Letter;
8 use SL::DB::Manager::Letter;
10 __PACKAGE__->meta->initialize;
12 __PACKAGE__->attr_html('body');
15 my ($class, $draft) = @_;
17 my $self = $class->new;
20 require SL::DB::LetterDraft;
21 $draft = SL::DB::LetterDraft->new(id => $draft)->load;
24 $self->assign_attributes(map { $_ => $draft->$_ } $draft->meta->columns);
32 die 'not an accessor' if @_ > 1;
33 $_[0]{customer_id} * 1;
36 sub has_customer_vendor {
38 die 'not an accessor' if @_ > 1;
40 return $self->is_sales
41 ? ($self->customer_id && $self->customer)
42 : ($self->vendor_id && $self->vendor);
46 die 'not an accessor' if @_ > 1;
47 $_[0]->is_sales ? $_[0]->customer : $_[0]->vendor;
50 sub customer_vendor_id {
51 die 'not an accessor' if @_ > 1;
52 $_[0]->customer_id || $_[0]->vendor_id;