Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.---.contabilita.plus.process;
- public class FIN_ContRateFinancingProcess implements IBusinessLogicFragment {
- private static Logger log = (ServiceCore.getDMLogger()).retrieveLogger(FIN_ContRateFinancingProcess.class);
- private IDataModel data;
- private String trxName;
- private Integer ad_org_id;
- private Integer ad_client_id;
- private BigDecimal rateAmt;
- private Integer financingRateId;
- private Integer financingId;
- private Integer chargeId;
- private Integer projectId;
- private final String tipoAddSoloInc = "SOLO_INC";
- @Override
- public void init(IComposableBusinessLogic process, IDataModel params) {
- this.data = process.getSessionProps();
- this.trxName = process.get_TrxName();
- this.financingRateId = params.getInt(DMFINCEFinancingRate.COLUMNNAME_FINCE_FinancingRate_ID);
- this.ad_org_id = data.getInt("#" + DMFINCEFINANCING.COLUMNNAME_AD_Org_ID);
- this.ad_client_id = data.getInt("#" + DMFINCEFINANCING.COLUMNNAME_AD_Client_ID);
- this.rateAmt = params.getBigDecimal(DMFINCEFinancingRate.COLUMNNAME_FIN_FinancingAmtRate);
- this.financingId = params.getInteger(DMFINCEFINANCING.COLUMNNAME_FINCE_FINANCING_ID);
- this.chargeId = params.getInteger(DMFINCEFinancingRate.COLUMNNAME_C_Charge_ID);
- //this.projectId = params.getInteger(DMFINCEFinancingRate.columnname_c_project_id); C_PROJECT_ID non c'è nel data model
- }
- @Override
- public String doIt() {
- String esito = "KO";
- if (financingRateId != null && financingRateId > 0) {
- String tipoAddebito = getTipoAddebito();
- Integer bpartnerID = getBPartnerFromFinancing();
- Integer docTypeId = getDocTypeId(tipoAddebito);
- Integer accountID = getAccountId();
- java.sql.Timestamp dataIscrBil = getDataIscrBil();
- if (tipoAddebito != null && tipoAddebito != "") {
- if (docTypeId != null && docTypeId > 0) {
- if (bpartnerID != null && bpartnerID > 0) {
- if (tipoAddSoloInc.equalsIgnoreCase(tipoAddebito)) { // Tipo
- // addebito
- // SOLO_INC
- try {
- // Builder che crea la Invoice
- IInvoiceBuilder i_ib = InvoiceBuilder.get(data, ad_org_id, bpartnerID, docTypeId,
- dataIscrBil, trxName); // interfaccia
- DMCInvoice invoice = i_ib.build();
- invoice.save(trxName);
- Integer invoiceID = invoice.getRecordID();
- if (invoiceID != null && invoiceID > 0) {
- if (accountID != null && accountID > 0) {
- setCInvoiceFK(invoiceID);
- // Builder che crea la InvoiceLine
- IInvoiceLineBuilder iLine_ib = InvoiceLineBuilder.get(data, invoice, trxName)
- .witAmt(rateAmt); // interfaccia
- DMCInvoiceLine invoiceLine = iLine_ib.build();
- if (projectId != null && projectId > 0) {
- invoiceLine.setC_Project_ID(projectId);
- }
- if (chargeId != null && chargeId > 0) {
- invoiceLine.setC_Charge_ID(chargeId);
- }
- invoiceLine.save(trxName);
- esito="OK";
- return esito;
- }
- return esito;
- }
- return esito;
- } catch (Exception e) {
- log.log(Level.SEVERE, e.getLocalizedMessage(), e);
- throw new DataModelException(e);
- }
- }
- return esito;
- }
- return esito;
- }
- return esito;
- }
- return esito;
- }
- return esito;
- }
- //INSERIRE PIù TRY CATCH CON I VARI LOG
- protected void setCInvoiceFK(Integer invoiceID) {
- IDataModel financing = ServiceCore.getDataModel(data, DMFINCEFINANCING.TableName,
- financingId, trxName);
- financing.setInt(DMFINCEFINANCING.COLUMNNAME_C_Invoice_ID, invoiceID);
- financing.getInt(DMFINCEFINANCING.COLUMNNAME_C_Invoice_ID);
- financing.save(trxName);
- }
- private Integer getAccountId() {
- IDataModel financing = ServiceCore.getDataModel(data, DMFINCEFINANCING.TableName, financingId, trxName);
- Integer accountId = financing.getInt(DMFINCEFINANCING.COLUMNNAME_FINCE_RegSrcFinancing_ID);
- return accountId;
- }
- private String getTipoAddebito() {
- String sql = "SELECT " + DMFINCEFINANCING.COLUMNNAME_FIN_FinancingTypeCharge + " FROM "
- + DMFINCEFINANCING.TableName + " WHERE " + DMFINCEFINANCING.COLUMNNAME_FINCE_FINANCING_ID + " = ?";
- String tipoAddebitoFin = DBUtils.getValue(trxName, sql, financingId);
- if (tipoAddebitoFin != null && tipoAddebitoFin != "") {
- return tipoAddebitoFin;
- } else {
- sql = "SELECT " + DMFINCESrcFinancing.COLUMNNAME_FIN_FinancingTypeCharge + " FROM "
- + DMFINCESrcFinancing.TableName + " WHERE " + DMFINCESrcFinancing.COLUMNNAME_FINCE_SrcFinancing_ID
- + " in (SELECT " + DMFINCEFINANCING.COLUMNNAME_FINCE_SrcFinancing_ID + " FROM "
- + DMFINCEFINANCING.TableName + " WHERE " + DMFINCEFINANCING.COLUMNNAME_FINCE_FINANCING_ID + " = ?)";
- String tipoAddebitoSrcFin = DBUtils.getValue(trxName, sql, financingId);
- return tipoAddebitoSrcFin;
- }
- }
- private Integer getDocTypeId(String tipoAddebito) {
- String sql = "SELECT " + DMFINCEProjectFinanceParam.COLUMNNAME_C_DocType_ID + " FROM "
- + DMFINCEProjectFinanceParam.TableName + " WHERE "
- + DMFINCEProjectFinanceParam.COLUMNNAME_FIN_FinancingTypeCharge + " = ?";
- Integer docTypeId = DBUtils.getValueInt(trxName, sql, tipoAddebito);
- return docTypeId;
- }
- private Integer getBPartnerFromFinancing() {
- String sql = "SELECT " + DMFINCEFINANCING.COLUMNNAME_C_BPartner_ID + " FROM " + DMFINCEFINANCING.TableName
- + " WHERE " + DMFINCEFINANCING.COLUMNNAME_FINCE_FINANCING_ID + " = ?";
- Integer bpartnerID = DBUtils.getValueInt(trxName, sql, financingId);
- return bpartnerID;
- }
- private java.sql.Timestamp getDataIscrBil () {
- String sql = "SELECT " + DMFINCEFINANCING.COLUMNNAME_FIN_DateAllocBalan + " FROM " + DMFINCEFINANCING.TableName
- + " WHERE " + DMFINCEFINANCING.COLUMNNAME_FINCE_FINANCING_ID + " = ?";
- java.sql.Timestamp dataIscrBil = DBUtils.getValueTimestamp(trxName, sql, financingId);
- return dataIscrBil;
- }
- //INSERIRE PIU' CONTROLLI NEI METODI
- @Override
- public void postProcess(boolean success) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement