Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init #4941

Merged
merged 30 commits into from
Feb 7, 2024
Merged

init #4941

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
538941e
init
hitchikermn Feb 1, 2024
71d168e
zasvar
hitchikermn Feb 1, 2024
84d46f9
update
hitchikermn Feb 1, 2024
7ddf4a8
fix all ui
Mygmarsuren Feb 5, 2024
cac2097
fix
hitchikermn Feb 5, 2024
75f0d6f
Merge branch 'syncpolaris' of https://github.com/erxes/erxes into syn…
hitchikermn Feb 5, 2024
10fc7d9
Merge branch 'dev' of https://github.com/erxes/erxes into syncpolaris
hitchikermn Feb 5, 2024
4674c6f
fix ui 02/05
Mygmarsuren Feb 5, 2024
eaf9c45
Merge branch 'syncpolaris' of https://github.com/erxes/erxes into syn…
Mygmarsuren Feb 5, 2024
cfe94cb
fix api 02/05
Mygmarsuren Feb 5, 2024
eaae103
fix
hitchikermn Feb 5, 2024
33348a1
fix
hitchikermn Feb 5, 2024
e61881d
fix
hitchikermn Feb 5, 2024
26e8581
fix
hitchikermn Feb 5, 2024
4a9cfc0
update
hitchikermn Feb 5, 2024
54cd9df
update
hitchikermn Feb 5, 2024
21419e3
fxi
hitchikermn Feb 5, 2024
92a6683
Merge branch 'dev' of github.com:erxes/erxes into syncpolaris
munkhsaikhan Feb 6, 2024
4e56c6a
add syncpolaris on create-plugins-cis
munkhsaikhan Feb 6, 2024
c90e402
update
hitchikermn Feb 7, 2024
cf4e99e
Merge branch 'syncpolaris' of https://github.com/erxes/erxes into syn…
hitchikermn Feb 7, 2024
a0e1b06
Merge branch 'dev' of https://github.com/erxes/erxes into syncpolaris
hitchikermn Feb 7, 2024
add2fca
fix
hitchikermn Feb 7, 2024
1aa5aec
update
hitchikermn Feb 7, 2024
ea7942f
update
hitchikermn Feb 7, 2024
737b1b2
fix
hitchikermn Feb 7, 2024
82479af
update
hitchikermn Feb 7, 2024
76a738b
udpate
hitchikermn Feb 7, 2024
642cc09
update
hitchikermn Feb 7, 2024
b06b2ed
update
hitchikermn Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/plugin-syncpolaris-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Plugin syncpolaris Api CI

on:
push:
branches:
- dev
- master
- staging
- build-test
paths:
- 'packages/api-utils/**'
- 'packages/plugin-syncpolaris-api/**'
- '.github/workflows/plugin-syncpolaris-api.yaml'
pull_request:
branches:
- dev
- master
- staging
- build-test
paths:
- 'packages/api-utils/**'
- 'packages/plugin-syncpolaris-api/**'
- '.github/workflows/plugin-syncpolaris-api.yaml'

jobs:
api:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Use Node.js 18.17.x
uses: actions/setup-node@v4
with:
node-version: 18.17.x

# https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-api-plugin-syncpolaris
restore-keys: |
${{ runner.os }}-yarn-api-
${{ runner.os }}-yarn-

- name: Build
run: |
cp -r builder dist
cd dist
yarn install
yarn build plugin syncpolaris

