account-service http://jira.mfd.msk:8088/browse/CLS-361 проставление в ТКР code
This commit is contained in:
parent
b59cd10acc
commit
33c9fd87e0
2 changed files with 39 additions and 5 deletions
|
|
@ -16,7 +16,6 @@ import ru.clearing.classes.statics.data.company.relation.Relation;
|
|||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest;
|
||||
|
|
@ -324,10 +323,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
tradingClearingRegistry.setTradingClearingRegistryPurpose(registryPurpose.getKey());
|
||||
|
||||
Company company = companyImdg.getSingleObjectByID(req.getCompanyId());
|
||||
String code = "%4s".formatted(company.getClearingCode()).replace(' ', '0');
|
||||
code += registryPurpose.getKey();
|
||||
if (registryPurpose == TradingClearingRegistryPurpose.C) code += tradingRegistryType + id;
|
||||
else code += "AT" + id;
|
||||
String code = makeCode(company.getClearingCode(), registryPurpose, tradingRegistryType, id);
|
||||
tradingClearingRegistry.setCode(code);
|
||||
|
||||
Instant now = Instant.now();
|
||||
|
|
@ -345,6 +341,26 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
return null;
|
||||
}
|
||||
|
||||
protected String makeCode(String companyClearingCode, TradingClearingRegistryPurpose registryPurpose, String tradingRegistryType, Long id) {
|
||||
String code;
|
||||
code = companyClearingCode;
|
||||
if (code.length() > 4)
|
||||
code = code.substring(code.length() - 4);
|
||||
code = "%4s".formatted(code).replace(' ', '0');
|
||||
code += registryPurpose.getKey(); // C / M / ...
|
||||
if (registryPurpose == TradingClearingRegistryPurpose.M) {
|
||||
code += "AT" + id;
|
||||
} else { // C, etc
|
||||
String trType = tradingRegistryType + "T"; // 2 символа
|
||||
code += trType;
|
||||
String sId = "%5s".formatted(id).replace(' ', '0');
|
||||
if (sId.length() > 5)
|
||||
sId = sId.substring(sId.length() - 5);
|
||||
code += sId;
|
||||
}
|
||||
return code; // 12 имволов
|
||||
}
|
||||
|
||||
public RequestInfoUpdate tradingClearingRegistryUpdate(BaseRequest<TradingClearingRegistryUpdateRequest> userRequest) {
|
||||
log.debug("TradingClearingRegistryUpdateRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.apache.kafka.clients.consumer.MockConsumer;
|
|||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
|
@ -319,4 +320,21 @@ class TradingClearingRegistryServiceTest {
|
|||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultUpdating, existTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultUpdating);
|
||||
}
|
||||
|
||||
@Test
|
||||
void makeCode() {
|
||||
Assertions.assertEquals("0005CAT00001", tradingClearingRegistryService.makeCode(
|
||||
"5", TradingClearingRegistryPurpose.C, TradingClearingRegistryType.Owner_A.getKey(), 1L
|
||||
));
|
||||
Assertions.assertEquals("0005CET00012", tradingClearingRegistryService.makeCode(
|
||||
"005", TradingClearingRegistryPurpose.C, "E", 12L
|
||||
));
|
||||
Assertions.assertEquals("0105CERT00012", tradingClearingRegistryService.makeCode(
|
||||
"000000105", TradingClearingRegistryPurpose.C, "ER", 100012L
|
||||
));
|
||||
|
||||
Assertions.assertEquals("0105MAT100012", tradingClearingRegistryService.makeCode(
|
||||
"000000105", TradingClearingRegistryPurpose.M, "ER", 100012L
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue