Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 25112bf2

Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt

  • ID 25112bf209b20ce4d085acaa9cf208cfff42df3c
  • Vorgänger ef7e9ebd
  • Nachfolger 0ff29f06

t/controllers/financial_overview/sales_orders.t auf SL::Dev umgestellt

Unterschiede anzeigen:

t/controllers/financial_overview/sales_orders.t
14 14

  
15 15
package main;
16 16

  
17
use Test::More tests => 49;
17
use Test::More tests => 43;
18 18

  
19 19
use lib 't';
20 20
use strict;
......
22 22

  
23 23
use Carp;
24 24
use Support::TestSetup;
25
use SL::Dev::ALL;
25 26

  
26 27
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
27 28
use_ok 'SL::Controller::FinancialOverview';
......
31 32
use_ok 'SL::DB::Invoice';
32 33
use_ok 'SL::DB::Order';
33 34
use_ok 'SL::DB::Part';
34
use_ok 'SL::DB::TaxZone';
35 35

  
36 36
Support::TestSetup::login();
37 37

  
38
our ($ar_chart, $buchungsgruppe, $ctrl, $currency_id, $customer, $employee, $order, $part, $tax_zone, $unit, @invoices);
38
our ($ar_chart, $ctrl, $customer, $order, $part, $unit, @invoices);
39 39

  
40 40
sub clear_up {
41 41
  "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part);
42 42
};
43 43

  
44 44
sub init_common_state {
45
  $ar_chart       = SL::DB::Manager::Chart->find_by(accno => '1400')                        || croak "No AR chart";
46
  $buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group";
47
  $currency_id    = SL::DB::Default->get->currency_id;
48
  $employee       = SL::DB::Manager::Employee->current                                      || croak "No employee";
49
  $tax_zone       = SL::DB::Manager::TaxZone->find_by( description => 'Inland')             || croak "No taxzone";
50
  $unit           = SL::DB::Manager::Unit->find_by(name => 'psch')                          || croak "No unit";
45
  $ar_chart       = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart";
46
  $unit           = SL::DB::Manager::Unit->find_by(name => 'psch')   || croak "No unit";
51 47
}
52 48

  
53 49
sub create_sales_order {
54 50
  my %params = @_;
55 51

  
56
  $params{$_} ||= {} for qw(customer part tax order orderitem);
52
  $params{$_} ||= {} for qw(customer part order orderitem);
57 53

  
58 54
  # Clean up: remove invoices, orders, parts and customers
59 55
  clear_up();
60 56

  
61
  $customer     = SL::DB::Customer->new(
57
  $customer     = SL::Dev::CustomerVendor::create_customer(
62 58
    name        => 'Test Customer',
63
    currency_id => $currency_id,
64
    taxzone_id  => $tax_zone->id,
65 59
    %{ $params{customer} }
66 60
  )->save;
67 61

  
68
  $part = SL::DB::Part->new(
62
  $part = SL::Dev::Part::create_part(
69 63
    partnumber         => 'T4254',
70 64
    description        => 'Fourty-two fifty-four',
71 65
    lastcost           => 222.22,
72 66
    sellprice          => 333.33,
73
    part_type          => 'part',
74
    buchungsgruppen_id => $buchungsgruppe->id,
75
    unit               => $unit->name,
76 67
    %{ $params{part} }
77 68
  )->save;
78 69
  $part->load;
79 70

  
80
  $order                     = SL::DB::Order->new(
81
    customer_id              => $customer->id,
82
    currency_id              => $currency_id,
83
    taxzone_id               => $tax_zone->id,
71
  $order                     = SL::Dev::Record::create_sales_order(
72
    save                     => 1,
73
    customer                 => $customer,
84 74
    transaction_description  => '<%period_start_date%>',
85 75
    transdate                => DateTime->from_kivitendo('01.03.2014'),
86
    orderitems               => [
87
      { parts_id             => $part->id,
88
        description          => $part->description,
89
        lastcost             => $part->lastcost,
90
        sellprice            => $part->sellprice,
91
        qty                  => 1,
92
        unit                 => $unit->name,
93
        %{ $params{orderitem} },
94
      },
95
    ],
76
    orderitems => [ SL::Dev::Record::create_order_item(part => $part, qty =>  1, %{ $params{orderitem} }) ],
96 77
    periodic_invoices_config => $params{periodic_invoices_config} ? {
97 78
      active                 => 1,
98 79
      ar_chart_id            => $ar_chart->id,
......
101 82
    %{ $params{order} },
102 83
  );
103 84

  
104
  $order->calculate_prices_and_taxes;
105

  
106
  ok($order->save(cascade => 1));
107

  
108 85
  $::form         = Support::TestSetup->create_new_form;
109 86
  $::form->{year} = 2014;
110 87
  $ctrl           = SL::Controller::FinancialOverview->new;

Auch abrufbar als: Unified diff