Search in sources :

Example 1 with MHRPaySelection

use of org.eevolution.model.MHRPaySelection in project adempiere by adempiere.

the class HRPaySelectionCreateFrom method doIt.

//	prepare
/**
     * Perform process.
     * @return Message
     * @throws Exception if not successful
     */
protected String doIt() throws Exception {
    log.info("Pay Selection Id=" + getRecord_ID() + ", Process=" + getPayrollProcessId() + ", Payroll=" + getPayrollId() + ", BP Group=" + getBusinessPartnerGroupId() + ", PaymentRule=" + getPaymentRule() + ", Concept=" + getGlobalPayrollConceptId() + ", Depatment=" + getDepartmentId() + ", Job=" + getPayrollJobId());
    MHRPaySelection paySelection = (MHRPaySelection) getInstance(get_TrxName());
    paySelection.setHR_Process_ID(getPayrollProcessId());
    paySelection.saveEx();
    List<Object> parameters = new ArrayList<Object>();
    if (getRecord_ID() == 0)
        throw new IllegalArgumentException("@HR_PaySelection_ID@ @Notfound@");
    if (paySelection.isProcessed())
        throw new IllegalArgumentException("@HR_PaySelection_ID@ @Processed@");
    parameters.add(getPayrollProcessId());
    parameters.add(true);
    parameters.add(getRecord_ID());
    StringBuilder where = new StringBuilder();
    where.append(MHRMovement.COLUMNNAME_HR_Process_ID).append("=?");
    // Only Concept isPaid
    where.append(" AND HR_Concept_ID IN(SELECT HR_Concept_ID FROM HR_Concept WHERE IsPaid=?)");
    where.append(// Not Exist in PaySelection Process or PaySelection Actual
    " AND HR_Movement_ID NOT IN(SELECT HR_Movement_ID " + " FROM HR_PaySelectionLine " + " WHERE HR_PaySelectionCheck_ID > 0 OR HR_PaySelection_ID=?)");
    if (getBusinessPartnerGroupId() > 0) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_C_BP_Group_ID).append("=?");
        parameters.add(getBusinessPartnerGroupId());
    }
    if (getEmployeeTypeId() > 0) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_HR_EmployeeType_ID).append("=?");
        parameters.add(getEmployeeTypeId());
    }
    if (getBusinessPartnerId() > 0) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_C_BPartner_ID).append("=?");
        parameters.add(getBusinessPartnerId());
    }
    if (getPaymentRule() != null) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_PaymentRule).append("=?");
        parameters.add(getPaymentRule());
    }
    if (getGlobalPayrollConceptId() > 0) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_HR_Concept_ID).append("=?");
        parameters.add(getGlobalPayrollConceptId());
    }
    if (getDepartmentId() > 0) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_HR_Department_ID).append("=?");
        parameters.add(getDepartmentId());
    }
    if (getPayrollJobId() > 0) {
        where.append(" AND ").append(MHRMovement.COLUMNNAME_HR_Job_ID).append("=?");
        parameters.add(getPayrollJobId());
    }
    List<MHRMovement> movements = new Query(getCtx(), MHRMovement.Table_Name, where.toString(), get_TrxName()).setClient_ID().setParameters(parameters).list();
    AtomicInteger lineNo = new AtomicInteger();
    movements.stream().filter(movement -> movement != null).forEach(movement -> {
        I_C_BPartner partner = movement.getC_BPartner();
        Optional<MHREmployee> employeeOption = Optional.ofNullable(MHREmployee.getActiveEmployee(getCtx(), partner.getC_BPartner_ID(), movement.get_TrxName()));
        String paymentRule = employeeOption.flatMap(employee -> Optional.ofNullable(employee.getPaymentRule())).orElse(Optional.ofNullable(partner.getPaymentRule()).orElse(MHREmployee.PAYMENTRULE_DirectDeposit));
        lineNo.updateAndGet(count -> count + 10);
        MHRPaySelectionLine paySelectionLine = new MHRPaySelectionLine(getCtx(), 0, get_TrxName());
        paySelectionLine.setHR_PaySelection_ID(getRecord_ID());
        paySelectionLine.setHR_Movement_ID(movement.getHR_Movement_ID());
        paySelectionLine.setPaymentRule(paymentRule);
        paySelectionLine.setAD_Org_ID(paySelection.getAD_Org_ID());
        paySelectionLine.setLine(lineNo.get());
        paySelectionLine.setOpenAmt(movement.getAmount().setScale(2, BigDecimal.ROUND_HALF_DOWN));
        paySelectionLine.setPayAmt(movement.getAmount().setScale(2, BigDecimal.ROUND_HALF_DOWN));
        paySelectionLine.setDescription(partner.getName() + " " + partner.getName2());
        paySelectionLine.setDifferenceAmt(BigDecimal.ZERO.ZERO);
        paySelectionLine.setDiscountAmt(BigDecimal.ZERO);
        paySelectionLine.setIsManual(false);
        paySelectionLine.setIsSOTrx(false);
        paySelectionLine.setIsActive(true);
        paySelectionLine.saveEx();
    });
    return "@HR_PaySelection_ID@  - #" + lineNo.get();
}
Also used : BigDecimal(java.math.BigDecimal) java.util(java.util) Query(org.compiere.model.Query) MHREmployee(org.eevolution.model.MHREmployee) MHRMovement(org.eevolution.model.MHRMovement) MHRPaySelection(org.eevolution.model.MHRPaySelection) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MHRPaySelectionLine(org.eevolution.model.MHRPaySelectionLine) I_C_BPartner(org.compiere.model.I_C_BPartner) MHRPaySelectionLine(org.eevolution.model.MHRPaySelectionLine) Query(org.compiere.model.Query) MHRMovement(org.eevolution.model.MHRMovement) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MHRPaySelection(org.eevolution.model.MHRPaySelection) I_C_BPartner(org.compiere.model.I_C_BPartner) MHREmployee(org.eevolution.model.MHREmployee)

