Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.fin.bo.invoicear;
- import org.jleaf.erp.fin.FinanceConstantsForSasa;
- import org.jleaf.erp.fin.FinanceExceptionConstantsForSasa;
- import org.jleaf.erp.fin.dao.HandoverInvoiceArDao;
- import org.jleaf.erp.fin.entity.HandoverInvoiceAr;
- import org.jleaf.common.CommonExceptionConstants;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.BusinessTransaction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.DefaultBusinessTransaction;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.util.GsonUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Service;
- //@formatter:off
- @Service
- @InfoIn(value = {
- @Info(name = "id", description = "Handover Invoice Ar back id", type = Long.class),
- @Info(name = "version", description = "Handover Invoice Ar back version", type = Long.class),
- @Info(name = "workflowStatus", description = "workflow status", type = String.class),
- @Info(name = "tenantLoginId", description = "tenant login id", type = Long.class),
- @Info(name = "userLoginId", description = "user login id", type = Long.class),
- @Info(name = "roleLoginId", description = "role login id", type = Long.class),
- @Info(name = "datetime", description = "datetime", type = String.class)
- })
- @InfoOut(value = {
- @Info(name = "id", description = "Handover Invoice Ar Back id", type = Long.class)
- })
- @ErrorList(errorKeys = {
- CommonExceptionConstants.DATA_CANT_CHANGE_CAUSE_TENANT
- })
- //@formatter:on
- public class UnsubmitHandoverInvoiceARBack extends DefaultBusinessTransaction implements BusinessTransaction {
- @Autowired
- HandoverInvoiceArDao handoverInvoiceArDao;
- @Autowired
- @Qualifier("findHandoverInvoiceArById")
- BusinessFunction findHandoverInvoiceArById;
- @Autowired
- @Qualifier("valTenantLoginCanUse")
- BusinessFunction valTenantLoginCanUse;
- @Override
- public String getDescription() {
- return "unsubmit handover invoice ar back";
- }
- @Override
- public Dto prepare(Dto inputDto, Dto originalDto) throws Exception {
- // Validation tenant login id can be use
- Dto loginDto = new Dto();
- loginDto.put("tenantLoginId", inputDto.getLong("tenantLoginId"));
- loginDto.put("userLoginId", inputDto.getLong("userLoginId"));
- loginDto.put("roleLoginId", inputDto.getLong("roleLoginId"));
- valTenantLoginCanUse.execute(loginDto);
- Dto handoverInvoiceArDto = findHandoverInvoiceArById.execute(inputDto);
- if (!handoverInvoiceArDto.getLong("tenantId").equals(inputDto.getLong("tenantLoginId"))) {
- throw new CoreException(CommonExceptionConstants.DATA_CANT_CHANGE_CAUSE_TENANT, "Handover Invoice Ar Back");
- }
- handoverInvoiceArDto.put("workflowStatus", inputDto.getString("workflowStatus"));
- handoverInvoiceArDto.put("statusDoc", FinanceConstantsForSasa.DRAFT_TRANSACTION);
- handoverInvoiceArDto.put("version", inputDto.getLong("version"));
- this.prepareUpdateAudit(handoverInvoiceArDto, inputDto.getLong("userLoginId"), inputDto.getString("datetime"));
- inputDto.put("handoverInvoiceArDto", handoverInvoiceArDto);
- return null;
- }
- @Override
- public Dto process(Dto inputDto, Dto originalDto) throws Exception {
- Dto handoverInvoiceArDto = inputDto.getDto("handoverInvoiceArDto");
- HandoverInvoiceAr handoverInvoiceAr = GsonUtil.fromDto(handoverInvoiceArDto, HandoverInvoiceAr.class);
- handoverInvoiceAr = handoverInvoiceArDao.merge(handoverInvoiceArDto.getLong("id"), handoverInvoiceAr);
- return new Dto().put("id", handoverInvoiceAr.getId());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement