Fixed tax bug in fix unpaid invoice tax script
Showing
1 changed file
with
6 additions
and
6 deletions
| ... | @@ -26,7 +26,7 @@ if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') { | ... | @@ -26,7 +26,7 @@ if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') { |
| 26 | $max = 1000; | 26 | $max = 1000; |
| 27 | 27 | ||
| 28 | for ($ui = 0; $ui < $num; $ui += $max) { | 28 | for ($ui = 0; $ui < $num; $ui += $max) { |
| 29 | $users = $wpdb->get_results("SELECT ID FROM `{$wpdb->users}` LIMIT {$ui}, {$max}"); | 29 | $users = $wpdb->get_results("SELECT `ID` FROM `{$wpdb->users}` LIMIT {$ui}, {$max}"); |
| 30 | foreach ($users as $user) { | 30 | foreach ($users as $user) { |
| 31 | $invoices = get_user_meta($user->ID, 'invoices', TRUE); | 31 | $invoices = get_user_meta($user->ID, 'invoices', TRUE); |
| 32 | foreach ($invoices as $invoice_id) { | 32 | foreach ($invoices as $invoice_id) { |
| ... | @@ -45,16 +45,16 @@ if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') { | ... | @@ -45,16 +45,16 @@ if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') { |
| 45 | // Here's the heavy work: get the payment data and add appropriate taxes | 45 | // Here's the heavy work: get the payment data and add appropriate taxes |
| 46 | $payment = get_post_meta($invoice_id, 'payment', TRUE); | 46 | $payment = get_post_meta($invoice_id, 'payment', TRUE); |
| 47 | $trans_amount = get_post_meta($invoice_id, 'trans_amount', TRUE); | 47 | $trans_amount = get_post_meta($invoice_id, 'trans_amount', TRUE); |
| 48 | 48 | ||
| 49 | $pp = get_user_meta($user->ID, 'profile_preference', true); | ||
| 49 | // Get the user's profile preference and use it to get the tax percent | 50 | // Get the user's profile preference and use it to get the tax percent |
| 50 | if (! empty($user->profile_preference)) { | 51 | if (!empty($pp)) { |
| 51 | $preference = strtolower($user->profile_preference) . '_province'; | 52 | $preference = strtolower($pp) . '_province'; |
| 52 | $tax_percent = getTaxesByProvince($user->$preference) * .01; | 53 | $tax_percent = getTaxesByProvince(get_user_meta($user->ID, $preference, true)) * .01; |
| 53 | } else { | 54 | } else { |
| 54 | $tax_percent = getTaxesByProvince($payment['bt_province']) * .01; | 55 | $tax_percent = getTaxesByProvince($payment['bt_province']) * .01; |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | |||
| 58 | $payment['total_taxes'] = $payment['total_cost'] * $tax_percent; | 58 | $payment['total_taxes'] = $payment['total_cost'] * $tax_percent; |
| 59 | $payment['total'] = number_format($payment['total_cost'] - $payment['total_discounts'] + $payment['total_taxes'], 2); | 59 | $payment['total'] = number_format($payment['total_cost'] - $payment['total_discounts'] + $payment['total_taxes'], 2); |
| 60 | $trans_amount = $payment['total']; | 60 | $trans_amount = $payment['total']; | ... | ... |
-
Please register or sign in to post a comment