Skip to content

Commit

Permalink
- Corrected capitalization
Browse files Browse the repository at this point in the history
Signed-off-by: objecttothis <[email protected]>
  • Loading branch information
objecttothis committed May 14, 2024
1 parent 50d9117 commit bfbccc9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/Models/Sale.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function get_info(int $sale_id): ResultInterface
$this->create_temp_table (['sale_id' => $sale_id]);

$decimals = totals_decimals();
$sales_tax = 'IFnull(SUM(sales_items_taxes.sales_tax), 0)';
$cash_adjustment = 'IFnull(SUM(payments.sale_cash_adjustment), 0)';
$sales_tax = 'IFNULL(SUM(sales_items_taxes.sales_tax), 0)';
$cash_adjustment = 'IFNULL(SUM(payments.sale_cash_adjustment), 0)';
$sale_price = 'CASE WHEN sales_items.discount_type = ' . PERCENT
. " THEN sales_items.quantity_purchased * sales_items.item_unit_price - ROUND(sales_items.quantity_purchased * sales_items.item_unit_price * sales_items.discount / 100, $decimals) "
. 'ELSE sales_items.quantity_purchased * (sales_items.item_unit_price - sales_items.discount) END';
Expand Down Expand Up @@ -136,10 +136,10 @@ public function search(string $search, array $filters, ?int $rows = 0, ?int $lim

$sale_cost = 'SUM(`sales_items`.`item_cost_price` * `sales_items`.`quantity_purchased`)';

$tax = 'IFnull(SUM(`sales_items_taxes`.`tax`), 0)';
$sales_tax = 'IFnull(SUM(`sales_items_taxes`.`sales_tax`), 0)';
$internal_tax = 'IFnull(SUM(`sales_items_taxes`.`internal_tax`), 0)';
$cash_adjustment = 'IFnull(SUM(`payments`.`sale_cash_adjustment`), 0)';
$tax = 'IFNULL(SUM(`sales_items_taxes`.`tax`), 0)';
$sales_tax = 'IFNULL(SUM(`sales_items_taxes`.`sales_tax`), 0)';
$internal_tax = 'IFNULL(SUM(`sales_items_taxes`.`internal_tax`), 0)';
$cash_adjustment = 'IFNULL(SUM(`payments`.`sale_cash_adjustment`), 0)';

$sale_subtotal = "ROUND(SUM($sale_price), $decimals) - $internal_tax";
$sale_total = "ROUND(SUM($sale_price), $decimals) + $sales_tax + $cash_adjustment";
Expand Down Expand Up @@ -1489,6 +1489,7 @@ private function create_temp_table_sales_payments_data(string $where): void
$builder->groupBy('payments.sale_id');

$sub_query = $builder->getCompiledSelect();
log_message('error', $sub_query);

$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS '
. $this->db->prefixTable('sales_payments_temp')
Expand Down

0 comments on commit bfbccc9

Please sign in to comment.