I scan the first product it comes correct but after that the items donot calculate inline tax
private function getSellLineRowForBarcode($variation_id, $location_id, $quantity, $row_count, $is_direct_sell, $so_line = null) { $business_id = request()->session()->get('user.business_id'); $business_details = $this->businessUtil->getDetails($business_id); $pos_settings = $this->getPosSettings($business_details);
$check_qty = $this->shouldCheckQuantity($pos_settings, $so_line);
$product = $this->getProductDetails($variation_id, $business_id, $location_id, $check_qty, $quantity);
$product = $this->adjustProductPriceForCustomerGroup($product);
$sub_units = $this->productUtil->getSubUnits($business_id, $product->unit_id, false, $product->product_id);
$tax_dropdown = TaxRate::forBusinessDropdown($business_id, true, true);
$enabled_modules = $this->transactionUtil->allModulesEnabled();
$lot_numbers = $this->getLotNumbers($variation_id, $business_id, $location_id);
$output = [];
$output['variation_id'] = $variation_id;
$output['success'] = true;
$output['enable_sr_no'] = $product->enable_sr_no;
$output['html_content'] = $this->generateHtmlContent($product, $row_count, $tax_dropdown, $enabled_modules, $pos_settings, $sub_units);
return $output;
}
private function getPosSettings($business_details) { return empty($business_details->pos_settings) ? $this->businessUtil->defaultPosSettings() : json_decode($business_details->pos_settings, true); }
private function shouldCheckQuantity($pos_settings, $so_line) { $is_sales_order = request()->has('is_sales_order') && request()->input('is_sales_order') == 'true'; $is_draft = request()->has('is_draft') && request()->input('is_draft') == 'true';
if ($is_sales_order || !empty($so_line) || $is_draft) {
return false;
}
return !empty($pos_settings['allow_overselling']);
}
private function getProductDetails($variation_id, $business_id, $location_id, $check_qty, $quantity) { $product = $this->productUtil->getDetailsFromVariation($variation_id, $business_id, $location_id, $check_qty); if (!isset($product->quantity_ordered)) { $product->quantity_ordered = $quantity; } $product->secondary_unit_quantity = isset($product->secondary_unit_quantity) ? $product->secondary_unit_quantity : 0; $product->formatted_qty_available = $this->productUtil->num_f($product->qty_available, false, null, true); return $product; }
private function adjustProductPriceForCustomerGroup($product) { $customer_id = request()->get('customer_id', null); $cg = $this->contactUtil->getCustomerGroup($this->business_id, $customer_id); $percent = (empty($cg) || empty($cg->amount) || $cg->price_calculation_type != 'percentage') ? 0 : $cg->amount;
$product->default_sell_price += $percent * $product->default_sell_price / 100;
$product->sell_price_inc_tax += $percent * $product->sell_price_inc_tax / 100;
return $product;
}
private function getLotNumbers($variation_id, $business_id, $location_id) { $lot_numbers = []; if (request()->session()->get('business.enable_lot_number') == 1 || request()->session()->get('business.enable_product_expiry') == 1) { $lot_number_obj = $this->transactionUtil->getLotNumbersFromVariation($variation_id, $business_id, $location_id, true); foreach ($lot_number_obj as $lot_number) { $lot_number->qty_formated = $this->productUtil->num_f($lot_number->qty_available); $lot_numbers[] = $lot_number; } } return $lot_numbers; }
private function generateHtmlContent($product, $row_count, $tax_dropdown, $enabled_modules, $pos_settings, $sub_units) { $type = request()->get('type');
if ($type == 'sell-return') {
return view('sell_return.partials.product_row')->with(compact('product', 'row_count', 'tax_dropdown', 'enabled_modules', 'sub_units'))->render();
} else {
$price_group = request()->input('price_group');
$is_cg = !empty($cg->id);
$discount = $this->productUtil->getProductDiscount($product, $this->business_id, $this->location_id, $is_cg, $price_group, $variation_id);
$edit_discount = auth()->user()->can('edit_product_discount_from_pos_screen');
$edit_price = auth()->user()->can('edit_product_price_from_pos_screen');
return view('sale_pos.product_row')->with(compact('product', 'row_count', 'tax_dropdown', 'enabled_modules', 'pos_settings', 'sub_units', 'discount', 'edit_discount', 'edit_price'))->render();
}
}
Please or to participate in this conversation.