Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'pu/cw/tweakTax' into '2022.11'
Browse files Browse the repository at this point in the history
tweak(Sales): allow to decouple taxrate from net/gross

See merge request tine20/tine20!2435
  • Loading branch information
corneliusweiss committed Jun 17, 2022
2 parents e6929a9 + 330b87c commit b7a655b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tine20/Sales/Model/PurchaseInvoice.php
Expand Up @@ -159,11 +159,11 @@ class Sales_Model_PurchaseInvoice extends Tinebase_Record_Abstract
'label' => 'Sales Tax', // _('Sales Tax')
'type' => 'float',
'specialType' => 'percent',
self::NULLABLE => true,
self::DEFAULT_VAL_CONFIG => [
self::APP_NAME => Tinebase_Config::APP_NAME,
self::CONFIG => Tinebase_Config::SALES_TAX
],
'inputFilters' => array('Zend_Filter_Empty' => 0),
'shy' => TRUE,
),
'price_total' => array(
Expand Down
7 changes: 5 additions & 2 deletions tine20/Sales/js/PurchaseInvoiceEditDialog.js
Expand Up @@ -175,6 +175,8 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
calcTax: function() {
var netPrice = parseFloat(this.priceNetField.getValue());
var taxPercent = parseFloat(this.salesTaxField.getValue());

if (_.isNaN(taxPercent)) return;

var tax = netPrice * (taxPercent / 100);
var negative = false;
Expand Down Expand Up @@ -203,7 +205,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
var taxPercent = tax * 100 / netPrice;

this.priceTaxField.setValue(tax);
this.salesTaxField.setValue(taxPercent.toFixed(2));
this.salesTaxField.setValue(_.isFinite(taxPercent) && this.salesTaxField.getValue() !== null ? taxPercent.toFixed(2) : null);
},

/**
Expand All @@ -217,7 +219,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog

var roundedPercent = Math.round(Math.abs(taxPercent) * 100) / 100;

this.salesTaxField.setValue(roundedPercent);
this.salesTaxField.setValue(_.isFinite(roundedPercent) && this.salesTaxField.getValue() !== null ? roundedPercent : null);
},

/**
Expand Down Expand Up @@ -349,6 +351,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
fieldLabel: this.app.i18n._('Sales Tax (percent)'),
columnWidth: 1/4,
suffix: ' %',
nullable: true,
listeners: {
scope: this,
spin: this.onUpdateSalesTax.createDelegate(this),
Expand Down

0 comments on commit b7a655b

Please sign in to comment.