@@ 126-143 (lines=18) @@ | ||
123 | * |
|
124 | * @return $total |
|
125 | */ |
|
126 | public function total($taxGroup = null) |
|
127 | { |
|
128 | if (null === $taxGroup) { |
|
129 | throw new TaxErrorException('You must pass a valid TaxGroup'); |
|
130 | } |
|
131 | ||
132 | $taxGroup = $this->getStoredTaxGroup($taxGroup); |
|
133 | $column = self::priceColumn(); |
|
134 | ||
135 | return $total = $taxGroup->taxManager($this->{$column}) |
|
136 | ->addTaxes( |
|
137 | $taxGroup->taxes->map(function ($tax) { |
|
138 | return $tax->info(); |
|
139 | }) |
|
140 | ->all() |
|
141 | ) |
|
142 | ->total(); |
|
143 | } |
|
144 | ||
145 | /** |
|
146 | * Get a list of taxes with amount calculated for the given TaxGroup. |
|
@@ 152-169 (lines=18) @@ | ||
149 | * |
|
150 | * @return $total |
|
151 | */ |
|
152 | public function getAmounts($taxGroup = null) |
|
153 | { |
|
154 | if (null === $taxGroup) { |
|
155 | throw new TaxErrorException('You must pass a valid TaxGroup'); |
|
156 | } |
|
157 | ||
158 | $taxGroup = $this->getStoredTaxGroup($taxGroup); |
|
159 | $column = self::priceColumn(); |
|
160 | ||
161 | return $taxGroup->taxManager($this->{$column}) |
|
162 | ->addTaxes( |
|
163 | $taxGroup->taxes->map(function ($tax) { |
|
164 | return $tax->info(); |
|
165 | }) |
|
166 | ->all() |
|
167 | ) |
|
168 | ->get(); |
|
169 | } |
|
170 | ||
171 | protected function getStoredTaxGroup($taxGroup): TaxGroup |
|
172 | { |