Fix tax_code in the report export for removed rates (#51395)

This commit is contained in:
Tomek Wytrębowicz 2024-09-16 15:59:18 +02:00 committed by GitHub
parent a89bd1a485
commit 450a299bae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Improve performance of tax report export generation and fix tax_code for removed rates.

View File

@ -244,7 +244,15 @@ class Controller extends GenericController implements ExportableInterface {
*/ */
public function prepare_item_for_export( $item ) { public function prepare_item_for_export( $item ) {
return array( return array(
'tax_code' => \WC_Tax::get_rate_code( $item['tax_rate_id'] ), 'tax_code' => \WC_Tax::get_rate_code(
(object) array(
'tax_rate_id' => $item['tax_rate_id'],
'tax_rate_country' => $item['country'],
'tax_rate_state' => $item['state'],
'tax_rate_name' => $item['name'],
'tax_rate_priority' => $item['priority'],
)
),
'rate' => $item['tax_rate'], 'rate' => $item['tax_rate'],
'total_tax' => self::csv_number_format( $item['total_tax'] ), 'total_tax' => self::csv_number_format( $item['total_tax'] ),
'order_tax' => self::csv_number_format( $item['order_tax'] ), 'order_tax' => self::csv_number_format( $item['order_tax'] ),