units_by_name => \%units_by_name,
price_factors_by_id => \%price_factors_by_id,
taxes => { },
+ taxes_by_tax_id => { },
amounts => { },
amounts_cogs => { },
allocated => { },
return $self unless wantarray;
- return map { ($_ => $data{$_}) } qw(taxes amounts amounts_cogs allocated exchangerate assembly_items items rounding);
+ return map { ($_ => $data{$_}) } qw(taxes taxes_by_tax_id amounts amounts_cogs allocated exchangerate assembly_items items rounding);
}
sub _get_exchangerate {
if ($taxkey->tax->chart_id) {
$data->{taxes}->{ $taxkey->tax->chart_id } ||= 0;
$data->{taxes}->{ $taxkey->tax->chart_id } += $tax_amount;
+ $data->{taxes_by_tax_id}->{ $taxkey->tax_id } ||= 0;
+ $data->{taxes_by_tax_id}->{ $taxkey->tax_id } += $tax_amount;
} elsif ($tax_amount) {
die "tax_amount != 0 but no chart_id for taxkey " . $taxkey->id . " tax " . $taxkey->tax->id;
}
A hash reference with the calculated taxes. The keys are chart IDs,
the values the calculated taxes.
+=item C<taxes_by_tax_id>
+
+A hash reference with the calculated taxes. The keys are tax IDs,
+the values the calculated taxes.
+
=item C<amounts>
A hash reference with the calculated amounts. The keys are chart IDs,
taxes => {
$tax->chart_id => 1.11,
},
+ taxes_by_tax_id => {
+ $tax->id => 1.1115,
+ },
items => [
{ linetotal => 5.85,
linetotal_cost => 4.83,
# item 2:
# sellprice 9.714 * qty 1.2 = 11.6568 rounded 11.66
# 7%(11.6568) = 0.815976; rounded = 0.82
+ # 7%(11.66) = 0.8162
# total rounded = 12.48
# lastcost 5.473 * qty 1.2 = 6.5676; rounded 6.57
$tax->chart_id => 1.11,
$tax7->chart_id => 0.82,
},
+ taxes_by_tax_id => {
+ $tax->id => 1.1115,
+ $tax7->id => 0.8162,
+ },
items => [
{ linetotal => 5.85,
linetotal_cost => 4.83,
taxes => {
$tax->chart_id => 2.9,
},
+ taxes_by_tax_id => {
+ $tax->id => 2.89750,
+ },
items => [
{ linetotal => 5.27,
linetotal_cost => 1.93,
taxes => {
$tax->chart_id => 0.66,
},
+ taxes_by_tax_id => {
+ $tax->id => 0.66310,
+ },
items => [
{ linetotal => 3.49,
linetotal_cost => 0,
taxes => {
$tax->chart_id => 1843,
},
+ taxes_by_tax_id => {
+ $tax->id => 1843,
+ },
items => [
{ linetotal => 9700,
linetotal_cost => 0,
taxes => {
$tax->chart_id => 12.84,
},
+ taxes_by_tax_id => {
+ $tax->id => 12.8364,
+ },
items => [
{ linetotal => 67.56,
linetotal_cost => 19301.93,