Projects:Business Partner Settlements/Technical Specification
Contents |
Introduction
In this document is described in detail all the developments that need to be delivered to fulfill the Business Partner Settlement project.
The document is structured in the different main processes that are included in the project.
- Module definition
- BP Settlement window
- Add Credit Payments Pick and Execute
- Add Pending Invoices Pick and Execute
- Process/Cancel/Reopen Process Definition
The code of the module is available in: https://code.openbravo.com/erp/pmods/org.openbravo.financial.bpsettlement
Module Definition
- Module Name
- Business Partner Settlements
- Description
- This module provides the ability to settle Available Credit or Pending Payments of a Business Partner that is both Customer and Provider.
- License
- OBPL
- DB Prefix
- OBFBPS
- javapackage
- org.openbravo.financial.bpsettlement
- Translation Required
- Yes
- Dependant Modules
- Openbravo 3.0 Framework PR14Q3.1 (2.1.24019)
- datapackage
- org.openbravo.financial.bpsettlement
BP Settlement window
- Window Name:Business Partner Settlement
- Help: Window to manage settlements that cancels available credit or pending Payments of a Business Partner.
- Type: Maintain
- Menu folder:Financial Management >> Receivables and Payables >> Transactions. Just above 'Financial Account' window
Header Tab
- Name: Header
- Help: Definition of each settlement created for a business partner.
- UI Pattern: Standard
- Table: OBFBPS_Settlement
- Sequence: 10
- Tab level: 0
Table Definition:
- Name: OBFBPS_Settlement
- TableName: OBFBPS_Settlement
- Java Class Name: BPSettlement
- Window: Business Partner Settlement
Name | Column Name | Mandatory | SeqNo | Reference | Show in Grid (seq) | Default | Definition |
Organization | AD_Org_ID | Yes | 10 | Table Dir only allow transactional Orgs | Yes (10) | ||
---|---|---|---|---|---|---|---|
Settlement Type | BP_Settlement_Type | Yes | 20 | List new BP_Settlement Type:
| Yes (20) | Stored In session: Yes
Do not allow to change when there are lines. Using an Event Handler | |
Settlement Date | SettlementDate | Yes | 30 | Date | Yes (30) | SYSDATE / now() | |
Business Partner | C_BPartner_ID | Yes | 40 | Selector new Customer/Vendor Business Partner:
| Yes (40) | Do not allow to change when there are lines. Using an Event Handler | |
GL Item | C_GLItem_ID | Yes | 50 | GL Item Selector | Yes (50) | ||
Settlement Payment In | FIN_Payment_In_ID | No | 60 | Payment selector | Yes (60) | Read Only Yes | |
Settlement Payment Out | FIN_Payment_Out_ID | No | 70 | Payment selector | Yes (70) | Read Only Yes | |
Description | Description | No | 80 | Text. Length: 2000 | No | ||
Status | BP_Settlement_Status | Yes | 1010 | List new BP Settlement Status:
| Yes (80) | DR | Show In Status Bar Yes
Stored In Session: Yes |
Incoming Amount | Incoming_Amt
(Defined in the ad_column, but not physically in the DB) | No | 1020 | Computed field: Sum of incoming amounts (Credit In and Sales Invoice) | Yes (90) | Show In Status Bar: Yes | |
Outgoing Amount | Outgoing_Amt
(Defined in the ad_column, but not physically in the DB) | No | 1030 | Computed field: Sum of outgoing amounts (Credit Out and Purchase Invoice) | Yes (100) | Show In Status Bar: Yes | |
Add Credit Payments | Add_Credit_Payments_Process
(AD_Column.Name: Add Credit Payments Process) | No | 2010 | Button (Char 1) | No | Y | Display Logic: type credit and status Draft |
Add Not Paid Invoices | Add_Invoices_Process
(AD_Column.Name: Add Invoices Process) | No | 2020 | Button (Char 1) | No | Y | Display Logic: type invoice and status Draft |
Process Settlement | Process_Settlement | No | 2030 | Button (Char 60) new BP Settlement Action List:
| No | CO |
OBFBPS_Settlement_trg trigger
Trigger to avoid modifying any field when the Settlement is in status Processed or Canceled.
When the status is changing from CO to any other it should allow to set FIN_Payment_In_ID and FIN_Payment_Out_ID to null.
Credit In Tab
- Name: Credit In
- Help: Each Payment In with available credit to consume that it is canceled in this settlement.
- UI Pattern: Read Only
- Table: OBFBPS_Credit_Payment
- Sequence: 20
- Tab level: 1
- Display Logic: Settlement Type Credit
- Auxiliary Input: IsSoTrxTab value Y
Table Definition:
- Name: OBFBPS_Credit_Payment
- TableName: OBFBPS_Credit_Payment
- Java Class Name: CreditPayment
- Window: Business Partner Settlement
Name | Column Name | Mandatory | SeqNo | Reference | Show in Grid (seq) | Default | Definition |
Credit Payment | FIN_Payment_ID | Yes | 10 | Payment Selector | Yes (10) | ||
---|---|---|---|---|---|---|---|
Settlement Amount | Settlement_Amt | Yes | 20 | Amount | Yes (20) | ||
Is Sales Transaction | IsSOTrx | Yes | Yes/No | No | @IsSoTrxTab@ (Auxiliary Input value) | Hidden Field |
OBFBPS_Credit_Payment trigger
Trigger to avoid modifying any field when the Settlement is in status Processed or Canceled.
When the status is changing from CO to any other it should allow to set FIN_Payment_In_ID and FIN_Payment_Out_ID to null.
Credit Out Tab
Same as Credit In with these differences:
- Name: Credit Out
- Help: Each Payment Out with available credit to consume that it is canceled in this settlement.
- Sequence: 30
- Tab level: 1
- Auxiliary Input: IsSoTrxTab value N
Sales Invoice Tab
- Name: Sales Invoices
- Help: Each not paid Sales Invoice that it is canceled in this settlement.
- UI Pattern: Read Only
- Table: OBFBPS_Invoice
- Sequence: 40
- Tab level: 1
- Display Logic: Settlement Type Invoice
- Auxiliary Input: IsSoTrxTab value Y
Table Definition:
- Name: OBFBPS_Invoice
- TableName: OBFBPS_Invoice
- Java Class Name: SettledInvoice
- Window: Business Partner Settlement
Name | Column Name | Mandatory | SeqNo | Reference | Show in Grid (seq) | Default | Definition |
Invoice | C_Invoice_ID | Yes | 10 | Invoice Selector | Yes (10) | ||
---|---|---|---|---|---|---|---|
Settlement Amount | Settlement_Amt | Yes | 20 | Amount | Yes (20) | ||
Is Sales Transaction | IsSOTrx | Yes | Yes/No | No | @IsSOTrxTab@ (Auxiliary Input value) | Hidden Field |
OBFBPS_Invoice_Trg trigger
Trigger to avoid modifying any field when the Settlement is in status Processed or Canceled.
Purchase Invoice Tab
Same as Sales Invoice with these differences:
- Name: Purchase Invoice
- Help: Each not paid Purchase Invoice that it is canceled in this settlement.
- Sequence: 50
- Tab level: 1
- Auxiliary Input: IsSoTrxTab value N
Add Credit Payments Pick and Execute
Add Pending Invoices Pick and Execute
Process/Cancel/Reopen Report and Process
Report and Process to manage bp settlements.
- Name: BP Settlement Process.
- UI Pattern: Standard
- Data access level: Organization
- All flags to false
- Parameter Action
- Reference List. BP Settlement Action, the list assigned to the button.
- Validation BP Settlement Valid Actions. Filters the available actions based on the BP_Settlement_Status column value.
- Status Draft (DR): Process (CO)
- Status Processed (CO): Cancel (VO), Reactivate (RE)
- Status Canceled (VO): None (the button should be hidden as well.
- Default value: value of Process_Settlement column.
- Process class: org.openbravo.financial.bpsettlement.process.BPSettlementProcess
- Similar example in Payment Process Report and Process.
BPSettlementProcess java class
Extends org.openbravo.service.db.DalBaseProcess.
Validations:
- Status - action validation.
- Settlements in status DR can only be processed.
- Settlements in status CO can only be canceled or reactivated.
- Settlements in status VO cannot be modified.
Process CO action
This action does an extra validation:
- When it is a invoice settlement type ensure that there are invoices and total amounts for purchase and sales invoices are the same.
- If it is a credit settlement type the same check with credit payments.
- Ensure that there are not invoices and credit payments in the same settlement.
Invoice type
Create and process a Payment In with all the sales Payment Schedule Details included in the OBFBPS_Invoice table for the settlement. Create a similar Payment Out with the purchase Payment Schedule Details.
Add a Payment Detail on each payment using the GL Item defined in the settlement so the total amount of each payment is Zero.
Set the generated payment ids on FIN_Payment_In_ID and FIN_Payment_Out_ID columns.
Set the BP_Settlement_Status to CO and the Process_Settlement to VO
To build the Payments based on the selected Payment Schedule details use the following public method:
org.openbravo.advpaymentmngt.process.FIN_AddPayment.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)
To add the GL Item payment details use the following public method:
org.openbravo.advpaymentmngt.process.FIN_AddPayment.saveGLItem(FIN_Payment payment, BigDecimal glitemAmount, GLItem glitem)
To process the payment use the following public method (strAction: P):
org.openbravo.advpaymentmngt.process.FIN_AddPayment.processPayment(VariablesSecureApp vars, ConnectionProvider conn, String strAction, FIN_Payment payment)
Credit type
Create and process a Payment In with all the sales credit payments included in the OBFBPS_Credit_Payment table. A similar Payment Out is created with the purchase credit payments.
For each selected credit payment update its description with the new payment document number and increment the Used Credit amount by the settled amount. Link the credit payment to the new payment.
Add a Payment Detail on each payment using the GL Item defined in the settlement so the total amount of each payment is Zero.
See an example on how to add the selected credit payments to the new payments on the following method:
org.openbravo.advpaymentmngt.actionHandler.AddPaymentActionHandler.addCredit(FIN_Payment payment, JSONObject jsonparams)
Note that to link the credit payments with the new payment it is used the public method:
org.openbravo.advpaymentmngt.process.FIN_PaymentProcess.linkCreditPayment(FIN_Payment newPayment, BigDecimal usedAmount, FIN_Payment creditPayment)
Cancel VO action
It cancels the Payments generated on this settlement and stored in FIN_Payment_In_ID and FIN_Payment_Out_ID columns.
To cancel the payment use the following public method (strAction: V):
org.openbravo.advpaymentmngt.process.FIN_AddPayment.processPayment(VariablesSecureApp vars, ConnectionProvider conn, String strAction, FIN_Payment payment)
Sets the BP_Settlement_Status to VO and the Process_Settlement to VO
Reactivate RE action
As in Cancel action cancels the payment generated on the settlement.
Sets the BP_Settlement_Status to DR and the Process_Settlement to CO
Sets to null the FIN_Payment_In_ID and FIN_Payment_Out_ID columns.