commit c0f94f6c1e30613067c489141f4b04346feb6855
parent f06b01724d03e3e3021ff11208b8519f441860f0
Author: timoahummel <privat@timohummel.com>
Date: Sun, 13 May 2012 22:40:59 -0700
Merge pull request #180 from scrupeus/fix-154-prices
Fix-154-prices
Diffstat:
7 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php b/src/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php
@@ -118,7 +118,7 @@ class Part extends BaseEntity implements Serializable, Deserializable {
* The average price for the part. Note that this is a cached value.
*
* @todo It would be nice if we could get rid of that
- * @Column(type="decimal",precision=5, scale=2,nullable=true)
+ * @Column(type="decimal",precision=13,scale=4,nullable=true)
* @var float
*/
private $averagePrice = null;
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Stock/StockEntry.php b/src/backend/de/RaumZeitLabor/PartKeepr/Stock/StockEntry.php
@@ -25,7 +25,7 @@ class StockEntry extends BaseEntity implements Serializable {
private $user;
/**
- * @Column(type="decimal",precision=5, scale=2,nullable=true)
+ * @Column(type="decimal",precision=13,scale=4,nullable=true)
* @var float
*/
private $price;
@@ -236,4 +236,4 @@ class StockEntry extends BaseEntity implements Serializable {
"price" => $this->getPrice()
);
}
-}-
\ No newline at end of file
+}
diff --git a/src/frontend/js/Components/Part/Editor/PartEditor.js b/src/frontend/js/Components/Part/Editor/PartEditor.js
@@ -229,7 +229,8 @@ Ext.define('PartKeepr.PartEditor', {
fieldLabel: i18n('Price'),
labelWidth: 150,
columnWidth: 0.5,
- name: 'initialStockLevelPrice'
+ name: 'initialStockLevelPrice',
+ decimalPrecision: 4
});
this.initialStockLevelPricePerItem = Ext.create("Ext.form.field.Checkbox", {
diff --git a/src/frontend/js/Components/Part/PartsGrid.js b/src/frontend/js/Components/Part/PartsGrid.js
@@ -174,7 +174,9 @@ Ext.define('PartKeepr.PartsGrid', {
renderer: this.stockLevelRenderer
},{
header: i18n("Avg. Price"),
- dataIndex: 'averagePrice'
+ dataIndex: 'averagePrice',
+ align: 'right',
+ renderer: this.averagePriceRenderer
},{
header: i18n("Footprint"),
dataIndex: 'footprintName'
@@ -205,6 +207,18 @@ Ext.define('PartKeepr.PartsGrid', {
}
},
/**
+ * Used as renderer for the average price column.
+ */
+ averagePriceRenderer: function (val,q,rec)
+ {
+ var numDecimals = PartKeepr.getApplication().getUserPreference("partkeepr.formatting.price.numdecimals");
+ if (numDecimals === null) {
+ numDecimals = 2;
+ }
+
+ return val.toFixed(numDecimals);
+ },
+ /**
* Used as renderer for the icon column.
*/
iconRenderer: function (val,q,rec)
diff --git a/src/frontend/js/Components/User/Preferences/FormattingPreferences.js b/src/frontend/js/Components/User/Preferences/FormattingPreferences.js
@@ -0,0 +1,29 @@
+Ext.define('PartKeepr.FormattingPreferencesPanel', {
+ extend: 'Ext.form.FormPanel',
+ title: i18n("Formatting"),
+ bodyStyle: 'background:#DBDBDB;padding: 10px;',
+ initComponent: function () {
+ this.priceNumDecimalsField = Ext.create("Ext.form.field.Number", {
+ name: 'priceNumDecimalsField',
+ fieldLabel: i18n('Decimal precision'),
+ labelWidth: 150,
+ columnWidth: 0.5,
+ minValue: 0,
+ maxValue: 4,
+ allowDecimals: false,
+ listeners: {
+ change: function(field, newValue) {
+ PartKeepr.getApplication().setUserPreference("partkeepr.formatting.price.numdecimals", newValue);
+ }
+ }
+ });
+
+ var numDecimals = PartKeepr.getApplication().getUserPreference("partkeepr.formatting.price.numdecimals", 2);
+ this.priceNumDecimalsField.setValue(numDecimals);
+
+ this.items = [ this.priceNumDecimalsField ];
+
+ this.callParent();
+ },
+});
+
diff --git a/src/frontend/js/Components/User/UserPreferences.js b/src/frontend/js/Components/User/UserPreferences.js
@@ -7,9 +7,10 @@ Ext.define('PartKeepr.UserPreferencePanel', {
this.passwordChangePanel = Ext.create("PartKeepr.UserPasswordChangePanel");
this.tipsPanel = Ext.create("PartKeepr.TipOfTheDayPreferencesPanel");
+ this.formattingPanel = Ext.create("PartKeepr.FormattingPreferencesPanel");
this.categoryTreePanel = Ext.create("PartKeepr.CategoryTreePreferencesPanel");
- this.stockPanel = Ext.create("PartKeepr.StockPreferencesPanel");
- this.items = [ this.tipsPanel, this.categoryTreePanel, this.passwordChangePanel, this.stockPanel ];
+ this.stockPanel = Ext.create("PartKeepr.StockPreferencesPanel");
+ this.items = [ this.tipsPanel, this.formattingPanel, this.categoryTreePanel, this.passwordChangePanel, this.stockPanel ];
this.callParent();
}
});
diff --git a/src/frontend/js/PartKeepr.js b/src/frontend/js/PartKeepr.js
@@ -490,14 +490,6 @@ Ext.application({
*/
getUsername: function () {
return this.username;
- },
- /**
- * Returns the number of decimal places
- *
- * @returns {int} The number of decimal places
- */
- getDecimalPlaces: function () {
- return this.getUserPreference("partkeepr.number.decimalplaces", 3);
}
});