use SL::DB::Invoice;
use SL::DB::Part;
use SL::DB::Unit;
+use SL::DB::TaxZone;
-my ($customer, $currency_id, @parts, $buchungsgruppe, $buchungsgruppe7, $unit, $employee, $tax, $tax7);
+my ($customer, $currency_id, @parts, $buchungsgruppe, $buchungsgruppe7, $unit, $employee, $tax, $tax7, $taxzone);
sub reset_state {
my %params = @_;
$employee = SL::DB::Manager::Employee->current || croak "No employee";
$tax = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, %{ $params{tax} }) || croak "No tax";
$tax7 = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07) || croak "No tax for 7\%";
+ $taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone";
$currency_id = $::instance_conf->get_currency_id;
$customer = SL::DB::Customer->new(
name => 'Test Customer',
currency_id => $currency_id,
+ taxzone_id => $taxzone->id,
%{ $params{customer} }
)->save;
employee_id => $employee->id,
salesman_id => $employee->id,
gldate => DateTime->today_local->to_kivitendo,
- taxzone_id => 0,
+ taxzone_id => $taxzone->id,
transdate => DateTime->today_local->to_kivitendo,
invoice => 1,
type => 'invoice',
is($invoice->marge_percent, 17.4358974358974, "${title}: marge_percent");
is_deeply(\%data, {
- allocated => {},
- amounts => {
- $buchungsgruppe->income_accno_id_0 => {
- amount => 5.85,
- tax_id => $tax->id,
- taxkey => 3,
+ allocated => {},
+ amounts => {
+ $buchungsgruppe->income_accno_id($taxzone) => {
+ amount => 5.85,
+ tax_id => $tax->id,
+ taxkey => 3,
},
},
- amounts_cogs => {},
- assembly_items => [
+ amounts_cogs => {},
+ assembly_items => [
[],
],
- exchangerate => 1,
- taxes => {
- $tax->chart_id => 1.11,
+ exchangerate => 1,
+ taxes => {
+ $tax->chart_id => 1.11,
},
}, "${title}: calculated data");
}
is($invoice->marge_percent, 34.8943460879497, "${title}: marge_percent");
is_deeply(\%data, {
- allocated => {},
- amounts => {
- $buchungsgruppe->income_accno_id_0 => {
- amount => 5.85,
- tax_id => $tax->id,
- taxkey => 3,
+ allocated => {},
+ amounts => {
+ $buchungsgruppe->income_accno_id($taxzone) => {
+ amount => 5.85,
+ tax_id => $tax->id,
+ taxkey => 3,
},
- $buchungsgruppe7->income_accno_id_0 => {
- amount => 11.66,
- tax_id => $tax7->id,
- taxkey => 2,
+ $buchungsgruppe7->income_accno_id($taxzone) => {
+ amount => 11.66,
+ tax_id => $tax7->id,
+ taxkey => 2,
},
},
- amounts_cogs => {},
- assembly_items => [
+ amounts_cogs => {},
+ assembly_items => [
[], [],
],
- exchangerate => 1,
- taxes => {
- $tax->chart_id => 1.11,
- $tax7->chart_id => 0.82,
+ exchangerate => 1,
+ taxes => {
+ $tax->chart_id => 1.11,
+ $tax7->chart_id => 0.82,
},
}, "${title}: calculated data");
}
is($invoice->marge_percent, 62.007874015748, "${title}: marge_percent");
is_deeply(\%data, {
- allocated => {},
- amounts => {
- $buchungsgruppe->income_accno_id_0 => {
- amount => 15.24,
- tax_id => $tax->id,
- taxkey => 3,
+ allocated => {},
+ amounts => {
+ $buchungsgruppe->income_accno_id($taxzone) => {
+ amount => 15.24,
+ tax_id => $tax->id,
+ taxkey => 3,
},
},
- amounts_cogs => {},
- assembly_items => [
+ amounts_cogs => {},
+ assembly_items => [
[], [], [],
],
- exchangerate => 1,
- taxes => {
- $tax->chart_id => 2.9,
+ exchangerate => 1,
+ taxes => {
+ $tax->chart_id => 2.9,
},
}, "${title}: calculated data");
}