Revision 3e6dc4aa
Von Kivitendo Admin vor etwa 1 Jahr hinzugefügt
SL/Dev/Record.pm | ||
---|---|---|
18 | 18 |
create_credit_note |
19 | 19 |
create_sales_reclamation |
20 | 20 |
|
21 |
create_purchase_quotation |
|
21 | 22 |
create_purchase_order |
22 | 23 |
create_purchase_delivery_order |
23 | 24 |
create_minimal_purchase_invoice |
... | ... | |
50 | 51 |
credit_note => 'SL::DB::InvoiceItem', |
51 | 52 |
sales_order => 'SL::DB::OrderItem', |
52 | 53 |
sales_quotation => 'SL::DB::OrderItem', |
54 |
purchase_quotation => 'SL::DB::OrderItem', |
|
53 | 55 |
purchase_order => 'SL::DB::OrderItem', |
54 | 56 |
sales_delivery_order => 'SL::DB::DeliveryOrderItem', |
55 | 57 |
purchase_delivery_order => 'SL::DB::DeliveryOrderItem', |
... | ... | |
223 | 225 |
_create_sales_order_or_quotation(%params); |
224 | 226 |
} |
225 | 227 |
|
226 |
sub create_purchase_order {
|
|
228 |
sub create_purchase_quotation {
|
|
227 | 229 |
my (%params) = @_; |
230 |
$params{type} = 'purchase_quotation'; |
|
231 |
# TODO: set a with reqdate |
|
232 |
_create_purchase_order_or_quotation(%params); |
|
233 |
} |
|
228 | 234 |
|
229 |
my $record_type = 'purchase_order'; |
|
230 |
my $orderitems = delete $params{orderitems} // _create_two_items($record_type); |
|
231 |
_check_items($orderitems, $record_type); |
|
232 |
|
|
233 |
my $save = delete $params{save} // 0; |
|
234 |
|
|
235 |
my $vendor = $params{vendor} // new_vendor(name => 'Testvendor')->save; |
|
236 |
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor'; |
|
237 |
|
|
238 |
my $order = SL::DB::Order->new( |
|
239 |
vendor_id => delete $params{vendor_id} // $vendor->id, |
|
240 |
taxzone_id => delete $params{taxzone_id} // $vendor->taxzone->id, |
|
241 |
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id, |
|
242 |
taxincluded => delete $params{taxincluded} // 0, |
|
243 |
transdate => delete $params{transdate} // DateTime->today, |
|
244 |
'closed' => undef, |
|
245 |
orderitems => $orderitems, |
|
246 |
); |
|
247 |
$order->assign_attributes(%params) if %params; |
|
248 |
|
|
249 |
if ( $save ) { |
|
250 |
$order->calculate_prices_and_taxes; # not tested for purchase orders |
|
251 |
$order->save; |
|
252 |
} |
|
253 |
return $order; |
|
254 |
}; |
|
235 |
sub create_purchase_order { |
|
236 |
my (%params) = @_; |
|
237 |
$params{type} = 'purchase_order'; |
|
238 |
_create_purchase_order_or_quotation(%params); |
|
239 |
} |
|
255 | 240 |
|
256 | 241 |
sub create_sales_reclamation { |
257 | 242 |
my (%params) = @_; |
... | ... | |
783 | 768 |
return $record; |
784 | 769 |
} |
785 | 770 |
|
771 |
sub _create_purchase_order_or_quotation { |
|
772 |
my (%params) = @_; |
|
773 |
|
|
774 |
my $record_type = $params{type}; |
|
775 |
die "illegal type" unless $record_type eq 'purchase_order' or $record_type eq 'purchase_quotation'; |
|
776 |
my $orderitems = delete $params{orderitems} // _create_two_items($record_type); |
|
777 |
_check_items($orderitems, $record_type); |
|
778 |
|
|
779 |
my $save = delete $params{save} // 0; |
|
780 |
|
|
781 |
my $vendor = $params{vendor} // new_vendor(name => 'Testvendor')->save; |
|
782 |
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor'; |
|
783 |
|
|
784 |
my $record = SL::DB::Order->new( |
|
785 |
vendor_id => delete $params{vendor_id} // $vendor->id, |
|
786 |
taxzone_id => delete $params{taxzone_id} // $vendor->taxzone->id, |
|
787 |
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id, |
|
788 |
taxincluded => delete $params{taxincluded} // 0, |
|
789 |
transdate => delete $params{transdate} // DateTime->today, |
|
790 |
'closed' => undef, |
|
791 |
quotation => $record_type eq 'purchase_quotation' ? 1 : 0, |
|
792 |
orderitems => $orderitems, |
|
793 |
); |
|
794 |
$record->assign_attributes(%params) if %params; |
|
795 |
|
|
796 |
if ( $save ) { |
|
797 |
$record->calculate_prices_and_taxes; # not tested for purchase orders |
|
798 |
$record->save; |
|
799 |
} |
|
800 |
return $record; |
|
801 |
}; |
|
786 | 802 |
|
787 | 803 |
sub _transaction_tax_helper { |
788 | 804 |
# checks for hash-entries with key tax, tax_id or taxkey |
... | ... | |
937 | 953 |
|
938 | 954 |
See C<create_sales_order> |
939 | 955 |
|
956 |
=head2 C<create_purchase_quotation %PARAMS> |
|
957 |
|
|
958 |
See comments for C<create_sales_quotation>. |
|
959 |
|
|
960 |
Example: |
|
961 |
|
|
962 |
my $purchase_quotation = SL::Dev::Record::create_purchase_quotation(save => 1); |
|
963 |
|
|
940 | 964 |
=head2 C<create_purchase_order %PARAMS> |
941 | 965 |
|
942 | 966 |
See comments for C<create_sales_order>. |
... | ... | |
945 | 969 |
|
946 | 970 |
my $purchase_order = SL::Dev::Record::create_purchase_order(save => 1); |
947 | 971 |
|
948 |
|
|
949 | 972 |
=head2 C<create_item %PARAMS> |
950 | 973 |
|
951 | 974 |
Creates an item from a part object that can be added to a record. |
Auch abrufbar als: Unified diff
SL::Dev::Record - Preisanfragen erstellen per create_purchase_quotation