Skip to content

Commit

Permalink
Merge branch 'master' into INT-114
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Gorodishenin authored Feb 21, 2020
2 parents ed60097 + a021889 commit 78a722b
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 204 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ v1.5 [unreleased]
### Breaking changes
- [#11](https://github.com/latera/camunda-ext/pull/11) Rename Invoice to Charge log
- [#13](https://github.com/latera/camunda-ext/pull/13) Fix id and non-id fields in helpers.hydra.Individual trait methods
- [#35](https://github.com/latera/camunda-ext/pull/35) Set private modifier for hid.hydra.Account#put* methods

v1.4.2 [unreleased]
-------------------
### Features
- [#25](https://github.com/latera/camunda-ext/pull/25) Add Planado APIv2 connector
- [#38](https://github.com/latera/camunda-ext/pull/38) Add method for job updating into PlanadoV2 class
- [#33](https://github.com/latera/camunda-ext/pull/33) Allow to pass goodValueId into hid.Hydra#getGoodAddParamsBy
- [#24](https://github.com/latera/camunda-ext/pull/24) Add methods for files to document attaching

### Bugfixes
- [#27](https://github.com/latera/camunda-ext/pull/27) Remove redundant get methods from hid.Hydra class
- [#28](https://github.com/latera/camunda-ext/pull/28) Fix return types of HID class methods
- [#30](https://github.com/latera/camunda-ext/pull/30) Fix wrong Self-Care app id passing into method calls
- [#26](https://github.com/latera/camunda-ext/pull/26) Fix passing appCode into hid.Hydra#mainInit method
- [#34](https://github.com/latera/camunda-ext/pull/34) Search settlement accounts for base subjects, not personal ones

v1.4.1 [2020-02-14]
-------------------
Expand All @@ -19,7 +30,6 @@ v1.4.1 [2020-02-14]
- [#3](https://github.com/latera/camunda-ext/pull/3) Add methods to tag entities into hid.Hydra class
- [#20](https://github.com/latera/camunda-ext/pull/20) Add newMessage method to MailSender class
- [#3200317](https://github.com/latera/camunda-ext/commit/3200317) Allow to pass constant id with non-Integer type into getConstantCode method
- [#24](https://github.com/latera/camunda-ext/pull/24) Add methods for files to document attaching

### Refactoring
- [#8](https://github.com/latera/camunda-ext/pull/8) Prettify runCommand, Add constants, use constants instead of magic numbers in logger, Update docs
Expand Down
10 changes: 5 additions & 5 deletions src/org/camunda/latera/bss/connectors/HID.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ WHERE ROWNUM <= ${limit}"""
}
}

List queryDatabaseList(CharSequence query, Integer limit = 0, Integer page = 1) {
List<List> queryDatabaseList(CharSequence query, Integer limit = 0, Integer page = 1) {
return queryDatabase(query, false, limit, page)
}

List queryDatabaseMap(CharSequence query, Integer limit = 0, Integer page = 1) {
List<Map> queryDatabaseMap(CharSequence query, Integer limit = 0, Integer page = 1) {
return queryDatabase(query, true, limit, page)
}

def queryFirst(CharSequence query, Boolean asMap = false) {
List result = this.queryDatabase(query, asMap, 1)
List result = queryDatabase(query, asMap, 1)

if (result) {
return result.getAt(0)
Expand All @@ -107,7 +107,7 @@ WHERE ROWNUM <= ${limit}"""
return queryFirst(query, true)
}

def execute(CharSequence execName, Map params) {
Map execute(CharSequence execName, Map params) {
LinkedHashMap encodedParams = [:]
params.each{ CharSequence key, def value ->
if (isDate(value)) {
Expand All @@ -128,7 +128,7 @@ WHERE ROWNUM <= ${limit}"""
return this.proxy.invokeMethod(execName, [encodedParams])
}

def execute(Map params = [:], CharSequence execName) {
Map execute(Map params = [:], CharSequence execName) {
return execute(execName, params)
}
}
18 changes: 18 additions & 0 deletions src/org/camunda/latera/bss/connectors/PlanadoV2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ class PlanadoV2 {
sendRequest('post', 'jobs', body: payload).getOrNull()
}

Map updateJob(Map data, def jobId) {
logger.info("Updating job ${jobId}")

LinkedHashMap payload = [:].with {
if (data.containsKey('description')) {
description = data.description
}

it
}

if (payload.size() == 0) {
throw new Exception("No params for update")
}

sendRequest('patch', "jobs/${jobId}", body: payload).getOrNull()
}

Map getJob(def jobId) {
sendRequest('get', "jobs/${jobId}").getOrNull()
}
Expand Down
31 changes: 8 additions & 23 deletions src/org/camunda/latera/bss/connectors/hid/Hydra.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ import org.camunda.latera.bss.connectors.hid.hydra.Search
import org.camunda.latera.bss.connectors.hid.hydra.Tag

class Hydra implements Ref, Message, DataType, AddParam, Good, Document, Contract, PriceOrder, ChargeLog, Invoice, Subject, Company, Person, Reseller, Group, Customer, Account, Subscription, Equipment, Region, Address, Param, Search, Tag {
private static String DEFAULT_USER = 'hydra'
private static String DEFAULT_LOCALE = 'ru'
HID hid
String user
private String password
def firmId
def resellerId
Number firmId
Number resellerId
SimpleLogger logger
String locale
Map regionHierarchyOverride
Expand All @@ -49,10 +51,10 @@ class Hydra implements Ref, Message, DataType, AddParam, Good, Document, Contrac
this.hid = new HID(execution)
def ENV = System.getenv()

this.locale = execution.getVariable('locale')
this.user = ENV['HYDRA_USER'] ?: execution.getVariable('hydraUser') ?: 'hydra'
this.locale = execution.getVariable('locale') ?: DEFAULT_LOCALE
this.user = ENV['HYDRA_USER'] ?: execution.getVariable('hydraUser') ?: DEFAULT_USER
this.password = ENV['HYDRA_PASSWORD'] ?: execution.getVariable('hydraPassword')
this.firmId = toIntSafe(execution.getVariable('hydraFirmId') ?: (execution.getVariable('homsOrderDataFirmId') ?: getDefaultFirmId()))
this.firmId = toIntSafe(execution.getVariable('hydraFirmId') ?: (execution.getVariable('homsOrderDataFirmId') ?: DEFAULT_FIRM))
this.resellerId = toIntSafe(execution.getVariable('hydraResellerId') ?: execution.getVariable('homsOrderDataResellerId'))
this.regionHierarchyOverride = execution.getVariable('regionHierarchy')

Expand Down Expand Up @@ -104,24 +106,7 @@ class Hydra implements Ref, Message, DataType, AddParam, Good, Document, Contrac
return result
}

Number getDefaultFirmId() {
return DEFAULT_FIRM
}

Number getFirmId() {
return firmId
}

Number getResellerId() {
return resellerId
}

String getLocale() {
return locale ?: 'ru'
}

Number getLangId() {
String locale = getLocale()
return getRefIdByCode("LANG_${capitalize(locale)}")
}

Expand All @@ -138,7 +123,7 @@ class Hydra implements Ref, Message, DataType, AddParam, Good, Document, Contrac
vch_VC_IP : params.ip,
vch_VC_USER : params.user,
vch_VC_PASS : params.password,
vch_VC_APP_CODE : params.app ?: params.appCode,
vch_VC_APP_CODE : params.appCode ?: params.app,
vch_VC_CLN_APPID : params.appId
])
}
Expand Down
69 changes: 46 additions & 23 deletions src/org/camunda/latera/bss/connectors/hid/hydra/Account.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import static org.camunda.latera.bss.utils.DateTimeUtil.local
import static org.camunda.latera.bss.utils.DateTimeUtil.dayEnd
import static org.camunda.latera.bss.utils.Oracle.encodeDateStr
import static org.camunda.latera.bss.utils.Constants.ACC_TYPE_Personal
import static org.camunda.latera.bss.utils.Constants.ACC_TYPE_Settlement
import static org.camunda.latera.bss.utils.Constants.OVERDRAFT_Manual
import java.time.temporal.Temporal

Expand All @@ -20,14 +21,22 @@ trait Account {
return ACCOUNTS_MV
}

String getDefaultAccountType() {
return getRefCode(getDefaultAccountTypeId())
String getCustomerAccountType() {
return getRefCode(getCustomerAccountTypeId())
}

Number getDefaultAccountTypeId() {
Number getCustomerAccountTypeId() {
return ACC_TYPE_Personal
}

String getBaseSubjectAccountType() {
return getRefCode(getBaseSubjectAccountTypeId())
}

Number getBaseSubjectAccountTypeId() {
return ACC_TYPE_Settlement
}

String getDefaultOverdraftReason() {
return getRefCode(getDefaultOverdraftReasonId())
}
Expand All @@ -40,7 +49,7 @@ trait Account {
LinkedHashMap params = mergeParams([
accountId : null,
subjectId : null,
accountTypeId : getDefaultAccountTypeId(),
accountTypeId : null,
bankId : null,
currencyId : null,
code : null,
Expand Down Expand Up @@ -102,56 +111,56 @@ trait Account {

List getSubjectAccounts(
def subjectId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = null
) {
return getAccountsBy(subjectId: subjectId, accountTypeId: accountTypeId)
}

List getCompanyAccounts(
def companyId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = getBaseSubjectAccountTypeId()
) {
return getSubjectAccounts(companyId, accountTypeId)
}

List getPersonAccounts(
def personId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = getBaseSubjectAccountTypeId()
) {
return getSubjectAccounts(personId, accountTypeId)
}

List getCustomerAccounts(
def customerId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = getCustomerAccountTypeId()
) {
return getSubjectAccounts(customerId, accountTypeId)
}

Map getSubjectAccount(
def subjectId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = null
) {
return getAccountBy(subjectId: subjectId, accountTypeId: accountTypeId)
}

Map getCompanyAccount(
def companyId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = getBaseSubjectAccountTypeId()
) {
return getSubjectAccount(companyId, accountTypeId)
}

Map getPersonAccount(
def personId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = getBaseSubjectAccountTypeId()
) {
return getSubjectAccount(personId, accountTypeId)
}

Map getCustomerAccount(
def customerId,
def accountTypeId = getDefaultAccountTypeId()
def accountTypeId = getCustomerAccountTypeId()
) {
return getSubjectAccount(customerId, accountTypeId)
}
Expand Down Expand Up @@ -279,7 +288,7 @@ trait Account {
return putCustomerAccount(input + [accountId: accountId])
}

Boolean putAdjustment(Map input) {
private Boolean putAdjustment(Map input) {
LinkedHashMap params = mergeParams([
accountId : null,
docId : null,
Expand Down Expand Up @@ -317,7 +326,7 @@ trait Account {
return putAdjustment(input + [accountId: accountId])
}

Boolean putPermanentOverdraft(Map input) {
private Boolean putPermanentOverdraft(Map input) {
LinkedHashMap params = mergeParams([
accountId : null,
reasonId : getDefaultOverdraftReasonId(),
Expand All @@ -344,20 +353,20 @@ trait Account {
return putPermanentOverdraft(params.accountId, params.sum, params.reasonId)
}

Boolean putPermanentOverdraft(
Boolean addPermanentOverdraft(Map input, def accountId) {
return putPermanentOverdraft(input + [accountId: accountId])
}

Boolean addPermanentOverdraft(
def accountId,
Double sum = 0,
def reasonId = getDefaultOverdraftReasonId()
) {
return putPermanentOverdraft(
return putPermanentOverdraft([
accountId : accountId,
sum : sum,
reasonId : reasonId
)
}

Boolean addPermanentOverdraft(Map input = [:], def accountId) {
return putPermanentOverdraft(input + [accountId: accountId])
])
}

Boolean deletePermanentOverdraft(def accountId) {
Expand All @@ -375,7 +384,7 @@ trait Account {
}
}

Boolean putTemporalOverdraft(Map input) {
private Boolean putTemporalOverdraft(Map input) {
LinkedHashMap params = mergeParams([
accountId : null,
sum : 0,
Expand Down Expand Up @@ -403,10 +412,24 @@ trait Account {
}
}

Boolean addTemporalOverdraft(Map input = [:], def accountId) {
Boolean addTemporalOverdraft(Map input, def accountId) {
return putTemporalOverdraft(input + [accountId: accountId])
}

Boolean addTemporalOverdraft(
def accountId,
Double sum = 0,
Temporal endDate = dayEnd(),
def reasonId = getDefaultOverdraftReasonId()
) {
return putTemporalOverdraft([
accountId : accountId,
sum : sum,
endDate : endDate,
reasonId : reasonId
])
}

Boolean deleteTemporalOverdraft(def accountId) {
try {
logger.info("Deleting temporal overdraft with params ${params}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ trait Address {
entrance : null,
providerId : getFirmId(),
rem : null,
limit : 0,
order : [n_address_id: 'desc']
], input)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ trait Customer {
return getSubjectGroups(customerId)
}

List getCustomerGroup(def customerId) {
Map getCustomerGroup(def customerId) {
return getSubjectGroup(customerId)
}

Expand Down Expand Up @@ -590,7 +590,7 @@ trait Customer {
}

Map getCustomerSelfCareAccessBy(Map input) {
input.appId = getSelfCareAppId()
input.applicationId = getSelfCareAppId()
return getCustomerAppAccessBy(input)
}

Expand Down Expand Up @@ -625,15 +625,15 @@ trait Customer {
}

Boolean changeSelfCarePassword(Map input) {
return changeAppPassword(input + [appId: getSelfCareApplicationId()])
return changeAppPassword(input + [applicationId: getSelfCareApplicationId()])
}

Boolean changeSelfCarePassword(Map input = [:], def customerId) {
return changeSelfCarePassword(input + [customerId: customerId])
}

Boolean deleteCustomerSelfCareAccess(def customerId) {
def subjServId = getCustomerAppAccessBy(customerId: customerId, appId: getSelfCareApplicationId())?.n_subj_serv_id
def subjServId = getCustomerAppAccessBy(customerId: customerId, applicationId: getSelfCareApplicationId())?.n_subj_serv_id
return deleteCustomerAppAccess(subjServId)
}

Expand Down
Loading

0 comments on commit 78a722b

Please sign in to comment.