adjusts validation for discount (purchase invoices) and budget (TA)
authorsstamer <s.stamer@metaways.de>
Mon, 13 Jul 2015 13:03:23 +0000 (15:03 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 13 Jul 2015 14:56:08 +0000 (16:56 +0200)
* and some code cleanup

Change-Id: I3180248ba649a74f61efdda0854cbc2e37661eb0
Reviewed-on: http://gerrit.tine20.com/customers/2030
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Sales/js/CustomerEditDialog.js
tine20/Sales/js/InvoiceEditDialog.js
tine20/Sales/js/PurchaseInvoiceEditDialog.js
tine20/Sales/js/SupplierEditDialog.js
tine20/Timetracker/js/TimeaccountEditDialog.js

index 7941356..b386c17 100644 (file)
@@ -265,7 +265,8 @@ Tine.Sales.CustomerEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                                     allowDecimals : true
                                 }),
                                 decimalPrecision: 2,
-                                decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator')
+                                decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator'),
+                                regex: /^[0-9]+\.?[0-9]*$/
                             }], [{
                                 name: 'iban',
                                 fieldLabel: this.app.i18n._('IBAN')
index 98201d9..8cc8570 100644 (file)
@@ -345,6 +345,7 @@ Tine.Sales.InvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
             }),
             name: 'sales_tax',
             decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator'),
+            regex: /^[0-9]+\.?[0-9]*$/,
             fieldLabel: this.app.i18n._('Sales Tax (percent)'),
             columnWidth: 1/3,
             listeners: {
index 45672cf..8008bc5 100644 (file)
@@ -47,8 +47,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
      * @return {Boolean}
      */
     isValid: function() {
-        var isValid = Tine.Sales.PurchaseInvoiceEditDialog.superclass.isValid.call(this);
-        return isValid;
+        return Tine.Sales.PurchaseInvoiceEditDialog.superclass.isValid.call(this);
     },
     
     /**
@@ -172,19 +171,6 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
     },
     
     /**
-     * calculates price gross by price net and tax
-     */
-    calcGrossOld: function() {
-        var net = parseFloat(this.priceNetField.getValue());
-        var tax = parseFloat(this.salesTaxField.getValue());
-        var gross = net + (net * (tax / 100));
-        
-        var grosscent = Math.ceil(gross * 100);
-        
-        this.priceGrossField.setValue(grosscent / 100);
-    },
-    
-    /**
      * returns dialog
      * 
      * NOTE: when this method gets called, all initalisation is done.
@@ -299,6 +285,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
             decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator'),
             fieldLabel: this.app.i18n._('Sales Tax (percent)'),
             columnWidth: 1/4,
+            regex: /^[0-9]+\.?[0-9]*$/,
             listeners: {
                 scope: this,
                 spin: this.onUpdateSalesTax.createDelegate(this),
@@ -311,20 +298,16 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
             decimalPrecision: 2,
             strategy: new Ext.ux.form.Spinner.NumberStrategy({
                 incrementValue : 1,
-                alternateIncrementValue: 0.1,
                 minValue: 0,
                 maxValue: 100,
-                allowDecimals: 2
+                allowDecimals: 0
             }),
             name: 'discount',
             decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator'),
             fieldLabel: this.app.i18n._('Discount (%)'),
             columnWidth: 1/4,
-            //listeners: {
-            //    scope: this,
-            //    spin: this.calcGross.createDelegate(this),
-            //    blur: this.calcGross.createDelegate(this)
-            //}
+            value: 0,
+            regex: /^[0-9]+\.?[0-9]*$/
         });
         
         var items = [{
@@ -351,7 +334,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
                                 name: 'number',
                                 fieldLabel: this.app.i18n._('Invoice Number'),
                                 columnWidth: 1/4,
-                                allowBlank: false,
+                                allowBlank: false
                                 //readOnly: ! Tine.Tinebase.common.hasRight('set_invoice_number', 'Sales'),
                                 //emptyText: this.app.i18n._('automatically set...')
                             }, {
@@ -376,7 +359,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
                                     xtype: 'extuxclearabledatefield',
                                     name: 'overdue_at',
                                     fieldLabel: this.app.i18n._('Overdue date'),
-                                    columnWidth: 1/4,
+                                    columnWidth: 1/4
                                     //emptyText: (this.record.get('is_auto') == 1) ? this.app.i18n._('automatically set...') : ''
                             }], [
                                 this.priceNetField,
@@ -390,7 +373,7 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
                                     name: 'discount_until',
                                     //allowBlank: false,
                                     fieldLabel: this.app.i18n._('Discount until'),
-                                    columnWidth: 1/4,
+                                    columnWidth: 1/4
                                     //emptyText: (this.record.get('is_auto') == 1) ? this.app.i18n._('automatically set...') : ''
                                 }
                             ]
@@ -411,13 +394,13 @@ Tine.Sales.PurchaseInvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
                                     xtype: 'extuxclearabledatefield',
                                     name: 'dunned_at',
                                     fieldLabel: this.app.i18n._('Dun date'),
-                                    columnWidth: 1/4,
+                                    columnWidth: 1/4
                                 }, {
                                     xtype: 'extuxclearabledatefield',
                                     name: 'payed_at',
                                     //allowBlank: false,
                                     fieldLabel: this.app.i18n._('Payed at'),
-                                    columnWidth: 1/4,
+                                    columnWidth: 1/4
                                     //emptyText: (this.record.get('is_auto') == 1) ? this.app.i18n._('automatically set...') : ''
                                 },
                                 // is_payed
index f53aef9..0edca5c 100644 (file)
@@ -245,7 +245,8 @@ Tine.Sales.SupplierEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                                     allowDecimals : true
                                 }),
                                 decimalPrecision: 2,
-                                decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator')
+                                decimalSeparator: Tine.Tinebase.registry.get('decimalSeparator'),
+                                regex: /^[0-9]+\.?[0-9]*$/
                             }], [{
                                 name: 'iban',
                                 fieldLabel: this.app.i18n._('IBAN')
index 29d38a9..05911fc 100644 (file)
@@ -77,10 +77,12 @@ Tine.Timetracker.TimeaccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
             fieldLabel: this.app.i18n._('Unit Price'),
             name: 'price',
             allowNegative: false
-            //decimalSeparator: ','
         }, {
+            xtype: 'numberfield',
             fieldLabel: this.app.i18n._('Budget'),
-            name: 'budget'
+            name: 'budget',
+            allowNegative: false,
+            value: 0
         }, {
             fieldLabel: this.app.i18n._('Status'),
             name: 'is_open',