Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e79aba17

Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt

  • ID e79aba176da8cdbde2c74253b1709e70f338ab14
  • Vorgänger b5eae4e1
  • Nachfolger 503fabbf

create_periodic_invoices.t - Umstellung auf SL/Dev und Partname

Unterschiede anzeigen:

t/background_job/create_periodic_invoices.t
14 14

  
15 15
package main;
16 16

  
17
use Test::More tests => 80;
17
use Test::More tests => 56;
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::DB::Chart';
......
34 35

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

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

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

  
48 45
sub clear_up {
......
57 54
  # Clean up: remove invoices, orders, parts and customers
58 55
  clear_up();
59 56

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

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

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

  
102
  $order->calculate_prices_and_taxes;
103

  
104
  ok($order->save(cascade => 1));
105

  
106 91
  SL::BackgroundJob::CreatePeriodicInvoices->new->run(SL::DB::BackgroundJob->new);
107 92

  
108 93
  @invoices = @{ SL::DB::Manager::Invoice->get_all(sort_by => [ qw(id) ]) };

Auch abrufbar als: Unified diff