details: https://code.openbravo.com/erp/devel/main/rev/f767a51ca221 changeset: 21539:f767a51ca221 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Mon Dec 09 13:16:08 2013 +0100 summary: Fixes issue 25274: Time fields are not working properly
There were two errors: - When a time field was edited from the form there was a missing convertion from UTC to local time. - There was a bug in convertToClassicString. It was always converting from utc to local time, but at that point the value introduce was already converted to t he proper time zone. details: https://code.openbravo.com/erp/devel/main/rev/754dc3e1c786 changeset: 21540:754dc3e1c786 user: Augusto Mauch <augusto.mauch <at> openbravo.com> date: Thu Dec 12 12:50:26 2013 +0100 summary: Fixes issue 25307: Tab display logic works with preferences For computing the display logic of a tab, the context info of its parent tab is used. But if a preference is used, it is stored as a session attribute in the subtab, so it was not being included in the context. details: https://code.openbravo.com/erp/devel/main/rev/8c65efdd4710 changeset: 21541:8c65efdd4710 user: Javier Etxarri <javier.echarri <at> openbravo.com> date: Wed Dec 11 17:50:26 2013 +0100 summary: Fixes issue 25311: Wrong payment details when creating a partial invoice from a partially prepaid order details: https://code.openbravo.com/erp/devel/main/rev/8d037bf11312 changeset: 21542:8d037bf11312 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Tue Dec 10 12:52:34 2013 +0100 summary: Related to issue 24615: code review Added index to C_INVOICETAX_CASHVAT table Use OBContext.setAdminMode(true); Added flush() to avoid problems with adminMode Removed unused javadoc params diffstat: modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml | 2 +- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js | 6 + modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js | 6 +- modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-date.js | 15 ++- modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TimeUIDefinition.java | 6 +- src-db/database/model/tables/C_INVOICETAX_CASHVAT.xml | 3 + src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java | 5 +- src/org/openbravo/erpCommon/utility/CashVATUtil.java | 42 ++------- 8 files changed, 39 insertions(+), 46 deletions(-) diffs (287 lines): diff -r eaaff0469b9b -r 8d037bf11312 modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml --- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml Mon Dec 09 16:17:44 2013 +0530 +++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml Tue Dec 10 12:52:34 2013 +0100 @@ -434,7 +434,7 @@ --When difference amount is not 0 the payment schedule detail of the order has to be split. The difference --amount is the amount of the new psd that is not related to any invoice. - IF (v_differenceamount <> 0) THEN + IF (v_differenceamount > 0) THEN v_new_scheduledetailid := get_uuid(); INSERT INTO fin_payment_scheduledetail ( diff -r eaaff0469b9b -r 8d037bf11312 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js Mon Dec 09 16:17:44 2013 +0530 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js Tue Dec 10 12:52:34 2013 +0100 @@ -149,7 +149,13 @@ return this.Super('moved', arguments); }, formSaved: function (request, response, data) { + var UTCOffsetInMiliseconds; if (this.getValue() !== data[this.name]) { + // it has not been converted to the local time yet, do it now + if (data[this.name].getFullYear() === 1970) { + UTCOffsetInMiliseconds = OB.Utilities.Date.getUTCOffsetInMiliseconds(); + data[this.name].setTime(data[this.name].getTime() + UTCOffsetInMiliseconds); + } this.setValue(data[this.name]); } } diff -r eaaff0469b9b -r 8d037bf11312 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Mon Dec 09 16:17:44 2013 +0530 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js Tue Dec 10 12:52:34 2013 +0100 @@ -1353,14 +1353,16 @@ }, updateSubtabVisibility: function () { - var i, length, tabViewPane, activeTab, activeTabNum, activeTabPane, indexFirstNotHiddenTab; + var i, length, tabViewPane, activeTab, activeTabNum, activeTabPane, indexFirstNotHiddenTab, contextInfo; if (this.childTabSet) { length = this.childTabSet.tabs.length; for (i = 0; i < length; i++) { tabViewPane = this.childTabSet.tabs[i].pane; // Calling getContextInfo with (false, true, true) in order to obtain also the value of the // session attributes of the form - if (tabViewPane.showTabIf && !(tabViewPane.showTabIf(this.getContextInfo(false, true, true)))) { + contextInfo = this.getContextInfo(false, true, true); + isc.addProperties(contextInfo, tabViewPane.sessionAttributes); + if (tabViewPane.showTabIf && !(tabViewPane.showTabIf(contextInfo))) { this.childTabSet.tabBar.members[i].hide(); tabViewPane.hidden = true; } else { diff -r eaaff0469b9b -r 8d037bf11312 modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-date.js --- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-date.js Mon Dec 09 16:17:44 2013 +0530 +++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities-date.js Tue Dec 10 12:52:34 2013 +0100 @@ -252,7 +252,7 @@ for (i = 0; i < length; i++) { field = allFields[i]; if (field.type === '_id_24') { - timeFields.push(field.name); + timeFields.push(field); } } return timeFields; @@ -275,12 +275,17 @@ convertedDataLength = convertedData.length; for (i = 0; i < timeFieldsLength; i++) { for (j = 0; j < convertedDataLength; j++) { - textField = convertedData[j][timeFields[i]]; - if (textField && textField.length > 0) { + textField = convertedData[j][timeFields[i].name]; + if (!textField) { + continue; + } + if (isc.isA.String(textField)) { fieldToDate = isc.Time.parseInput(textField); - fieldToDate.setTime(fieldToDate.getTime() + UTCOffsetInMiliseconds); - convertedData[j][timeFields[i]] = fieldToDate.getHours() + ':' + fieldToDate.getMinutes() + ':' + fieldToDate.getSeconds(); + } else if (isc.isA.Date(textField)) { + fieldToDate = textField; } + fieldToDate.setTime(fieldToDate.getTime() + UTCOffsetInMiliseconds); + convertedData[j][timeFields[i].name] = fieldToDate.getHours() + ':' + fieldToDate.getMinutes() + ':' + fieldToDate.getSeconds(); } } return convertedData; diff -r eaaff0469b9b -r 8d037bf11312 modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TimeUIDefinition.java --- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TimeUIDefinition.java Mon Dec 09 16:17:44 2013 +0530 +++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TimeUIDefinition.java Tue Dec 10 12:52:34 2013 +0100 @@ -62,11 +62,7 @@ if (value instanceof String) { return (String) value; } - - String timestamp = value.toString(); - timestamp = timestamp.substring(timestamp.indexOf(" ") + 1); - StringBuffer convertedValue = convertUtcToLocalTime(timestamp); - return convertedValue.toString(); + return value.toString(); } private SimpleDateFormat getClassicFormat() { diff -r eaaff0469b9b -r 8d037bf11312 src-db/database/model/tables/C_INVOICETAX_CASHVAT.xml --- a/src-db/database/model/tables/C_INVOICETAX_CASHVAT.xml Mon Dec 09 16:17:44 2013 +0530 +++ b/src-db/database/model/tables/C_INVOICETAX_CASHVAT.xml Tue Dec 10 12:52:34 2013 +0100 @@ -65,6 +65,9 @@ <foreign-key foreignTable="FIN_PAYMENT_DETAIL" name="C_INVOICETAXCASHVAT_FPD" onDelete="cascade"> <reference local="FIN_PAYMENT_DETAIL_ID" foreign="FIN_PAYMENT_DETAIL_ID"/> </foreign-key> + <index name="C_INVOICETAX_CASHVAT_INVTAX" unique="false"> + <index-column name="C_INVOICETAX_ID"/> + </index> <check name="C_INVOICETAXCASHVAT_ACTIVE_CH"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check> </table> </database> diff -r eaaff0469b9b -r 8d037bf11312 src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java --- a/src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java Mon Dec 09 16:17:44 2013 +0530 +++ b/src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java Tue Dec 10 12:52:34 2013 +0100 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2010-2013 Openbravo SLU + * All portions are Copyright (C) 2013 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -31,7 +31,6 @@ /** * Use for DocLine that must support Cash VAT regime * - * @author openbravo * */ public class DocLineCashVATReady_PaymentTransactionReconciliation extends DocLine { @@ -56,7 +55,7 @@ this.invoiceTaxCashVAT_V = new ArrayList<InvoiceTaxCashVAT_V>(); } else { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final StringBuffer hql = new StringBuffer(); hql.append(" as itcv "); hql.append(" where itcv." + InvoiceTaxCashVAT_V.PROPERTY_PAYMENTDETAILS diff -r eaaff0469b9b -r 8d037bf11312 src/org/openbravo/erpCommon/utility/CashVATUtil.java --- a/src/org/openbravo/erpCommon/utility/CashVATUtil.java Mon Dec 09 16:17:44 2013 +0530 +++ b/src/org/openbravo/erpCommon/utility/CashVATUtil.java Tue Dec 10 12:52:34 2013 +0100 @@ -66,7 +66,7 @@ */ public static String getOrganizationIsCashVAT(final String strOrgId) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final Organization org = OBDal.getInstance().get(Organization.class, strOrgId); final Organization legalEntity = OBContext.getOBContext() .getOrganizationStructureProvider(org.getClient().getId()).getLegalEntity(org); @@ -75,8 +75,7 @@ return legalEntity.getOrganizationInformationList().get(0).isCashVAT() ? "Y" : "N"; } } catch (final Exception e) { - log4j.error("Error getting organization'" + strOrgId + "' cash vat. Returning null"); - log4j.error(e.getMessage(), e); + log4j.error("Error getting organization'" + strOrgId + "' cash vat. Returning null", e); } finally { OBContext.restorePreviousMode(); } @@ -89,17 +88,17 @@ * * @param strBPId * Vendor (c_bpartner_id) + * @return "Y", "N" or null if not found */ public static String getBusinessPartnerIsCashVAT(final String strBPId) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final BusinessPartner bp = OBDal.getInstance().get(BusinessPartner.class, strBPId); if (bp != null) { return bp.isCashVAT() ? "Y" : "N"; } } catch (final Exception e) { - log4j.error("Error getting business partner'" + strBPId + "' cash vat. Returning null"); - log4j.error(e.getMessage(), e); + log4j.error("Error getting business partner'" + strBPId + "' cash vat. Returning null", e); } finally { OBContext.restorePreviousMode(); } @@ -111,14 +110,11 @@ * Creates the records into the Cash VAT management table (InvoiceTaxCashVAT), calculating the * percentage paid/collected tax amount and taxable amount * - * @param paymentDetail - * @param paymentSchedule - * @param amount */ public static void createInvoiceTaxCashVAT(final FIN_PaymentDetail paymentDetail, final FIN_PaymentSchedule paymentSchedule, final BigDecimal amount) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final Invoice invoice = paymentSchedule.getInvoice(); if (invoice != null && invoice.isCashVAT()) { // A previous cash vat line with this payment detail means we are reactivating the payment. @@ -173,6 +169,7 @@ OBDal.getInstance().save(iTCashVAT); } } + OBDal.getInstance().flush(); } } finally { OBContext.restorePreviousMode(); @@ -181,12 +178,10 @@ /** * Gets the InvoiceTaxCashVAT records linked to the payment detail - * - * @param paymentDetail */ public static List<InvoiceTaxCashVAT> getInvoiceTaxCashVAT(final FIN_PaymentDetail paymentDetail) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); return OBDao.getFilteredCriteria(InvoiceTaxCashVAT.class, Restrictions.eq(InvoiceTaxCashVAT.PROPERTY_FINPAYMENTDETAIL, paymentDetail)).list(); } finally { @@ -202,11 +197,10 @@ * Use this method when the invoice is fully paid to avoid rounding issues with on the fly * calculations based on the percentage of the invoice that has been paid/collected * - * @param cInvoiceTaxID */ public static Map<String, BigDecimal> getTotalOutstandingCashVATAmount(final String cInvoiceTaxID) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final StringBuffer hql = new StringBuffer(); hql.append(" select 100 - sum(coalesce(itcv." + InvoiceTaxCashVAT_V.PROPERTY_PERCENTAGE + ", 0)) as percentage, "); @@ -241,14 +235,11 @@ * prepayment, i.e. from an (partially or totally) paid/collected order. This percentage must be * directly registered into the final tax account instead of the transitory tax account as usual, * because this part of the invoice has been paid from the order - * - * @param cTaxID - * @param cInvoiceId */ public static BigDecimal calculatePrepaidPercentageForCashVATTax(final String cTaxID, final String cInvoiceId) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final StringBuffer hql = new StringBuffer(); hql.append(" select coalesce(sum(" + InvoiceTaxCashVAT_V.PROPERTY_PERCENTAGE + "), 0) "); hql.append(" from " + InvoiceTaxCashVAT_V.ENTITY_NAME); @@ -290,7 +281,7 @@ public static BigDecimal calculatePercentageAmount(final BigDecimal percentage, final BigDecimal totalAmt, final String cCurrencyId) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); final Currency currency = OBDal.getInstance().get(Currency.class, cCurrencyId); return calculatePercentageAmount(percentage, totalAmt, currency); } finally { @@ -313,7 +304,7 @@ public static BigDecimal calculatePercentageAmount(final BigDecimal percentage, final BigDecimal totalAmt, final Currency currency) { try { - OBContext.setAdminMode(); + OBContext.setAdminMode(true); if (currency != null) { int precission = currency.getStandardPrecision().intValue(); return percentage.multiply(totalAmt).divide(_100, precission, RoundingMode.HALF_UP); @@ -329,15 +320,6 @@ * Create the accounting fact lines related to Cash VAT for payments, transactions and * reconciliations that come from a cash VAT invoice * - * @param as - * @param conn - * @param fact - * @param Fact_Acct_Group_ID - * @param line - * @param invoice - * @param documentType - * @param cCurrencyID - * @param SeqNo */ public static String createFactCashVAT(AcctSchema as, ConnectionProvider conn, Fact fact, String Fact_Acct_Group_ID, DocLineCashVATReady_PaymentTransactionReconciliation line, ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits