Class ContractService
java.lang.Object
es.kukenan.smartfi.microservice.smartficore.service.ContractService
Service to reply contracts invocations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AccountBankRepositoryBank Account repository.private static final StringDocument state active name.private static final StringAddi requested file name.private static final StringAdvance constant.private AdvanceProductServiceAdvance product service.private static StringApc product ("producto") constant.private static StringApc type ("tipo") constant.private ApcApiClientApc client manager.private ApcScoreRepositoryApcScore repository.private EFacturaPtyApiClientEFacturaPty api client.private StringApplication files destination.private static final StringDocument state approved name.private static final StringDocument state approved payment pending name.private AuditServiceBackoffice endpoints implementation.private BackofficeApiClientBackoffice clients manager.private static final StringClosed group name.private static final StringDocument state granted with commission name.private static final StringDocument state company affiliation name.private CompanyRepositoryCompany Repository.private static final StringContract requested file name.private ContractCacheOperationContractCacheOperation contractCacheOperation.private ContractDocumentRepositoryContract Document repository.private ContractRepositoryContractRepository contractRepository.private ContractStateRepositoryContract State repository.private static final StringCredit constant.private CreditProductServiceCredit product service.private booleanDo APC Score validation flag.private DocumentStateRepositoryDocument State repository.private booleanDo UltraFace validation flag.private static intTEMPORAL DATA FOR GENERATING CONTRACT(APPOINTMENT).private EntityRepositoryEntity repository.private final org.springframework.data.domain.ExampleMatcherExample matcher configuration.private static final StringDocument state finished client name.private static final StringDocument state finished name.private static final StringGranted group name.private static final StringInvoice requested file name.private KafkaControllerKafka Controller.private static final StringDocument state late payment name.private static final intProduct main wallet.private NotificationCreatedEventMapperNotification event mapper.private OnboardingServiceOnboarding service.private static final StringOpen request group name.private static final StringDocument state paid name.private static final StringDocument state payment pending name.private PaymentServicePayment service.private static final StringPending Commission group name.private static final StringDocument state pending signature for credit.private static final StringDocument state pre approved name.private static intProduct ADVANCE (Prestamo fijo).private static intProduct CREDIT (Credito fijo).private static final StringProof of payment requested file name.private static final StringDocument state rejected name.private es.kukenan.smartfi.common.context.RequestContextManagerRequest context manager.private RuleServiceRule service.private TransfersUtilsUtilities for core transfers.private UltraFaceApiClientUltraFace api client.private StringUltraface folder path.private static final StringDocument state under review.private UserCompanyRepositoryUser Company repository.private UserContractDocumentEventMapperContract Document event mapper.private UserMongoRepositoryUser Mongo document repository.private UserRepositoryUsers repository.private static final StringDocument state waiting document submission name.private static final StringDocument state waiting documents name.private WalletProductRepositoryWallet repository. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBodyDataToContract(Contract contract, String product, Float amount, Integer deadline, Integer deadlineUnit, Integer userCode, String sponsor, Optional<AccountBank> accountBank, String initialStatus, String contractNumber) Add body data to contract.calculateComission(Contract contract, Company company) Calculate advance contract comission.calculateCostoOperativo(Contract contract, Company company) Calculate advance contract operative cost.calculatePaymentDate(int addValue, int deadlineUnit) Calculate payment approximated date.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>>changeApplicationsToPayed(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateListOfContractsRequestDto updateListOfContractsRequestDto, String userId, String product) Change a list of application identifier from PAYMENT_PENDING (credit) or APPROVED_PAYMENT_PENDING_NAME (advance) to PAYED (advance) or ACTIVE (credit).private FilecheckFilePath(String userId, String contractId) createContract(String name, Entity entity, User user) Create contract for Entity and User.private ContractDocumentcreateContractDocument(String contractDocumentId, Contract contract, DocumentState documentState, String savedFileName, String savedFilePath, Long documentId, int contractDocumentType) private ContractfindContract(String contractId, String userId) Retrieve contract entity.private es.kukenan.smartfi.microservice.backoffice.dtos.core.invoice.request.InvoiceGeneralDatageneralDataFromApplication(Contract application) Create Invoice General Data from application.private voidgenerateAddiFile(Contract contract) Create Direct Discount Authorization file.voidgenerateContractFile(Contract contract, String backofficeUserId, javax.servlet.http.HttpServletResponse response) Generate pdf contract document file.voidgenerateInvoiceFile(Contract application, Company company) Create Invoice document with API.private voidgenerateItem(Contract application, List<es.kukenan.smartfi.microservice.backoffice.dtos.core.invoice.request.InvoiceItem> invoiceItems, Company company) Create an Invoice Item and Add to inoice items list.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>>getApprovedContracts(String userId) Retrieve approved contracts.private voidgetCompanyContractCountAndTotal(List<String> contractStates, String product, Integer companyId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.CountInfoDto countInfoDto, String group) Get count with filter.private LonggetContractCount(List<ContractState> contractStateList, User user, String sponsorId, String product, Integer companyId) Get count of Contracts by filter.private List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.BasicGraphInfoDto>getContractCountFiltered(List<String> contractStates, String product) Get count with filter.es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractgetContractDetail(String userId, String contractId, String userToken) Retrieve contract detail.private ContractDocumentgetContractDocument(Contract application, ContractDocument contractDocument, String contractDocumentId, DocumentState documentState, String savedFileName, String savedFilePath, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.requestedfiles.DataObject contractFile) Check contract document in contract documents list.voidgetContractDocumentFile(String contractDocumentId, String userId, javax.servlet.http.HttpServletResponse response) Get contract document file.private ContractgetContractExample(Integer contractStateId, User user, String type, String sponsorId, Company company, String contractNumber) Build contract example for query.es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>getContracts(String userId, Integer pageNumber, Integer pageSize, String sortedBy, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.GetApplicationsRequestDto getApplicationsRequestDto, es.kukenan.smartfi.common.security.WalletAuthentication authentication) Retrieve contracts.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.clients.dto.ContractCompanyInfoDto>>getContractsAndCompanyInfo(String userId) Retrieve approved contracts.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.CountInfoDto>>getContractsCount(String userId, es.kukenan.smartfi.common.security.WalletAuthentication authentication) Retrieve contracts count.List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractStateDto>getContractStates(String product) Retrieve contract states.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>saveContract(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.NewApplicationRequestDto requestDto, String userIp, String userAgent) Create new application from Client/Sponsor.voidsaveFile(org.springframework.web.multipart.MultipartFile file, String destination, String userId, String contractId) Save file to path.private voidsaveFileAndUpdateContractDocument(String userUpdateId, org.springframework.web.multipart.MultipartFile file, ContractDocument contractDocument, DocumentState documentState, String newContractState, Contract contract, List<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.requestedfiles.DataObject> requestedFiles, es.kukenan.smartfi.dto.BasicApiResponse result, es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract> responseDto, boolean fileNotFound, String userToken) private voidsaveGeneratedProduct(User user, Contract application, String product, BigDecimal quota, int deadline, int deadlineUnit, LocalDate advancePaymentDay, es.kukenan.smartfi.microservice.onboarding.events.common.CompanyDto companyDto) Generate requested product.private es.kukenan.smartfi.microservice.backoffice.dtos.core.invoice.request.InvoiceTotalDatatotalDataFromApplication(Contract application) Create Invoice Total Data from application.private StringtranslateDocumentType(String document) Transform document type name on DB to spanish.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>updateContractAppointment(String contractId, String userId, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.appointments.AppointmentDto appointmentDto) Update contract with appointment.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>updateContractDocumentStatus(String contractDocumentId, String userId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateContractDocumentRequestDto requestDto, String userToken) Update contract document status.private ContractupdateContractState(String state, Contract contract) Update Contract state.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>updateContractStatus(String contractId, String userId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractStatusRequestDto contractStatusRequestDto, String userToken) Change application status.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>uploadContractualFile(String contractId, String userUpdateId, org.springframework.web.multipart.MultipartFile file, String process, String userToken) Save specific contractual document file.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>uploadFile(String contractId, String userId, List<org.springframework.web.multipart.MultipartFile> files, Integer companyId) Save files to application.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>uploadSpecificFile(String contractDocumentId, String userUpdateId, org.springframework.web.multipart.MultipartFile file, String userToken) Save specific contract document file.private BooleanvalidActiveRequest(String product, String userId, Integer advanceCount) Check if user has active request.private BooleanvalidFortnightDays(String product, Integer companyId) Check if can request this fortnight.private BooleanvalidFortnightRequest(String product, String userId) Check if user has active request this fortnight.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Boolean>>validNewContract(String userId, String type) Validation if user can create Contract.
-
Field Details
-
applicationsFolderPath
Application files destination. -
doUltraFaceValidation
@Value("${ultraface.doValidation}") private boolean doUltraFaceValidationDo UltraFace validation flag. -
doApcScoreValidation
@Value("${apc.doValidation}") private boolean doApcScoreValidationDo APC Score validation flag. -
ultrafacePath
Ultraface folder path. -
OPEN_REQUEST_GROUP_NAME
Open request group name.- See Also:
-
GRANTED_GROUP_NAME
Granted group name.- See Also:
-
CLOSED_GROUP_NAME
Closed group name.- See Also:
-
PENDING_COMMISSION_GROUP_NAME
Pending Commission group name.- See Also:
-
PRE_APPROVED_NAME
Document state pre approved name.- See Also:
-
UNDER_REVIEW_NAME
Document state under review.- See Also:
-
PENDING_SIGNATURE_NAME
Document state pending signature for credit.- See Also:
-
REJECTED_NAME
Document state rejected name.- See Also:
-
FINISHED_NAME
Document state finished name.- See Also:
-
FINISHED_CLIENT_NAME
Document state finished client name.- See Also:
-
WAITING_DOCUMENTS_NAME
Document state waiting documents name.- See Also:
-
APPROVED_NAME
Document state approved name.- See Also:
-
PAYMENT_PENDING_NAME
Document state payment pending name.- See Also:
-
APPROVED_PAYMENT_PENDING_NAME
Document state approved payment pending name.- See Also:
-
LATE_PAYMENT_NAME
Document state late payment name.- See Also:
-
COMPANY_AFFILIATION_NAME
Document state company affiliation name.- See Also:
-
PAID_NAME
Document state paid name.- See Also:
-
ACTIVE_NAME
Document state active name.- See Also:
-
COMMISSION_PAID_NAME
Document state granted with commission name.- See Also:
-
WAITING_CONTRACT_DOCUMENT_NAME
Document state waiting document submission name.- See Also:
-
CONTRACT_REQUESTED_NAME
Contract requested file name.- See Also:
-
INVOICE_REQUESTED_NAME
Invoice requested file name.- See Also:
-
ADDI_REQUESTED_NAME
Addi requested file name.- See Also:
-
PROOF_OF_PAYMENT_REQUESTED_NAME
Proof of payment requested file name.- See Also:
-
CREDIT_PRODUCT
Credit constant.- See Also:
-
MAIN_WALLET
private static final int MAIN_WALLETProduct main wallet.- See Also:
-
ADVANCE_PRODUCT
Advance constant.- See Also:
-
entity
private static int entityTEMPORAL DATA FOR GENERATING CONTRACT(APPOINTMENT). -
productCredit
private static int productCreditProduct CREDIT (Credito fijo). -
productAdvance
private static int productAdvanceProduct ADVANCE (Prestamo fijo). -
APC_TYPE
Apc type ("tipo") constant. -
APC_PRODUCT
Apc product ("producto") constant. -
exampleMatcher
private final org.springframework.data.domain.ExampleMatcher exampleMatcherExample matcher configuration. -
contractRepository
ContractRepository contractRepository. -
contractCacheOperation
ContractCacheOperation contractCacheOperation. -
userRepository
Users repository. -
creditProductService
Credit product service. -
advanceProductService
Advance product service. -
userCompanyRepository
User Company repository. -
entityRepository
Entity repository. -
contractStateRepository
Contract State repository. -
accountBankRepository
Bank Account repository. -
contractDocumentRepository
Contract Document repository. -
documentStateRepository
Document State repository. -
apcScoreRepository
ApcScore repository. -
onboardingService
Onboarding service. -
kafkaController
Kafka Controller. -
notificationCreatedEventMapper
Notification event mapper. -
backofficeApiClient
Backoffice clients manager. -
apcApiClient
Apc client manager. -
companyRepository
Company Repository. -
ultraFaceApiClient
UltraFace api client. -
apiEFacturaPtyApiClient
EFacturaPty api client. -
requestContextManager
@Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManagerRequest context manager. -
auditService
Backoffice endpoints implementation. -
userContractDocumentEventMapper
Contract Document event mapper. -
userMongoRepository
User Mongo document repository. -
paymentService
Payment service. -
walletProductRepository
Wallet repository. -
transfersUtils
Utilities for core transfers. -
ruleService
Rule service.
-
-
Constructor Details
-
ContractService
public ContractService()
-
-
Method Details
-
getContractsCount
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.CountInfoDto>> getContractsCount(String userId, es.kukenan.smartfi.common.security.WalletAuthentication authentication) Retrieve contracts count.- Parameters:
userId- user id.authentication- user credentials.- Returns:
- the count.
-
getCompanyContractCountAndTotal
private void getCompanyContractCountAndTotal(List<String> contractStates, String product, Integer companyId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.CountInfoDto countInfoDto, String group) Get count with filter.- Parameters:
contractStates- states to filter count.product- product to count.companyId- company identifier.countInfoDto- count info dto to update.group- group to update.
-
getContractCountFiltered
private List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.BasicGraphInfoDto> getContractCountFiltered(List<String> contractStates, String product) Get count with filter.- Parameters:
contractStates- states to filter count.product- product to count.- Returns:
- map response.
-
getContractCount
private Long getContractCount(List<ContractState> contractStateList, User user, String sponsorId, String product, Integer companyId) Get count of Contracts by filter.- Parameters:
contractStateList- list of states to search.user- user entity.sponsorId- user sponsor identifier.product- product type.companyId- company identifier.- Returns:
- contracts count value.
-
getContracts
public es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract> getContracts(String userId, Integer pageNumber, Integer pageSize, String sortedBy, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.GetApplicationsRequestDto getApplicationsRequestDto, es.kukenan.smartfi.common.security.WalletAuthentication authentication) Retrieve contracts.- Parameters:
userId- user id.pageNumber- number of page to get.pageSize- size of list to return.sortedBy- sort param.getApplicationsRequestDto- body for filtering.authentication- user credentials.- Returns:
- the contracts.
-
getContractExample
private Contract getContractExample(Integer contractStateId, User user, String type, String sponsorId, Company company, String contractNumber) Build contract example for query.- Parameters:
contractStateId- contract state identifier.user- User for search.type- contract type.sponsorId- Sponsor identifier.company- Company data.contractNumber- contract number.- Returns:
- Contract example to search.
-
validFortnightDays
Check if can request this fortnight.- Parameters:
product- product type.companyId- company identifier.- Returns:
- flag if can request.
-
validFortnightRequest
Check if user has active request this fortnight.- Parameters:
product- product type.userId- user identifier.- Returns:
- flag if user has active request this fortnight.
-
validActiveRequest
Check if user has active request.- Parameters:
product- product type.userId- user identifier.advanceCount- company advance request count.- Returns:
- flag if user has active request.
-
validNewContract
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Boolean>> validNewContract(String userId, String type) Validation if user can create Contract.- Parameters:
userId- user identifier.type- contract type.- Returns:
- the contract validation.
-
saveContract
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> saveContract(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.NewApplicationRequestDto requestDto, String userIp, String userAgent) Create new application from Client/Sponsor.- Parameters:
requestDto- new application data.userIp- user real ipuserAgent- user-agent header- Returns:
- Contract created.
-
generateInvoiceFile
Create Invoice document with API.- Parameters:
application- application information.company- user company.
-
generateAddiFile
Create Direct Discount Authorization file.- Parameters:
contract- application information.
-
getContractDocument
private ContractDocument getContractDocument(Contract application, ContractDocument contractDocument, String contractDocumentId, DocumentState documentState, String savedFileName, String savedFilePath, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.requestedfiles.DataObject contractFile) Check contract document in contract documents list. Create if not exist or update if exist.- Parameters:
application- application entity.contractDocument- contract document created.contractDocumentId- contract document identifier.documentState- contract document state.savedFileName- contract document file name.savedFilePath- contract document file path.contractFile- contract file.- Returns:
- contract document entity.
-
generalDataFromApplication
private es.kukenan.smartfi.microservice.backoffice.dtos.core.invoice.request.InvoiceGeneralData generalDataFromApplication(Contract application) Create Invoice General Data from application.- Parameters:
application- application information.- Returns:
- invoice general data object
-
generateItem
private void generateItem(Contract application, List<es.kukenan.smartfi.microservice.backoffice.dtos.core.invoice.request.InvoiceItem> invoiceItems, Company company) Create an Invoice Item and Add to inoice items list.- Parameters:
application- application information.invoiceItems- list of items.company- user company.
-
totalDataFromApplication
private es.kukenan.smartfi.microservice.backoffice.dtos.core.invoice.request.InvoiceTotalData totalDataFromApplication(Contract application) Create Invoice Total Data from application.- Parameters:
application- application information.- Returns:
- invoice total data object
-
saveGeneratedProduct
private void saveGeneratedProduct(User user, Contract application, String product, BigDecimal quota, int deadline, int deadlineUnit, LocalDate advancePaymentDay, es.kukenan.smartfi.microservice.onboarding.events.common.CompanyDto companyDto) Generate requested product.- Parameters:
user- user identificationapplication- application createdproduct- product type requestedquota- application monthly quotadeadline- application deadlinedeadlineUnit- application deadline unitadvancePaymentDay- application calculated advance payment daycompanyDto- company information
-
calculatePaymentDate
Calculate payment approximated date.- Parameters:
addValue- value to add actual date.deadlineUnit- unit to add to date.- Returns:
- calculated date.
-
createContract
Create contract for Entity and User.- Parameters:
name- contract name.entity- for contract.user- identifier.- Returns:
- Contract.
-
addBodyDataToContract
public Contract addBodyDataToContract(Contract contract, String product, Float amount, Integer deadline, Integer deadlineUnit, Integer userCode, String sponsor, Optional<AccountBank> accountBank, String initialStatus, String contractNumber) Add body data to contract.- Parameters:
contract- contract to add data.product- product type.amount- application amount.deadline- application deadline.deadlineUnit- application deadline unit.userCode- user code identifier.sponsor- sponsor user identifier.accountBank- account bank information.initialStatus- custom initial status.contractNumber- contract number.- Returns:
- updated Contract.
-
getContractStates
public List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractStateDto> getContractStates(String product) Retrieve contract states.- Parameters:
product- application product for filtering.- Returns:
- the contract states.
-
findContract
Retrieve contract entity.- Parameters:
contractId- contract identifier.userId- user id.- Returns:
- the contract entity.
-
getContractDetail
public es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract getContractDetail(String userId, String contractId, String userToken) Retrieve contract detail.- Parameters:
userId- user id.contractId- contract identifier.userToken- user token.- Returns:
- the contract detail.
-
uploadFile
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> uploadFile(String contractId, String userId, List<org.springframework.web.multipart.MultipartFile> files, Integer companyId) Save files to application.- Parameters:
contractId- application identifier.userId- user identifier.files- list of files received.companyId- company identifier.- Returns:
- Contract updated.
-
uploadSpecificFile
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> uploadSpecificFile(String contractDocumentId, String userUpdateId, org.springframework.web.multipart.MultipartFile file, String userToken) Save specific contract document file.- Parameters:
contractDocumentId- contract document id.userUpdateId- user id.file- file received.userToken- user token.- Returns:
- Contract updated.
-
uploadContractualFile
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> uploadContractualFile(String contractId, String userUpdateId, org.springframework.web.multipart.MultipartFile file, String process, String userToken) Save specific contractual document file.- Parameters:
contractId- contract id.userUpdateId- user id.file- file received.process- type of process called.userToken- user token.- Returns:
- Contract updated.
-
saveFileAndUpdateContractDocument
private void saveFileAndUpdateContractDocument(String userUpdateId, org.springframework.web.multipart.MultipartFile file, ContractDocument contractDocument, DocumentState documentState, String newContractState, Contract contract, List<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.requestedfiles.DataObject> requestedFiles, es.kukenan.smartfi.dto.BasicApiResponse result, es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract> responseDto, boolean fileNotFound, String userToken) throws IOException, ExecutionException, InterruptedException -
updateContractState
Update Contract state.- Parameters:
state- state tu updatecontract- contract to update- Returns:
- updated contract.
-
saveFile
public void saveFile(org.springframework.web.multipart.MultipartFile file, String destination, String userId, String contractId) throws IOException Save file to path.- Parameters:
file- file received.destination- file path destination.userId- user identifier.contractId- contract identifier.- Throws:
IOException- exception if destination fails.
-
checkFilePath
-
getApprovedContracts
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>> getApprovedContracts(String userId) Retrieve approved contracts.- Parameters:
userId- user id.- Returns:
- the contracts.
-
getContractsAndCompanyInfo
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.clients.dto.ContractCompanyInfoDto>> getContractsAndCompanyInfo(String userId) Retrieve approved contracts.- Parameters:
userId- user id.- Returns:
- the contracts.
-
updateContractAppointment
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> updateContractAppointment(String contractId, String userId, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.appointments.AppointmentDto appointmentDto) Update contract with appointment.- Parameters:
contractId- contract id.userId- user id.appointmentDto- appointment information.- Returns:
- ok.
-
updateContractStatus
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> updateContractStatus(String contractId, String userId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractStatusRequestDto contractStatusRequestDto, String userToken) Change application status.- Parameters:
contractId- contract id.userId- user id.contractStatusRequestDto- list of files received.userToken- user token.- Returns:
- ok.
-
updateContractDocumentStatus
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> updateContractDocumentStatus(String contractDocumentId, String userId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateContractDocumentRequestDto requestDto, String userToken) Update contract document status.- Parameters:
contractDocumentId- contract document id.userId- user id.requestDto- Update contract document information.userToken- user token.- Returns:
- ok.
-
getContractDocumentFile
public void getContractDocumentFile(String contractDocumentId, String userId, javax.servlet.http.HttpServletResponse response) throws IOException Get contract document file.- Parameters:
contractDocumentId- contract document id.userId- user id.response- response.- Throws:
IOException- file to write response.
-
generateContractFile
public void generateContractFile(Contract contract, String backofficeUserId, javax.servlet.http.HttpServletResponse response) Generate pdf contract document file.- Parameters:
contract- contract entity.backofficeUserId- backoffice user id.response- response.
-
calculateCostoOperativo
public Float calculateCostoOperativo(Contract contract, Company company) throws ExecutionException, InterruptedException Calculate advance contract operative cost.- Parameters:
contract- Contract information.company- user company.- Returns:
- Operative cost value.
- Throws:
ExecutionException- Exception if config values endpoint fails.InterruptedException- Exception if config values endpoint fails.
-
calculateComission
Calculate advance contract comission.- Parameters:
contract- Contract information.company- user company.- Returns:
- Comission value.
-
translateDocumentType
Transform document type name on DB to spanish.- Parameters:
document- document name on DB.- Returns:
- Document name translated.
-
createContractDocument
private ContractDocument createContractDocument(String contractDocumentId, Contract contract, DocumentState documentState, String savedFileName, String savedFilePath, Long documentId, int contractDocumentType) -
changeApplicationsToPayed
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>> changeApplicationsToPayed(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateListOfContractsRequestDto updateListOfContractsRequestDto, String userId, String product) Change a list of application identifier from PAYMENT_PENDING (credit) or APPROVED_PAYMENT_PENDING_NAME (advance) to PAYED (advance) or ACTIVE (credit).- Parameters:
updateListOfContractsRequestDto- contract id list.userId- user id.product- application type.- Returns:
- ok.
-