Example 2 with MHRPaySelection

use of org.eevolution.model.MHRPaySelection in project adempiere by adempiere.

the class WHRPayPrint method loadPaymentRuleInfo.

//  loadPaymentRule
/**
	 *  PaymentRule changed - load DocumentNo, NoPayments,
	 *  enable/disable EFT, Print
	 */
private void loadPaymentRuleInfo() {
    if (fPaymentRule.getSelectedItem() == null)
        return;
    ValueNamePair pp = fPaymentRule.getSelectedItem().toValueNamePair();
    if (pp == null)
        return;
    String PaymentRule = pp.getValue();
    log.info("PaymentRule=" + PaymentRule);
    fNoPayments.setText(" ");
    int HR_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
    String msg = loadPaymentRuleInfo(HR_PaySelection_ID, PaymentRule);
    if (noPayments != null)
        fNoPayments.setText(noPayments);
    bProcess.setEnabled(PaymentRule.equals("T"));
    if (documentNo != null)
        fDocumentNo.setValue(documentNo);
    if (documentNo != null) {
        MHRPaySelection hrps = new MHRPaySelection(Env.getCtx(), HR_PaySelection_ID, null);
        if (hrps.get_ValueAsInt("CheckNo") > 0)
            fDocumentNo.setValue(hrps.get_ValueAsInt("CheckNo"));
        else
            fDocumentNo.setValue(documentNo);
    }
    if (msg != null && msg.length() > 0)
        FDialog.error(m_WindowNo, form, msg);
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) HRPayPrint(org.eevolution.service.HRPayPrint) MHRPaySelection(org.eevolution.model.MHRPaySelection)

Example 3 with MHRPaySelection

use of org.eevolution.model.MHRPaySelection in project adempiere by adempiere.

the class HRPaySelectionCreateCheck method doIt.

//	prepare
/**
     * Perform process.
     * @return Message (clear text)
     */
protected String doIt() {
    log.info("HR_PaySelection_ID=" + getRecord_ID() + ", PaymentRule=" + getPaymentRule());
    MHRPaySelection paySelection = (MHRPaySelection) getInstance(get_TrxName());
    if (paySelection.get_ID() == 0)
        throw new IllegalArgumentException("Not found HR_PaySelection_ID=" + getRecord_ID());
    if (paySelection.isProcessed())
        throw new IllegalArgumentException("@Processed@");
    Arrays.stream(paySelection.getLines(true)).filter(paySelectionLine -> paySelectionLine != null && (paySelectionLine.isActive() && !paySelectionLine.isProcessed())).forEach(paySelectionLine -> {
        createCheck(paySelectionLine);
    });
    paySelection.setProcessed(true);
    paySelection.save();
    return "@C_PaySelectionCheck_ID@ - #" + paySelectionChecks.size();
}
Also used : Arrays(java.util.Arrays) List(java.util.List) MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) MHRPaySelection(org.eevolution.model.MHRPaySelection) X_C_Order(org.compiere.model.X_C_Order) Optional(java.util.Optional) MHRPaySelectionLine(org.eevolution.model.MHRPaySelectionLine) ArrayList(java.util.ArrayList) MHRPaySelection(org.eevolution.model.MHRPaySelection)

Aggregations

MHRPaySelection (org.eevolution.model.MHRPaySelection)3 MHRPaySelectionLine (org.eevolution.model.MHRPaySelectionLine)2 BigDecimal (java.math.BigDecimal)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 I_C_BPartner (org.compiere.model.I_C_BPartner)1 Query (org.compiere.model.Query)1 X_C_Order (org.compiere.model.X_C_Order)1 ValueNamePair (org.compiere.util.ValueNamePair)1 MHREmployee (org.eevolution.model.MHREmployee)1 MHRMovement (org.eevolution.model.MHRMovement)1 MHRPaySelectionCheck (org.eevolution.model.MHRPaySelectionCheck)1 HRPayPrint (org.eevolution.service.HRPayPrint)1