Revision c22f1710
Von Tamino Steinert vor etwa 2 Jahren hinzugefügt
SL/Dev/Record.pm | ||
---|---|---|
37 | 37 |
use SL::DATEV; |
38 | 38 |
|
39 | 39 |
my %record_type_to_item_type = ( sales_invoice => 'SL::DB::InvoiceItem', |
40 |
purchase_invoice => 'SL::DB::InvoiceItem', |
|
40 | 41 |
credit_note => 'SL::DB::InvoiceItem', |
41 | 42 |
sales_order => 'SL::DB::OrderItem', |
42 | 43 |
purchase_order => 'SL::DB::OrderItem', |
... | ... | |
77 | 78 |
return $invoice; |
78 | 79 |
} |
79 | 80 |
|
81 |
sub create_purchase_invoice { |
|
82 |
my (%params) = @_; |
|
83 |
|
|
84 |
my $record_type = 'purchase_invoice'; |
|
85 |
my $invoiceitems = delete $params{invoiceitems} // _create_two_items($record_type); |
|
86 |
_check_items($invoiceitems, $record_type); |
|
87 |
|
|
88 |
my $vendor = delete $params{vendor} // new_vendor(name => 'Testvendor')->save; |
|
89 |
die "illegal vendor" unless defined $vendor && ref($vendor) eq 'SL::DB::Vendor'; |
|
90 |
|
|
91 |
my $invoice = SL::DB::PurchaseInvoice->new( |
|
92 |
invoice => 1, |
|
93 |
type => 'purchase_invoice', |
|
94 |
vendor => $vendor->id, |
|
95 |
taxzone_id => $vendor->taxzone->id, |
|
96 |
invnumber => delete $params{invnumber} // undef, |
|
97 |
currency_id => $params{currency_id} // $::instance_conf->get_currency_id, |
|
98 |
taxincluded => $params{taxincluded} // 0, |
|
99 |
employee_id => $params{employee_id} // SL::DB::Manager::Employee->current->id, |
|
100 |
transdate => $params{transdate} // DateTime->today_local->to_kivitendo, |
|
101 |
payment_id => $params{payment_id} // undef, |
|
102 |
gldate => DateTime->today, |
|
103 |
invoiceitems => $invoiceitems, |
|
104 |
); |
|
105 |
$invoice->assign_attributes(%params) if %params; |
|
106 |
|
|
107 |
$invoice->save; |
|
108 |
return $invoice; |
|
109 |
} |
|
110 |
|
|
80 | 111 |
sub create_credit_note { |
81 | 112 |
my (%params) = @_; |
82 | 113 |
|
... | ... | |
147 | 178 |
_check_items($orderitems, $record_type); |
148 | 179 |
|
149 | 180 |
my $vendor = $params{vendor} // new_vendor(name => 'Testvendor')->save; |
150 |
die "illegal customer" unless ref($vendor) eq 'SL::DB::Vendor';
|
|
181 |
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor';
|
|
151 | 182 |
|
152 | 183 |
my $delivery_order = SL::DB::DeliveryOrder->new( |
153 | 184 |
order_type => PURCHASE_DELIVERY_ORDER_TYPE, |
Auch abrufbar als: Unified diff
Reclamation: Test for workflow invoice_to_reclamation