Class FIN_AddPayment


  • public class FIN_AddPayment
    extends Object
    • Constructor Detail

      • FIN_AddPayment

        public FIN_AddPayment()
    • Method Detail

      • savePayment

        public static FIN_Payment savePayment​(FIN_Payment payment,
                                              boolean isReceipt,
                                              DocumentType docType,
                                              String strPaymentDocumentNo,
                                              BusinessPartner businessPartner,
                                              FIN_PaymentMethod paymentMethod,
                                              FIN_FinancialAccount finAccount,
                                              String strPaymentAmount,
                                              Date paymentDate,
                                              Organization organization,
                                              String referenceNo,
                                              List<FIN_PaymentScheduleDetail> selectedPaymentScheduleDetails,
                                              HashMap<String,​BigDecimal> selectedPaymentScheduleDetailsAmounts,
                                              boolean isWriteoff,
                                              boolean isRefund,
                                              Currency paymentCurrency,
                                              BigDecimal finTxnConvertRate,
                                              BigDecimal finTxnAmount,
                                              boolean doFlush,
                                              String paymentId)
        Saves the payment and the payment details based on the given Payment Schedule Details. If no FIN_Payment is given it creates a new one. If the Payment Scheduled Detail is not completely paid and the difference is not written a new Payment Schedule Detail is created with the difference. If a Refund Amount is given an extra Payment Detail will be created with it.
        Parameters:
        payment - FIN_Payment where new payment details will be saved.
        isReceipt - boolean to define if the Payment is a Receipt Payment (true) or a Payable Payment (false). Used when no FIN_Payment is given.
        docType - DocumentType of the Payment. Used when no FIN_Payment is given.
        strPaymentDocumentNo - String with the Document Number of the new payment. Used when no FIN_Payment is given.
        businessPartner - BusinessPartner of the new Payment. Used when no FIN_Payment is given.
        paymentMethod - FIN_PaymentMethod of the new Payment. Used when no FIN_Payment is given.
        finAccount - FIN_FinancialAccount of the new Payment. Used when no FIN_Payment is given.
        strPaymentAmount - String with the Payment Amount of the new Payment. Used when no FIN_Payment is given.
        paymentDate - Date when the Payment is done. Used when no FIN_Payment is given.
        organization - Organization of the new Payment. Used when no FIN_Payment is given.
        selectedPaymentScheduleDetails - List of FIN_PaymentScheduleDetail to be included in the Payment. If one of the items is contained in other payment the method will throw an exception. Prevent invoice/order to be paid several times.
        selectedPaymentScheduleDetailsAmounts - HashMap with the Amount to be paid for each Scheduled Payment Detail.
        isWriteoff - Boolean to write off the difference when the payment amount is lower than the Payment Scheduled PAyment Detail amount.
        isRefund - Not used.
        paymentCurrency - The currency that the payment is being made in. Will default to financial account currency if not specified
        finTxnConvertRate - Exchange rate to convert between payment currency and financial account currency for this payment. Defaults to 1.0 if not supplied
        finTxnAmount - Amount of payment in currency of financial account
        doFlush - Force to flush inside the method after creating the payment
        paymentId - id to set in new entities
        Returns:
        The FIN_Payment OBObject containing all the Payment Details.
      • savePayment

        public static FIN_Payment savePayment​(FIN_Payment payment,
                                              boolean isReceipt,
                                              DocumentType docType,
                                              String strPaymentDocumentNo,
                                              BusinessPartner businessPartner,
                                              FIN_PaymentMethod paymentMethod,
                                              FIN_FinancialAccount finAccount,
                                              String strPaymentAmount,
                                              Date paymentDate,
                                              Organization organization,
                                              String referenceNo,
                                              List<FIN_PaymentScheduleDetail> selectedPaymentScheduleDetails,
                                              HashMap<String,​BigDecimal> selectedPaymentScheduleDetailsAmounts,
                                              boolean isWriteoff,
                                              boolean isRefund,
                                              Currency paymentCurrency,
                                              BigDecimal finTxnConvertRate,
                                              BigDecimal finTxnAmount)
        Saves the payment and the payment details based on the given Payment Schedule Details. If no FIN_Payment is given it creates a new one. If the Payment Scheduled Detail is not completely paid and the difference is not written a new Payment Schedule Detail is created with the difference. If a Refund Amount is given an extra Payment Detail will be created with it.
        Parameters:
        payment - FIN_Payment where new payment details will be saved.
        isReceipt - boolean to define if the Payment is a Receipt Payment (true) or a Payable Payment (false). Used when no FIN_Payment is given.
        docType - DocumentType of the Payment. Used when no FIN_Payment is given.
        strPaymentDocumentNo - String with the Document Number of the new payment. Used when no FIN_Payment is given.
        businessPartner - BusinessPartner of the new Payment. Used when no FIN_Payment is given.
        paymentMethod - FIN_PaymentMethod of the new Payment. Used when no FIN_Payment is given.
        finAccount - FIN_FinancialAccount of the new Payment. Used when no FIN_Payment is given.
        strPaymentAmount - String with the Payment Amount of the new Payment. Used when no FIN_Payment is given.
        paymentDate - Date when the Payment is done. Used when no FIN_Payment is given.
        organization - Organization of the new Payment. Used when no FIN_Payment is given.
        selectedPaymentScheduleDetails - List of FIN_PaymentScheduleDetail to be included in the Payment. If one of the items is contained in other payment the method will throw an exception. Prevent invoice/order to be paid several times.
        selectedPaymentScheduleDetailsAmounts - HashMap with the Amount to be paid for each Scheduled Payment Detail.
        isWriteoff - Boolean to write off the difference when the payment amount is lower than the Payment Scheduled PAyment Detail amount.
        isRefund - Not used.
        paymentCurrency - The currency that the payment is being made in. Will default to financial account currency if not specified
        finTxnConvertRate - Exchange rate to convert between payment currency and financial account currency for this payment. Defaults to 1.0 if not supplied
        finTxnAmount - Amount of payment in currency of financial account
        Returns:
        The FIN_Payment OBObject containing all the Payment Details.
      • savePayment

        public static FIN_Payment savePayment​(FIN_Payment payment,
                                              boolean isReceipt,
                                              DocumentType docType,
                                              String strPaymentDocumentNo,
                                              BusinessPartner businessPartner,
                                              FIN_PaymentMethod paymentMethod,
                                              FIN_FinancialAccount finAccount,
                                              String strPaymentAmount,
                                              Date paymentDate,
                                              Organization organization,
                                              String referenceNo,
                                              List<FIN_PaymentScheduleDetail> selectedPaymentScheduleDetails,
                                              HashMap<String,​BigDecimal> selectedPaymentScheduleDetailsAmounts,
                                              boolean isWriteoff,
                                              boolean isRefund,
                                              boolean doFlush)
        Saves the payment and the payment details based on the given Payment Schedule Details. If no FIN_Payment is given it creates a new one. If the Payment Scheduled Detail is not completely paid and the difference is not written a new Payment Schedule Detail is created with the difference. If a Refund Amount is given an extra Payment Detail will be created with it.
        Parameters:
        payment - FIN_Payment where new payment details will be saved.
        isReceipt - boolean to define if the Payment is a Receipt Payment (true) or a Payable Payment (false). Used when no FIN_Payment is given.
        docType - DocumentType of the Payment. Used when no FIN_Payment is given.
        strPaymentDocumentNo - String with the Document Number of the new payment. Used when no FIN_Payment is given.
        businessPartner - BusinessPartner of the new Payment. Used when no FIN_Payment is given.
        paymentMethod - FIN_PaymentMethod of the new Payment. Used when no FIN_Payment is given.
        finAccount - FIN_FinancialAccount of the new Payment. Used when no FIN_Payment is given.
        strPaymentAmount - String with the Payment Amount of the new Payment. Used when no FIN_Payment is given.
        paymentDate - Date when the Payment is done. Used when no FIN_Payment is given.
        organization - Organization of the new Payment. Used when no FIN_Payment is given.
        selectedPaymentScheduleDetails - List of FIN_PaymentScheduleDetail to be included in the Payment. If one of the items is contained in other payment the method will throw an exception. Prevent invoice/order to be paid several times.
        selectedPaymentScheduleDetailsAmounts - HashMap with the Amount to be paid for each Scheduled Payment Detail.
        isWriteoff - Boolean to write off the difference when the payment amount is lower than the Payment Scheduled PAyment Detail amount.
        isRefund - Not used.
        doFlush - Force to flush inside the method after creating the payment
        Returns:
        The FIN_Payment OBObject containing all the Payment Details.
      • updatePaymentDetail

        public static BigDecimal updatePaymentDetail​(FIN_PaymentScheduleDetail paymentScheduleDetail,
                                                     FIN_Payment payment,
                                                     BigDecimal paymentDetailAmount,
                                                     boolean isWriteoff)
                                              throws OBException
        Updates the paymentScheduleDetail with the paymentDetailAmount. If it is not related to the Payment a new Payment Detail is created. If isWriteoff is true and the amount is different to the outstanding amount the difference is written off.
        Parameters:
        paymentScheduleDetail - the Payment Schedule Detail to be assigned to the Payment
        payment - the FIN_Payment that it is being paid
        paymentDetailAmount - the amount of this paymentScheduleDetail that it is being paid
        isWriteoff - flag to write off the difference when there is an outstanding amount remaining to pay
        Returns:
        a BigDecimal with the amount newly assigned to the payment. For example, when the paymentScheduleDetail is already related to the payment and its amount is not changed BigDecimal.ZERO is returned.
        Throws:
        OBException - when the paymentDetailAmount is related to a different payment.
      • updatePaymentDetail

        public static BigDecimal updatePaymentDetail​(FIN_PaymentScheduleDetail paymentScheduleDetail,
                                                     FIN_Payment payment,
                                                     BigDecimal paymentDetailAmount,
                                                     boolean isWriteoff,
                                                     boolean doFlush)
                                              throws OBException
        Updates the paymentScheduleDetail with the paymentDetailAmount. If it is not related to the Payment a new Payment Detail is created. If isWriteoff is true and the amount is different to the outstanding amount the difference is written off.
        Parameters:
        paymentScheduleDetail - the Payment Schedule Detail to be assigned to the Payment
        payment - the FIN_Payment that it is being paid
        paymentDetailAmount - the amount of this paymentScheduleDetail that it is being paid
        isWriteoff - flag to write off the difference when there is an outstanding amount remaining to pay
        doFlush - Force to flush inside the method
        Returns:
        a BigDecimal with the amount newly assigned to the payment. For example, when the paymentScheduleDetail is already related to the payment and its amount is not changed BigDecimal.ZERO is returned.
        Throws:
        OBException - when the paymentDetailAmount is related to a different payment.
      • savePaymentProposal

        public static void savePaymentProposal​(FIN_PaymentProposal paymentProposal,
                                               BigDecimal paymentAmount,
                                               List<FIN_PaymentScheduleDetail> selectedPaymentScheduleDetails,
                                               HashMap<String,​BigDecimal> selectedPaymentScheduleDetailAmounts,
                                               BigDecimal writeOffAmt)
        Adds new Details to the given Payment Proposal based on the List of Payment Schedule Details.
        Parameters:
        paymentProposal - FIN_PaymentProposal where new Details are added.
        paymentAmount - Total amount to be paid.
        selectedPaymentScheduleDetails - List of FIN_PaymentScheduleDetail that needs to be added to the Payment Proposal.
        selectedPaymentScheduleDetailAmounts - HashMap with the Amount to be paid for each Scheduled Payment Detail.
        writeOffAmt - Total amount to be written off.
      • saveGLItem

        public static void saveGLItem​(FIN_Payment payment,
                                      BigDecimal glitemAmount,
                                      GLItem glitem,
                                      String paymentId)
        It adds to the Payment a new Payment Detail with the given GL Item and amount.
        Parameters:
        payment - Payment where the new Payment Detail needs to be added.
        glitemAmount - Amount of the new Payment Detail.
        glitem - GLItem to be set in the new Payment Detail.
        paymentId - id to set in new entities
      • saveGLItem

        public static void saveGLItem​(FIN_Payment payment,
                                      BigDecimal glitemAmount,
                                      GLItem glitem,
                                      String paymentId,
                                      boolean doFlush)
        It adds to the Payment a new Payment Detail with the given GL Item and amount.
        Parameters:
        payment - Payment where the new Payment Detail needs to be added.
        glitemAmount - Amount of the new Payment Detail.
        glitem - GLItem to be set in the new Payment Detail.
        paymentId - id to set in new entities
        doFlush - Do the flush during the process
      • saveGLItem

        public static void saveGLItem​(FIN_Payment payment,
                                      BigDecimal glitemAmount,
                                      GLItem glitem,
                                      BusinessPartner businessPartner,
                                      Product product,
                                      Project project,
                                      Campaign campaign,
                                      ABCActivity activity,
                                      SalesRegion salesRegion,
                                      Costcenter costCenter,
                                      UserDimension1 user1,
                                      UserDimension2 user2)
        It adds to the Payment a new Payment Detail with the given GL Item, amount and accounting dimensions
        Parameters:
        payment - Payment where the new Payment Detail needs to be added.
        glitemAmount - Amount of the new Payment Detail.
        glitem - GLItem to be set in the new Payment Detail.
        businessPartner - accounting dimension
        product - accounting dimension
        project - accounting dimension
        campaign - accounting dimension
        activity - accounting dimension
        salesRegion - accounting dimension
        costCenter - accounting dimension
        user1 - accounting dimension
        user2 - accounting dimension
      • saveGLItem

        public static void saveGLItem​(FIN_Payment payment,
                                      BigDecimal glitemAmount,
                                      GLItem glitem,
                                      BusinessPartner businessPartner,
                                      Product product,
                                      Project project,
                                      Campaign campaign,
                                      ABCActivity activity,
                                      SalesRegion salesRegion)
        It adds to the Payment a new Payment Detail with the given GL Item, amount and accounting dimensions
        Parameters:
        payment - Payment where the new Payment Detail needs to be added.
        glitemAmount - Amount of the new Payment Detail.
        glitem - GLItem to be set in the new Payment Detail.
        businessPartner - accounting dimension
        product - accounting dimension
        project - accounting dimension
        campaign - accounting dimension
        activity - accounting dimension
        salesRegion - accounting dimension
      • removeGLItem

        public static void removeGLItem​(FIN_Payment payment,
                                        FIN_PaymentDetail paymentDetail)
        Removes the Payment Detail from the Payment when the Detail is related to a GLItem
        Parameters:
        payment - FIN_Payment that contains the Payment Detail.
        paymentDetail - FIN_PaymentDetail to be removed.
      • getSelectedPaymentDetails

        public static List<FIN_PaymentScheduleDetail> getSelectedPaymentDetails​(List<FIN_PaymentScheduleDetail> scheduledPaymentDetails,
                                                                                String strSelectedPaymentDetailsIds)
        It adds to the scheduledPaymentDetails List the FIN_PaymentScheduleDetails given in the strSelectedPaymentDetailsIds comma separated String of Id's that are not yet included on it.
        Parameters:
        scheduledPaymentDetails - List of FIN_PaymentScheduleDetail.
        strSelectedPaymentDetailsIds - String of comma separated id's that needs to be included in the List if they are not present.
        Returns:
        returns a List of FIN_PaymentScheduleDetail including all the Payment Schedule Details.
      • getSelectedBaseOBObjectAmount

        public static <T extends BaseOBObjectHashMap<String,​BigDecimal> getSelectedBaseOBObjectAmount​(VariablesSecureApp vars,
                                                                                                              List<T> selectedBaseOBObjects,
                                                                                                              String htmlElementId)
                                                                                                       throws javax.servlet.ServletException
        Creates a HashMap with the BaseOBObject id's and the amount gotten from the Session. The amounts are stored in Session like "htmlElementId"+basobObject.Id
        Parameters:
        vars - VariablseSecureApp with the session data.
        selectedBaseOBObjects - List of bobs that need to be included in the HashMap.
        Returns:
        A HashMap mapping the Id with the corresponding amount.
        Throws:
        javax.servlet.ServletException
      • mergePaymentScheduleDetails

        public static void mergePaymentScheduleDetails​(FIN_PaymentScheduleDetail psd)
        This method groups several payment schedule details by {PaymentDetails, OrderPaymenSchedule, InvoicePaymentSchedule}.
        Parameters:
        psd - Payment Schedule Detail base. The amount will be updated here.
      • updatePaymentScheduleAmounts

        @Deprecated
        public static void updatePaymentScheduleAmounts​(FIN_PaymentSchedule paymentSchedule,
                                                        BigDecimal amount,
                                                        BigDecimal writeOffAmount)
        Deprecated.
        This method doesn't support Cash VAT flow, so it's better to use updatePaymentDetail(FIN_PaymentScheduleDetail, FIN_Payment, BigDecimal, boolean)
        Update Payment Schedule amounts with the amount of the Payment Schedule Detail or Payment Detail. Useful when paying orders
        Parameters:
        paymentSchedule - Payment Schedule to be updated
        amount - Amount of the Payment Schedule Detail or Payment Detail
        writeOffAmount - Write off amount, null or 0 if not applicable.
      • updatePaymentScheduleAmounts

        public static void updatePaymentScheduleAmounts​(FIN_PaymentDetail paymentDetail,
                                                        FIN_PaymentSchedule paymentSchedule,
                                                        BigDecimal amount,
                                                        BigDecimal writeOffAmount)
        Update Payment Schedule amounts with the amount of the Payment Schedule Detail or Payment Detail. Useful when paying invoices. It supports Invoices with Cash VAT, creating the records into the Cash VAT management table (InvoiceTaxCashVAT)
        Parameters:
        paymentDetail - payment
        paymentSchedule - Payment Schedule to be updated
        amount - Amount of the Payment Schedule Detail or Payment Detail
        writeOffAmount - Write off amount, null or 0 if not applicable.
      • getPaymentFromPaymentProposal

        public static List<String> getPaymentFromPaymentProposal​(FIN_PaymentProposal paymentProposal)
        Method used to get a list of payments identifiers associated to a payment proposal
        Parameters:
        paymentProposal -
        Returns:
        List of payment identifiers
      • processPayment

        public static OBError processPayment​(VariablesSecureApp vars,
                                             ConnectionProvider conn,
                                             String strAction,
                                             FIN_Payment payment)
                                      throws Exception
        It calls the PAyment Process for the given payment and action.
        Parameters:
        vars - VariablesSecureApp with the session data.
        conn - ConnectionProvider with the connection being used.
        strAction - String with the action of the process. {P, D, R}
        payment - FIN_Payment that needs to be processed.
        Returns:
        a OBError with the result message of the process.
        Throws:
        Exception
      • processPayment

        public static OBError processPayment​(VariablesSecureApp vars,
                                             ConnectionProvider conn,
                                             String strAction,
                                             FIN_Payment payment,
                                             String comingFrom)
                                      throws Exception
        It calls the PAyment Process for the given payment, action and origin.
        Parameters:
        vars - VariablesSecureApp with the session data.
        conn - ConnectionProvider with the connection being used.
        strAction - String with the action of the process. {P, D, R}
        payment - FIN_Payment that needs to be processed.
        comingFrom - Origin where the process is invoked
        Returns:
        a OBError with the result message of the process.
        Throws:
        Exception
      • processPayment

        public static OBError processPayment​(VariablesSecureApp vars,
                                             ConnectionProvider conn,
                                             String strAction,
                                             FIN_Payment payment,
                                             String comingFrom,
                                             String selectedCreditLineIds)
                                      throws Exception
        It calls the PAyment Process for the given payment, action and origin.
        Parameters:
        vars - VariablesSecureApp with the session data.
        conn - ConnectionProvider with the connection being used.
        strAction - String with the action of the process. {P, D, R}
        payment - FIN_Payment that needs to be processed.
        comingFrom - Origin where the process is invoked
        selectedCreditLineIds - Id's of selected lines in Credit to Use grid
        Returns:
        a OBError with the result message of the process.
        Throws:
        Exception
      • processPayment

        public static OBError processPayment​(ProcessBundle pb,
                                             String strAction,
                                             FIN_Payment payment,
                                             String comingFrom,
                                             String selectedCreditLineIds,
                                             boolean doFlush)
                                      throws Exception
        It calls the Payment Process using the given ProcessBundle
        Parameters:
        pb - ProcessBundle already created and initialized. This improves the performance when calling this method in a loop
        payment - FIN_Payment that needs to be processed.
        comingFrom - Origin where the process is invoked
        selectedCreditLineIds - Id's of selected lines in Credit to Use grid
        doFlush - Force to flush inside the method
        Returns:
        a OBError with the result message of the process.
        Throws:
        Exception
      • processPaymentProposal

        public static OBError processPaymentProposal​(VariablesSecureApp vars,
                                                     ConnectionProvider conn,
                                                     String strProcessProposalAction,
                                                     String strFinPaymentProposalId)
                                              throws Exception
        It calls the Payment Proposal Process for the given payment proposal and action.
        Parameters:
        vars - VariablesSecureApp with the session data.
        conn - ConnectionProvider with the connection being used.
        strProcessProposalAction - String with the action of the process. {GSP, RE}
        strFinPaymentProposalId - String with FIN_PaymentProposal Id to be processed.
        Returns:
        a OBError with the result message of the process.
        Throws:
        Exception
      • processBankStatement

        public static OBError processBankStatement​(VariablesSecureApp vars,
                                                   ConnectionProvider conn,
                                                   String strBankStatementAction,
                                                   String strBankStatementId)
                                            throws Exception
        It calls the Bank Statement Process for the given bank statement and action.
        Parameters:
        vars - VariablesSecureApp with the session data.
        conn - ConnectionProvider with the connection being used.
        strBankStatementAction - String with the action of the process. {P, R}
        strBankStatementId - String with FIN_BankStatement Id to be processed.
        Returns:
        a OBError with the result message of the process.
        Throws:
        Exception
      • createPSD

        public static FIN_PaymentScheduleDetail createPSD​(BigDecimal amount,
                                                          FIN_PaymentSchedule paymentSchedule,
                                                          FIN_PaymentSchedule paymentScheduleInvoice,
                                                          Organization organization,
                                                          BusinessPartner businessPartner)
        Method to create a new Payment Schedule Detail (PSD)
        Parameters:
        amount - Amount of the PSD
        paymentSchedule - The PS that the PSD will belong to
        paymentScheduleInvoice - The PS Invoice that the PSD will belong to
        businessPartner - The BP of the PSD
        Returns:
        newPSD The newly created PSD
      • createPSD

        public static FIN_PaymentScheduleDetail createPSD​(BigDecimal amount,
                                                          FIN_PaymentSchedule paymentSchedule,
                                                          FIN_PaymentSchedule paymentScheduleInvoice,
                                                          FIN_PaymentDetail paymentDetails,
                                                          Organization organization,
                                                          BusinessPartner businessPartner)
        Method to create a new Payment Schedule Detail (PSD)
        Parameters:
        amount - Amount of the PSD
        paymentSchedule - The PS that the PSD will belong to
        paymentScheduleInvoice - The PS Invoice that the PSD will belong to
        paymentDetails - The PD to which the PSD will be related
        businessPartner - The BP of the PSD
        Returns:
        newPSD The newly created PSD