Skip to content

Commit

Permalink
Merge branch 'v4.8.x' of https://github.com/blair2004/NexoPOS-4x into…
Browse files Browse the repository at this point in the history
… v4.8.x
  • Loading branch information
Blair2004 committed Aug 12, 2023
2 parents 0892771 + f9e2b27 commit 3373380
Show file tree
Hide file tree
Showing 32 changed files with 12,148 additions and 106 deletions.
3 changes: 3 additions & 0 deletions app/Http/Controllers/Dashboard/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ public function searchUsingArgument( $reference )

if ( $procurementProduct instanceof ProcurementProduct ) {
$product = $procurementProduct->product;
$product->load( 'tax_group.taxes' );

/**
* check if the product has expired
Expand Down Expand Up @@ -588,9 +589,11 @@ public function searchUsingArgument( $reference )

$product = Product::find( $productUnitQuantity->product_id );
$product->load( 'unit_quantities.unit' );
$product->load( 'tax_group.taxes' );
$product->selectedUnitQuantity = $productUnitQuantity;
} elseif ( $product instanceof Product ) {
$product->load( 'unit_quantities.unit' );
$product->load( 'tax_group.taxes' );

if ( $product->accurate_tracking ) {
throw new NotAllowedException( __( 'Unable to add a product that has accurate tracking enabled, using an ordinary barcode.' ) );
Expand Down
7 changes: 5 additions & 2 deletions app/Services/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ private function __computeUnitQuantities( $fields, $product )
}

/**
* We don't need tos ave all the informations
* We don't need to save all the information
* available on the group variable, that's why we define
* explicitly how everything is saved here.
*/
Expand Down Expand Up @@ -1785,7 +1785,10 @@ public function searchProduct( $search, $limit = 5, $arguments = [] )
->orWhere( 'sku', 'LIKE', "%{$search}%" )
->orWhere( 'barcode', 'LIKE', "%{$search}%" );
})
->with( 'unit_quantities.unit' )
->with([
'unit_quantities.unit',
'tax_group.taxes'
])
->limit( $limit );

/**
Expand Down
22 changes: 6 additions & 16 deletions app/Services/TaxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,23 +251,13 @@ public function update( $id, $fields )
public function getComputedTaxGroupValue( $tax_type, $tax_group_id, $price )
{
$taxGroup = TaxGroup::find( $tax_group_id );
$taxValue = 0;

if ( $taxGroup instanceof TaxGroup ) {
$taxValue = $taxGroup->taxes
->map( function( $tax ) use ( $tax_type, $price ) {
$taxValue = $this->getVatValue(
$tax_type,
floatval( $tax[ 'rate' ] ),
$price
);

return $taxValue;
})
->sum();
$summarizedRate = $taxGroup->taxes->sum( 'rate' );
return $this->getVatValue( $tax_type, $summarizedRate, $price );
}

return $taxValue;
return 0;
}

/**
Expand Down Expand Up @@ -306,21 +296,21 @@ public function computeTax( ProductUnitQuantity $product, $tax_group_id, $tax_ty

if ( ( $tax_type ?? $product->tax_type) === 'inclusive' ) {
$product->sale_price_with_tax = ( floatval( $product->sale_price_edit ) );
$product->sale_price_tax = ( floatval( $this->getVatValue( 'inclusive', $taxRate, $product->sale_price_edit ) ) );
$product->sale_price_without_tax = $this->getPriceWithoutTax(
type: 'inclusive',
rate: $taxRate,
value: $product->sale_price_edit
);
$product->sale_price_tax = ( floatval( $this->getVatValue( 'inclusive', $taxRate, $product->sale_price_edit ) ) );
$product->sale_price = $product->sale_price_with_tax;
} else {
$product->sale_price_without_tax = floatval( $product->sale_price_edit );
$product->sale_price_tax = ( floatval( $this->getVatValue( 'exclusive', $taxRate, $product->sale_price_edit ) ) );
$product->sale_price_with_tax = $this->getPriceWithTax(
type: 'exclusive',
rate: $taxRate,
value: $product->sale_price_edit
);
$product->sale_price_tax = ( floatval( $this->getVatValue( 'exclusive', $taxRate, $product->sale_price_edit ) ) );
$product->sale_price = $product->sale_price_with_tax;
}
}
Expand Down Expand Up @@ -542,7 +532,7 @@ public function getVatValue( $type, float $rate, float $value )
if ( $type === 'inclusive' ) {
return ns()->currency->define( $value )->subtractBy( $this->getPriceWithoutTax( $type, $rate, $value ) )->getRaw();
} elseif ( $type === 'exclusive' ) {
return ns()->currency->define( $this->getPriceWithoutTax( $type, $rate, $value ) )->subtractBy( $value )->getRaw();
return ns()->currency->define( $this->getPriceWithTax( $type, $rate, $value ) )->subtractBy( $value )->getRaw();
}
}

Expand Down
12 changes: 12 additions & 0 deletions app/Settings/pos/vat.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
];
}

$fields[] = [
'type' => 'select',
'name' => 'ns_pos_tax_compute_group_separately',
'value' => ns()->option->get( 'ns_pos_tax_compute_group_separately', 'no' ),
'options' => Helper::kvToJsOptions([
'yes' => __( 'Yes' ),
'no' => __( 'No' )
]),
'label' => __( 'Tax Group Computing' ),
'description' => __( 'If disabled, the rates are summed and computed. Otherwise it\'s computed separately.' ),
];

return [
'label' => __( 'VAT Settings' ),
'fields' => $fields,
Expand Down
1 change: 0 additions & 1 deletion public/css/animations.cb4544d9bb06aeaa8e48.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/app.fd019f689f87eb441ab3.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/dark.27ee9f62809c1ef1073e.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/fonts.64053e5a2ec1dd65399b.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/light.4d84b75697bee3a4f7ec.css

This file was deleted.

1 change: 0 additions & 1 deletion public/css/typography.5d798833a07dd150efa8.css

This file was deleted.

2 changes: 1 addition & 1 deletion public/js/app.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/auth.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/bootstrap.min/117.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/js/bootstrap.min/144.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/bootstrap.min/228.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3373380

Please sign in to comment.