- name: Build docker image
if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/build-test' )
run: |
cd dist/erxes
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker buildx build -t erxes/plugin-syncpolaris-api:${GITHUB_REF#refs/heads/} -f Dockerfile .
docker push erxes/plugin-syncpolaris-api:${GITHUB_REF#refs/heads/}
99 changes: 99 additions & 0 deletions .github/workflows/plugin-syncpolaris-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Plugin syncpolaris UI CI

on:
push:
branches:
- dev
- master
- staging
- build-test
paths:
- 'packages/erxes-ui/**'
- 'packages/ui-plugin-template/**'
- 'packages/ui-cards/**'
- 'packages/ui-forms/**'
- 'packages/ui-inbox/**'
- 'packages/ui-knowledgebase/**'
- 'packages/ui-leads/**'
- 'packages/ui-log/**'
- 'packages/ui-notifications/**'
- 'packages/ui-products/**'
- 'packages/ui-segments/**'
- 'packages/ui-settings/**'
- 'packages/ui-team/**'
- 'packages/ui-tags/**'
- 'packages/ui-syncpolaris/**'
- 'packages/plugin-syncpolaris-ui/**'
- '.github/workflows/plugin-syncpolaris-ui.yaml'
pull_request:
branches:
- dev
- master
- staging
- build-test
paths:
- 'packages/erxes-ui/**'
- 'packages/ui-plugin-template/**'
- 'packages/ui-cards/**'
- 'packages/ui-forms/**'
- 'packages/ui-inbox/**'
- 'packages/ui-knowledgebase/**'
- 'packages/ui-leads/**'
- 'packages/ui-log/**'
- 'packages/ui-notifications/**'
- 'packages/ui-products/**'
- 'packages/ui-segments/**'
- 'packages/ui-settings/**'
- 'packages/ui-team/**'
- 'packages/ui-tags/**'
- 'packages/ui-syncpolaris/**'
- 'packages/plugin-syncpolaris-ui/**'
- '.github/workflows/plugin-syncpolaris-ui.yaml'

jobs:
ui:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Use Node.js 18.17.x
uses: actions/setup-node@v4
with:
node-version: 18.17.x

# https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn # since the yarn install runs at workspace level
restore-keys: |
${{ runner.os }}-yarn

- name: Build
run: |
yarn install --frozen-lockfile
cd packages/plugin-syncpolaris-ui
yarn build
cp -r ./src/locales/ ./dist/locales 2>/dev/null || true

- name: Configure AWS credentials
if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/build-test')
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Deploy
if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/build-test')
run: |
tar -cf build.tar --directory=packages/plugin-syncpolaris-ui/dist .
cp build.tar packages/plugin-syncpolaris-ui/dist
rm -rf packages/plugin-syncpolaris-ui/dist/*.js
aws s3 sync packages/plugin-syncpolaris-ui/dist s3://erxes-${GITHUB_REF#refs/heads/}-plugins/uis/plugin-syncpolaris-ui --delete
8 changes: 5 additions & 3 deletions packages/plugin-loans-api/src/cronjobs/contractCronJobs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IModels, generateModels } from '../connectionResolver';
import {
CONTRACT_STATUS,
SCHEDULE_STATUS
SCHEDULE_STATUS,
} from '../models/definitions/constants';
import { IContractDocument } from '../models/definitions/contracts';
import { getFullDate } from '../models/utils/utils';
Expand All @@ -20,12 +20,14 @@ export async function checkContractScheduleAnd(subdomain: string) {

if (exactTime === '00:00:00') {
const loanContracts: IContractDocument[] = await models.Contracts.find({
status: CONTRACT_STATUS.NORMAL
status: CONTRACT_STATUS.NORMAL,
}).lean();

if (!loanContracts.length) return;
now.setDate(now.getDate() - 1);
const periodDate = getFullDate(now);

const periodLock = await createPeriodLock(today, [], models);
const periodLock = await createPeriodLock(periodDate, [], models);

for await (let contract of loanContracts) {
await storeInterestContract(contract, today, models, periodLock._id);
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-loans-api/src/graphql/schema/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const types = () => `
leaseType: String
commitmentInterest:Float
endDate:Date
customFieldsData: JSON
}


Expand Down Expand Up @@ -237,6 +238,7 @@ const commonFields = `
commitmentInterest: Float
endDate: Date
savingContractId: String
customFieldsData: JSON
`;

const interestCorrectionFields = `
Expand Down
29 changes: 29 additions & 0 deletions packages/plugin-loans-api/src/logUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,35 @@ export async function createLog(subdomain, user, logData) {
);
}

export const prepareCocLogData = (coc) => {
// condition logic was in ActivityLogs model before
let action = 'create';
let content: string[] = [];

if (coc.mergedIds && coc.mergedIds.length > 0) {
action = 'merge';
content = coc.mergedIds;
}

return {
createdBy: coc.ownerId || coc.integrationId,
action,
content,
contentId: coc._id,
};
};

export async function activityLog(subdomain, logData) {
const { data } = logData;

const updatedParams = {
...logData,
subdomain,
data: { ...data, contentType: `contacts:${data.contentType}` },
};
await putActivityLog(subdomain, updatedParams);
}

export async function updateLog(subdomain, user, logData) {
const descriptions = gatherDescriptions(logData);

Expand Down
45 changes: 45 additions & 0 deletions packages/plugin-loans-api/src/messageBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MessageArgs, MessageArgsOmitService } from '@erxes/api-utils/src/core';
import { generateModels } from './connectionResolver';
import fetch from 'node-fetch';
import { consumeRPCQueue } from '@erxes/api-utils/src/messageBroker';
import { getCloseInfo } from './models/utils/closeUtils';

export const initBroker = async () => {
consumeRPCQueue('loans:contracts.find', async ({ subdomain, data }) => {
Expand All @@ -14,6 +15,50 @@ export const initBroker = async () => {
};
});

consumeRPCQueue(
'loans:contracts.updateContractNumber',
async ({ subdomain, data }) => {
const models = await generateModels(subdomain);

return {
status: 'success',
data: await models.Contracts.updateOne(
{ _id: data._id },
{ number: data.number },
),
};
},
);

consumeRPCQueue(
'loans:contracts.getCloseInfo',
async ({ subdomain, data }) => {
const models = await generateModels(subdomain);
const contract = await models.Contracts.getContract({
_id: data.contractId,
});
const closeInfo = await getCloseInfo(
models,
subdomain,
contract,
data.closeDate,
);
return {
status: 'success',
data: closeInfo,
};
},
);

consumeRPCQueue('loans:contractType.findOne', async ({ subdomain, data }) => {
const models = await generateModels(subdomain);

return {
status: 'success',
data: await models.ContractTypes.findOne(data).lean(),
};
});

consumeRPCQueue('loans:transactions.find', async ({ subdomain, data }) => {
const models = await generateModels(subdomain);

Expand Down
Loading
Loading