priyasharma1 opened a new pull request #158: URL: https://github.com/apache/ofbiz-framework/pull/158 (OFBIZ-11481) Done the following: - removed mini-lang version of the service - added groovy version - updated the service definition ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
dixitdeepak commented on a change in pull request #158: URL: https://github.com/apache/ofbiz-framework/pull/158#discussion_r454106321 ########## File path: applications/accounting/groovyScripts/payment/PaymentServices.groovy ########## @@ -134,3 +136,77 @@ def updatePaymentContent() { } } +def createPaymentApplication() { + // Create a Payment Application + if (!parameters.invoiceId && !parameters.billingAccountId && !parameters.taxAuthGeoId && !parameters.toPaymentId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + GenericValue paymentAppl = delegator.makeValue("PaymentApplication") + paymentAppl.setNonPKFields(parameters) + + GenericValue payment = from("Payment").where("paymentId", parameters.paymentId).queryOne() + if (!payment) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + + BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment) + + if (parameters.invoiceId) { + // get the invoice and do some further validation against it + GenericValue invoice = from("Invoice").where("invoiceId", parameters.invoiceId).queryOne() + // check the currencies if they are compatible + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId != payment.actualCurrencyUomId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingCurrenciesOfInvoiceAndPaymentNotCompatible) + } + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId == payment.actualCurrencyUomId) { + // if required get the payment amount in foreign currency (local we already have) + Boolean actual = true + notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment, actual) + } + // get the amount that has not been applied yet for the invoice (outstanding amount) + BigDecimal notAppliedInvoice = InvoiceWorker.getInvoiceNotApplied(invoice) + if (notAppliedInvoice <= notAppliedPayment) { + paymentAppl.amountApplied = notAppliedInvoice + } else { + paymentAppl.amountApplied = notAppliedPayment + } + + if (invoice.billingAccountId) { + paymentAppl.billingAccountId = invoice.billingAccountId + } + } + + if (parameters.toPaymentId) { + // get the to payment and check the parent types are compatible + GenericValue toPayment = from("Payment").where("paymentId", parameters.toPaymentId).queryOne() + if (toPayment) { + toPaymentType = from("PaymentType").where("paymentTypeId", toPayment.paymentTypeId).queryOne() + } + paymentType = from("PaymentType").where("paymentTypeId", payment.paymentTypeId).queryOne() Review comment: Use cache. ########## File path: applications/accounting/groovyScripts/payment/PaymentServices.groovy ########## @@ -134,3 +136,77 @@ def updatePaymentContent() { } } +def createPaymentApplication() { + // Create a Payment Application + if (!parameters.invoiceId && !parameters.billingAccountId && !parameters.taxAuthGeoId && !parameters.toPaymentId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + GenericValue paymentAppl = delegator.makeValue("PaymentApplication") + paymentAppl.setNonPKFields(parameters) + + GenericValue payment = from("Payment").where("paymentId", parameters.paymentId).queryOne() + if (!payment) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + + BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment) + + if (parameters.invoiceId) { + // get the invoice and do some further validation against it + GenericValue invoice = from("Invoice").where("invoiceId", parameters.invoiceId).queryOne() + // check the currencies if they are compatible + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId != payment.actualCurrencyUomId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingCurrenciesOfInvoiceAndPaymentNotCompatible) + } + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId == payment.actualCurrencyUomId) { + // if required get the payment amount in foreign currency (local we already have) + Boolean actual = true + notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment, actual) + } + // get the amount that has not been applied yet for the invoice (outstanding amount) + BigDecimal notAppliedInvoice = InvoiceWorker.getInvoiceNotApplied(invoice) + if (notAppliedInvoice <= notAppliedPayment) { + paymentAppl.amountApplied = notAppliedInvoice + } else { + paymentAppl.amountApplied = notAppliedPayment + } + + if (invoice.billingAccountId) { + paymentAppl.billingAccountId = invoice.billingAccountId + } + } + + if (parameters.toPaymentId) { + // get the to payment and check the parent types are compatible + GenericValue toPayment = from("Payment").where("paymentId", parameters.toPaymentId).queryOne() + if (toPayment) { + toPaymentType = from("PaymentType").where("paymentTypeId", toPayment.paymentTypeId).queryOne() Review comment: we can use getRelated method with cache. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
priyasharma1 commented on a change in pull request #158: URL: https://github.com/apache/ofbiz-framework/pull/158#discussion_r454121486 ########## File path: applications/accounting/groovyScripts/payment/PaymentServices.groovy ########## @@ -134,3 +136,77 @@ def updatePaymentContent() { } } +def createPaymentApplication() { + // Create a Payment Application + if (!parameters.invoiceId && !parameters.billingAccountId && !parameters.taxAuthGeoId && !parameters.toPaymentId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + GenericValue paymentAppl = delegator.makeValue("PaymentApplication") + paymentAppl.setNonPKFields(parameters) + + GenericValue payment = from("Payment").where("paymentId", parameters.paymentId).queryOne() + if (!payment) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + + BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment) + + if (parameters.invoiceId) { + // get the invoice and do some further validation against it + GenericValue invoice = from("Invoice").where("invoiceId", parameters.invoiceId).queryOne() + // check the currencies if they are compatible + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId != payment.actualCurrencyUomId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingCurrenciesOfInvoiceAndPaymentNotCompatible) + } + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId == payment.actualCurrencyUomId) { + // if required get the payment amount in foreign currency (local we already have) + Boolean actual = true + notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment, actual) + } + // get the amount that has not been applied yet for the invoice (outstanding amount) + BigDecimal notAppliedInvoice = InvoiceWorker.getInvoiceNotApplied(invoice) + if (notAppliedInvoice <= notAppliedPayment) { + paymentAppl.amountApplied = notAppliedInvoice + } else { + paymentAppl.amountApplied = notAppliedPayment + } + + if (invoice.billingAccountId) { + paymentAppl.billingAccountId = invoice.billingAccountId + } + } + + if (parameters.toPaymentId) { + // get the to payment and check the parent types are compatible + GenericValue toPayment = from("Payment").where("paymentId", parameters.toPaymentId).queryOne() + if (toPayment) { + toPaymentType = from("PaymentType").where("paymentTypeId", toPayment.paymentTypeId).queryOne() Review comment: Thanks, Deepak. As I was trying to make this improvement, I noticed that there two variables are never used i.e. paymentType and toPaymentType. Will it be fine to skip these two entity operations if they are not used? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
verma-pawan commented on a change in pull request #158: URL: https://github.com/apache/ofbiz-framework/pull/158#discussion_r454323351 ########## File path: applications/accounting/groovyScripts/payment/PaymentServices.groovy ########## @@ -134,3 +136,77 @@ def updatePaymentContent() { } } +def createPaymentApplication() { + // Create a Payment Application + if (!parameters.invoiceId && !parameters.billingAccountId && !parameters.taxAuthGeoId && !parameters.toPaymentId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + GenericValue paymentAppl = delegator.makeValue("PaymentApplication") + paymentAppl.setNonPKFields(parameters) + + GenericValue payment = from("Payment").where("paymentId", parameters.paymentId).queryOne() + if (!payment) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + + BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment) + + if (parameters.invoiceId) { + // get the invoice and do some further validation against it + GenericValue invoice = from("Invoice").where("invoiceId", parameters.invoiceId).queryOne() + // check the currencies if they are compatible + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId != payment.actualCurrencyUomId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingCurrenciesOfInvoiceAndPaymentNotCompatible) + } + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId == payment.actualCurrencyUomId) { + // if required get the payment amount in foreign currency (local we already have) + Boolean actual = true + notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment, actual) + } + // get the amount that has not been applied yet for the invoice (outstanding amount) + BigDecimal notAppliedInvoice = InvoiceWorker.getInvoiceNotApplied(invoice) + if (notAppliedInvoice <= notAppliedPayment) { + paymentAppl.amountApplied = notAppliedInvoice + } else { + paymentAppl.amountApplied = notAppliedPayment + } + + if (invoice.billingAccountId) { + paymentAppl.billingAccountId = invoice.billingAccountId + } + } + + if (parameters.toPaymentId) { + // get the to payment and check the parent types are compatible + GenericValue toPayment = from("Payment").where("paymentId", parameters.toPaymentId).queryOne() + if (toPayment) { + toPaymentType = from("PaymentType").where("paymentTypeId", toPayment.paymentTypeId).queryOne() Review comment: Hi Priya, Yes, If a variable is never used we can remove it safely. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
priyasharma1 commented on a change in pull request #158: URL: https://github.com/apache/ofbiz-framework/pull/158#discussion_r455750319 ########## File path: applications/accounting/groovyScripts/payment/PaymentServices.groovy ########## @@ -134,3 +136,77 @@ def updatePaymentContent() { } } +def createPaymentApplication() { + // Create a Payment Application + if (!parameters.invoiceId && !parameters.billingAccountId && !parameters.taxAuthGeoId && !parameters.toPaymentId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + GenericValue paymentAppl = delegator.makeValue("PaymentApplication") + paymentAppl.setNonPKFields(parameters) + + GenericValue payment = from("Payment").where("paymentId", parameters.paymentId).queryOne() + if (!payment) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingPaymentApplicationParameterMissing) + } + + BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment) + + if (parameters.invoiceId) { + // get the invoice and do some further validation against it + GenericValue invoice = from("Invoice").where("invoiceId", parameters.invoiceId).queryOne() + // check the currencies if they are compatible + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId != payment.actualCurrencyUomId) { + return error(UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)?.AccountingCurrenciesOfInvoiceAndPaymentNotCompatible) + } + if (invoice.currencyUomId != payment.currencyUomId && invoice.currencyUomId == payment.actualCurrencyUomId) { + // if required get the payment amount in foreign currency (local we already have) + Boolean actual = true + notAppliedPayment = PaymentWorker.getPaymentNotApplied(payment, actual) + } + // get the amount that has not been applied yet for the invoice (outstanding amount) + BigDecimal notAppliedInvoice = InvoiceWorker.getInvoiceNotApplied(invoice) + if (notAppliedInvoice <= notAppliedPayment) { + paymentAppl.amountApplied = notAppliedInvoice + } else { + paymentAppl.amountApplied = notAppliedPayment + } + + if (invoice.billingAccountId) { + paymentAppl.billingAccountId = invoice.billingAccountId + } + } + + if (parameters.toPaymentId) { + // get the to payment and check the parent types are compatible + GenericValue toPayment = from("Payment").where("paymentId", parameters.toPaymentId).queryOne() + if (toPayment) { + toPaymentType = from("PaymentType").where("paymentTypeId", toPayment.paymentTypeId).queryOne() Review comment: Thanks, Pawan for the verification. I have removed both those lines. Though I have tested it please let me know if this causes any issue. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] |
Free forum by Nabble | Edit this page |