get_totals (Sale_lib)

ospos · pos, cart-totals, tax-calculation, cash-rounding, payment-summary

Calculates cart sale totals including discounts, taxes, payments, cash rounding, amount due, item count, and units.

	public function get_totals($taxes)
	{
		$totals = array();

		$prediscount_subtotal = 0.0;
		$subtotal = 0.0;
		$total = 0.0;
		$total_discount = 0.0;
		$item_count = 0;
		$total_units = 0.0;

		foreach($this->get_cart() as $item)
		{
			if($item['stock_type'] == HAS_STOCK)
			{
				$item_count++;
				$total_units += $item['quantity'];
			}
			$discount_amount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount'], $item['discount_type']);
			$total_discount = bcadd($total_discount, $discount_amount);

			$extended_amount = $this->get_extended_amount($item['quantity'], $item['price']);
			$extended_discounted_amount = $this->get_extended_amount($item['quantity'], $item['price'], $discount_amount);
			$prediscount_subtotal= bcadd($prediscount_subtotal, $extended_am

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key