mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
Compare commits
16 Commits
v0.16.4
...
backup-scr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
341bcbea7d | ||
|
|
b7214044bb | ||
|
|
93cb3615c3 | ||
|
|
7abfa6a162 | ||
|
|
1372a1f0a8 | ||
|
|
484024ec28 | ||
|
|
46639c7b86 | ||
|
|
d10d1654c1 | ||
|
|
2f06070ecb | ||
|
|
deefdb9bfd | ||
|
|
3cc62d80de | ||
|
|
4962c5d4d3 | ||
|
|
571a332658 | ||
|
|
b44c318a5d | ||
|
|
bd9717f4dc | ||
|
|
f48aea8e5a |
@@ -105,6 +105,24 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"bug"
|
"bug"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "benpsnyder",
|
||||||
|
"name": "Ben Snyder",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/707567?v=4",
|
||||||
|
"profile": "https://snyder.tech",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "cloudsbird",
|
||||||
|
"name": "Vederis Leunardus",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/13505006?v=4",
|
||||||
|
"profile": "http://vederis.id",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
|||||||
89
.github/workflows/build-deploy-container.yml
vendored
89
.github/workflows/build-deploy-container.yml
vendored
@@ -12,20 +12,37 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-publish-webapp:
|
build-publish-webapp:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
name: Build and deploy webapp container
|
name: Build and deploy webapp container
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: production
|
environment: production
|
||||||
steps:
|
steps:
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# Login to Container registry.
|
# Login to Container registry.
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GH_TOKEN }}
|
password: ${{ secrets.GH_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
@@ -35,14 +52,29 @@ jobs:
|
|||||||
|
|
||||||
# Builds and push the Docker image.
|
# Builds and push the Docker image.
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v5
|
||||||
|
id: build
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./packages/webapp/Dockerfile
|
file: ./packages/webapp/Dockerfile
|
||||||
push: true
|
platforms: ${{ matrix.platform }}
|
||||||
tags: ghcr.io/bigcapitalhq/webapp:latest
|
push: true
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
tags: ghcr.io/bigcapitalhq/webapp:latest
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-main-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
# Send notification to Slack channel.
|
# Send notification to Slack channel.
|
||||||
- name: Slack Notification built and published webapp container successfully.
|
- name: Slack Notification built and published webapp container successfully.
|
||||||
uses: rtCamp/action-slack-notify@v2
|
uses: rtCamp/action-slack-notify@v2
|
||||||
@@ -53,12 +85,23 @@ jobs:
|
|||||||
name: Build and deploy server container
|
name: Build and deploy server container
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Prepare
|
||||||
uses: actions/checkout@v2
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# Login to Container registry.
|
# Login to Container registry.
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -66,14 +109,30 @@ jobs:
|
|||||||
|
|
||||||
# Builds and push the Docker image.
|
# Builds and push the Docker image.
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v5
|
||||||
|
id: build
|
||||||
with:
|
with:
|
||||||
context: ./
|
context: ./
|
||||||
file: ./packages/server/Dockerfile
|
file: ./packages/server/Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
push: true
|
push: true
|
||||||
tags: ghcr.io/bigcapitalhq/server:latest
|
tags: ghcr.io/bigcapitalhq/server:latest
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "/tmp/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-main-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: /tmp/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
# Send notification to Slack channel.
|
# Send notification to Slack channel.
|
||||||
- name: Slack Notification built and published server container successfully.
|
- name: Slack Notification built and published server container successfully.
|
||||||
uses: rtCamp/action-slack-notify@v2
|
uses: rtCamp/action-slack-notify@v2
|
||||||
|
|||||||
4
.github/workflows/e2e.yml
vendored
4
.github/workflows/e2e.yml
vendored
@@ -8,14 +8,14 @@ on:
|
|||||||
- '**.ts'
|
- '**.ts'
|
||||||
- '**.tsx'
|
- '**.tsx'
|
||||||
- '**/tsconfig.json'
|
- '**/tsconfig.json'
|
||||||
- 'yarn.lock'
|
- 'pnpm-lock.yaml'
|
||||||
- '.github/workflows/e2e.yml'
|
- '.github/workflows/e2e.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '**.ts'
|
- '**.ts'
|
||||||
- '**.tsx'
|
- '**.tsx'
|
||||||
- '**/tsconfig.json'
|
- '**/tsconfig.json'
|
||||||
- 'yarn.lock'
|
- 'pnpm-lock.yaml'
|
||||||
- '.github/workflows/e2e.yml'
|
- '.github/workflows/e2e.yml'
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
. "$(dirname -- "$0")/_/husky.sh"
|
. "$(dirname -- "$0")/_/husky.sh"
|
||||||
|
|
||||||
yarn commitlint --edit
|
pnpx commitlint --edit
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
<img src="https://img.shields.io/twitter/follow/bigcapitalhq?style=social" alt="twitter" />
|
<img src="https://img.shields.io/twitter/follow/bigcapitalhq?style=social" alt="twitter" />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://app.bigcapital.ly">Bigcapital Cloud</a>
|
||||||
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
# What's Bigcapital?
|
# What's Bigcapital?
|
||||||
@@ -118,6 +122,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ANasouf"><img src="https://avatars.githubusercontent.com/u/19536487?v=4?s=100" width="100px;" alt="ANasouf"/><br /><sub><b>ANasouf</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=ANasouf" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ANasouf"><img src="https://avatars.githubusercontent.com/u/19536487?v=4?s=100" width="100px;" alt="ANasouf"/><br /><sub><b>ANasouf</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=ANasouf" title="Code">💻</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://ragnarlaud.dev"><img src="https://avatars.githubusercontent.com/u/3042904?v=4?s=100" width="100px;" alt="Ragnar Laud"/><br /><sub><b>Ragnar Laud</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Axprnio" title="Bug reports">🐛</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://ragnarlaud.dev"><img src="https://avatars.githubusercontent.com/u/3042904?v=4?s=100" width="100px;" alt="Ragnar Laud"/><br /><sub><b>Ragnar Laud</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Axprnio" title="Bug reports">🐛</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/asenawritescode"><img src="https://avatars.githubusercontent.com/u/67445192?v=4?s=100" width="100px;" alt="Asena"/><br /><sub><b>Asena</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Aasenawritescode" title="Bug reports">🐛</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/asenawritescode"><img src="https://avatars.githubusercontent.com/u/67445192?v=4?s=100" width="100px;" alt="Asena"/><br /><sub><b>Asena</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Aasenawritescode" title="Bug reports">🐛</a></td>
|
||||||
|
<td align="center" valign="top" width="14.28%"><a href="https://snyder.tech"><img src="https://avatars.githubusercontent.com/u/707567?v=4?s=100" width="100px;" alt="Ben Snyder"/><br /><sub><b>Ben Snyder</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=benpsnyder" title="Code">💻</a></td>
|
||||||
|
<td align="center" valign="top" width="14.28%"><a href="http://vederis.id"><img src="https://avatars.githubusercontent.com/u/13505006?v=4?s=100" width="100px;" alt="Vederis Leunardus"/><br /><sub><b>Vederis Leunardus</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=cloudsbird" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -21,16 +21,12 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- server
|
- server
|
||||||
- webapp
|
- webapp
|
||||||
deploy:
|
restart: on-failure
|
||||||
restart_policy:
|
|
||||||
condition: unless-stopped
|
|
||||||
|
|
||||||
webapp:
|
webapp:
|
||||||
container_name: bigcapital-webapp
|
container_name: bigcapital-webapp
|
||||||
image: ghcr.io/bigcapitalhq/webapp:latest
|
image: ghcr.io/bigcapitalhq/webapp:latest
|
||||||
deploy:
|
restart: on-failure
|
||||||
restart_policy:
|
|
||||||
condition: unless-stopped
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
container_name: bigcapital-server
|
container_name: bigcapital-server
|
||||||
@@ -45,9 +41,7 @@ services:
|
|||||||
- mysql
|
- mysql
|
||||||
- mongo
|
- mongo
|
||||||
- redis
|
- redis
|
||||||
deploy:
|
restart: on-failure
|
||||||
restart_policy:
|
|
||||||
condition: unless-stopped
|
|
||||||
environment:
|
environment:
|
||||||
# Mail
|
# Mail
|
||||||
- MAIL_HOST=${MAIL_HOST}
|
- MAIL_HOST=${MAIL_HOST}
|
||||||
@@ -92,6 +86,22 @@ services:
|
|||||||
- GOTENBERG_URL=${GOTENBERG_URL}
|
- GOTENBERG_URL=${GOTENBERG_URL}
|
||||||
- GOTENBERG_DOCS_URL=${GOTENBERG_DOCS_URL}
|
- GOTENBERG_DOCS_URL=${GOTENBERG_DOCS_URL}
|
||||||
|
|
||||||
|
# Bank Sync
|
||||||
|
- BANKING_CONNECT=${BANKING_CONNECT}
|
||||||
|
|
||||||
|
# Plaid
|
||||||
|
- PLAID_ENV=${PLAID_ENV}
|
||||||
|
- PLAID_CLIENT_ID=${PLAID_CLIENT_ID}
|
||||||
|
- PLAID_SECRET_DEVELOPMENT=${PLAID_SECRET_DEVELOPMENT}
|
||||||
|
- PLAID_SECRET_SANDBOX=${b8cf42b441e110451e2f69ad7e1e9f}
|
||||||
|
- PLAID_LINK_WEBHOOK=${PLAID_LINK_WEBHOOK}
|
||||||
|
|
||||||
|
# Lemon Squeez
|
||||||
|
- LEMONSQUEEZY_API_KEY=${LEMONSQUEEZY_API_KEY}
|
||||||
|
- LEMONSQUEEZY_STORE_ID=${LEMONSQUEEZY_STORE_ID}
|
||||||
|
- LEMONSQUEEZY_WEBHOOK_SECRET=${LEMONSQUEEZY_WEBHOOK_SECRET}
|
||||||
|
- HOSTED_ON_BIGCAPITAL_CLOUD=${HOSTED_ON_BIGCAPITAL_CLOUD}
|
||||||
|
|
||||||
database_migration:
|
database_migration:
|
||||||
container_name: bigcapital-database-migration
|
container_name: bigcapital-database-migration
|
||||||
build:
|
build:
|
||||||
@@ -111,9 +121,7 @@ services:
|
|||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
container_name: bigcapital-mysql
|
container_name: bigcapital-mysql
|
||||||
deploy:
|
restart: on-failure
|
||||||
restart_policy:
|
|
||||||
condition: unless-stopped
|
|
||||||
build:
|
build:
|
||||||
context: ./docker/mariadb
|
context: ./docker/mariadb
|
||||||
environment:
|
environment:
|
||||||
@@ -128,9 +136,7 @@ services:
|
|||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
container_name: bigcapital-mongo
|
container_name: bigcapital-mongo
|
||||||
deploy:
|
restart: on-failure
|
||||||
restart_policy:
|
|
||||||
condition: unless-stopped
|
|
||||||
build: ./docker/mongo
|
build: ./docker/mongo
|
||||||
expose:
|
expose:
|
||||||
- '27017'
|
- '27017'
|
||||||
@@ -139,9 +145,7 @@ services:
|
|||||||
|
|
||||||
redis:
|
redis:
|
||||||
container_name: bigcapital-redis
|
container_name: bigcapital-redis
|
||||||
deploy:
|
restart: on-failure
|
||||||
restart_policy:
|
|
||||||
condition: unless-stopped
|
|
||||||
build:
|
build:
|
||||||
context: ./docker/redis
|
context: ./docker/redis
|
||||||
expose:
|
expose:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||||
"version": "independent",
|
"version": "independent",
|
||||||
"npmClient": "pnpm",
|
"npmClient": "pnpm",
|
||||||
"useWorkspaces": true,
|
"packages": [
|
||||||
"packages": ["packages/*"]
|
"packages/*"
|
||||||
}
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
"@faker-js/faker": "^8.0.2",
|
"@faker-js/faker": "^8.0.2",
|
||||||
"@playwright/test": "^1.32.3",
|
"@playwright/test": "^1.32.3",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lerna": "^6.4.1"
|
"lerna": "^8.1.2",
|
||||||
|
"pnpm": "^9.0.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "16.x || 17.x || 18.x"
|
"node": "16.x || 17.x || 18.x"
|
||||||
|
|||||||
4
packages/server/.gitignore
vendored
4
packages/server/.gitignore
vendored
@@ -3,4 +3,6 @@
|
|||||||
stdout.log
|
stdout.log
|
||||||
/dist
|
/dist
|
||||||
/build
|
/build
|
||||||
/public/imports
|
/public/imports
|
||||||
|
|
||||||
|
dist
|
||||||
17747
packages/server/package-lock.json
generated
17747
packages/server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,10 +8,10 @@ export default class DashboardMetaController {
|
|||||||
dashboardService: DashboardService;
|
dashboardService: DashboardService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Constructor router.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
router() {
|
public router() {
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get('/boot', this.getDashboardBoot);
|
router.get('/boot', this.getDashboardBoot);
|
||||||
@@ -25,7 +25,7 @@ export default class DashboardMetaController {
|
|||||||
* @param {Response} res -
|
* @param {Response} res -
|
||||||
* @param {NextFunction} next -
|
* @param {NextFunction} next -
|
||||||
*/
|
*/
|
||||||
getDashboardBoot = async (
|
private getDashboardBoot = async (
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
next: NextFunction
|
next: NextFunction
|
||||||
|
|||||||
@@ -180,6 +180,14 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bank Synchronization.
|
||||||
|
*/
|
||||||
|
bankSync: {
|
||||||
|
enabled: parseBoolean(defaultTo(process.env.BANKING_CONNECT, false), false),
|
||||||
|
provider: 'plaid',
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plaid.
|
* Plaid.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export enum Features {
|
export enum Features {
|
||||||
WAREHOUSES = 'warehouses',
|
WAREHOUSES = 'warehouses',
|
||||||
BRANCHES = 'branches',
|
BRANCHES = 'branches',
|
||||||
|
BankSyncing = 'BankSyncing'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFeatureAllItem {
|
export interface IFeatureAllItem {
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ export default class MetableStore implements IMetableStore {
|
|||||||
* @param {String} key -
|
* @param {String} key -
|
||||||
* @param {Mixied} defaultValue -
|
* @param {Mixied} defaultValue -
|
||||||
*/
|
*/
|
||||||
get(query: string | IMetaQuery, defaultValue: any): any | false {
|
get(query: string | IMetaQuery, defaultValue: any): any | null {
|
||||||
const metadata = this.find(query);
|
const metadata = this.find(query);
|
||||||
return metadata
|
return metadata
|
||||||
? metadata.value
|
? metadata.value
|
||||||
: typeof defaultValue !== 'undefined'
|
: typeof defaultValue !== 'undefined'
|
||||||
? defaultValue
|
? defaultValue
|
||||||
: false;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { defaultTo } from 'lodash';
|
|
||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import { omit } from 'lodash';
|
|
||||||
import { FeaturesSettingsDriver } from './FeaturesSettingsDriver';
|
import { FeaturesSettingsDriver } from './FeaturesSettingsDriver';
|
||||||
import { FeaturesConfigureManager } from './FeaturesConfigureManager';
|
|
||||||
import { IFeatureAllItem } from '@/interfaces';
|
import { IFeatureAllItem } from '@/interfaces';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
@@ -10,9 +7,6 @@ export class FeaturesManager {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private drive: FeaturesSettingsDriver;
|
private drive: FeaturesSettingsDriver;
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private configure: FeaturesConfigureManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns-on the given feature name.
|
* Turns-on the given feature name.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
@@ -40,35 +34,15 @@ export class FeaturesManager {
|
|||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
public async accessible(tenantId: number, feature: string) {
|
public async accessible(tenantId: number, feature: string) {
|
||||||
// Retrieves the feature default accessible value.
|
return this.drive.accessible(tenantId, feature);
|
||||||
const defaultValue = this.configure.getFeatureConfigure(
|
|
||||||
feature,
|
|
||||||
'defaultValue'
|
|
||||||
);
|
|
||||||
const isAccessible = await this.drive.accessible(tenantId, feature);
|
|
||||||
|
|
||||||
return defaultTo(isAccessible, defaultValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the all features and their accessible value and default value.
|
* Retrieves the all features and their accessible value and default value.
|
||||||
* @param {number} tenantId
|
* @param {number} tenantId
|
||||||
* @returns
|
* @returns {Promise<IFeatureAllItem[]>}
|
||||||
*/
|
*/
|
||||||
public async all(tenantId: number): Promise<IFeatureAllItem[]> {
|
public async all(tenantId: number): Promise<IFeatureAllItem[]> {
|
||||||
const all = await this.drive.all(tenantId);
|
return this.drive.all(tenantId);
|
||||||
|
|
||||||
return all.map((feature: IFeatureAllItem) => {
|
|
||||||
const defaultAccessible = this.configure.getFeatureConfigure(
|
|
||||||
feature.name,
|
|
||||||
'defaultValue'
|
|
||||||
);
|
|
||||||
const isAccessible = feature.isAccessible;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...feature,
|
|
||||||
isAccessible: defaultTo(isAccessible, defaultAccessible),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,15 @@ import { Service, Inject } from 'typedi';
|
|||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
import { FeaturesConfigure } from './constants';
|
import { FeaturesConfigure } from './constants';
|
||||||
import { IFeatureAllItem } from '@/interfaces';
|
import { IFeatureAllItem } from '@/interfaces';
|
||||||
|
import { FeaturesConfigureManager } from './FeaturesConfigureManager';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class FeaturesSettingsDriver {
|
export class FeaturesSettingsDriver {
|
||||||
@Inject()
|
@Inject()
|
||||||
tenancy: HasTenancyService;
|
private tenancy: HasTenancyService;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
private configure: FeaturesConfigureManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns-on the given feature name.
|
* Turns-on the given feature name.
|
||||||
@@ -41,7 +45,15 @@ export class FeaturesSettingsDriver {
|
|||||||
async accessible(tenantId: number, feature: string) {
|
async accessible(tenantId: number, feature: string) {
|
||||||
const settings = this.tenancy.settings(tenantId);
|
const settings = this.tenancy.settings(tenantId);
|
||||||
|
|
||||||
return !!settings.get({ group: 'features', key: feature });
|
const defaultValue = this.configure.getFeatureConfigure(
|
||||||
|
feature,
|
||||||
|
'defaultValue'
|
||||||
|
);
|
||||||
|
const settingValue = settings.get(
|
||||||
|
{ group: 'features', key: feature },
|
||||||
|
defaultValue
|
||||||
|
);
|
||||||
|
return settingValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Features, IFeatureConfiugration } from '@/interfaces';
|
import { Features, IFeatureConfiugration } from '@/interfaces';
|
||||||
|
import config from '@/config';
|
||||||
|
import { defaultTo } from 'lodash';
|
||||||
|
|
||||||
export const FeaturesConfigure: IFeatureConfiugration[] = [
|
export const FeaturesConfigure: IFeatureConfiugration[] = [
|
||||||
{
|
{
|
||||||
@@ -9,4 +11,8 @@ export const FeaturesConfigure: IFeatureConfiugration[] = [
|
|||||||
name: Features.WAREHOUSES,
|
name: Features.WAREHOUSES,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: Features.BankSyncing,
|
||||||
|
defaultValue: defaultTo(config.bankSync.enabled, false),
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export class LemonSqueezyWebhooks {
|
|||||||
const variantId = attributes.variant_id as string;
|
const variantId = attributes.variant_id as string;
|
||||||
|
|
||||||
// We assume that the Plan table is up to date.
|
// We assume that the Plan table is up to date.
|
||||||
const plan = await Plan.query().findOne('slug', 'essentials-yearly');
|
const plan = await Plan.query().findOne('slug', 'early-adaptor');
|
||||||
|
|
||||||
if (!plan) {
|
if (!plan) {
|
||||||
throw new Error(`Plan with variantId ${variantId} not found.`);
|
throw new Error(`Plan with variantId ${variantId} not found.`);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
exports.up = function (knex) {
|
||||||
|
return knex.seed.run({
|
||||||
|
specific: 'seed_tenants_free_subscription.js',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
exports.seed = (knex) => {
|
||||||
|
// Deletes ALL existing entries
|
||||||
|
return knex('subscription_plan_subscriptions')
|
||||||
|
.then(async () => {
|
||||||
|
const tenants = await knex('tenants');
|
||||||
|
|
||||||
|
for (const tenant of tenants) {
|
||||||
|
const existingSubscription = await knex('subscription_plan_subscriptions')
|
||||||
|
.where('tenantId', tenant.id)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
if (!existingSubscription) {
|
||||||
|
const freePlan = await knex('subscription_plans').where('slug', 'free').first();
|
||||||
|
|
||||||
|
await knex('subscription_plan_subscriptions').insert({
|
||||||
|
tenantId: tenant.id,
|
||||||
|
planId: freePlan.id,
|
||||||
|
slug: 'main',
|
||||||
|
startsAt: knex.fn.now(),
|
||||||
|
endsAt: null,
|
||||||
|
createdAt: knex.fn.now(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
3
packages/webapp/.gitignore
vendored
3
packages/webapp/.gitignore
vendored
@@ -20,4 +20,5 @@
|
|||||||
.env.production.local
|
.env.production.local
|
||||||
|
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
|
||||||
|
dist
|
||||||
@@ -5,5 +5,6 @@ export const Features = {
|
|||||||
Warehouses: 'warehouses',
|
Warehouses: 'warehouses',
|
||||||
Branches: 'branches',
|
Branches: 'branches',
|
||||||
ManualJournal: 'manualJournal',
|
ManualJournal: 'manualJournal',
|
||||||
Projects:'Projects'
|
Projects:'Projects',
|
||||||
|
BankSyncing: 'BankSyncing',
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
Can,
|
Can,
|
||||||
Icon,
|
Icon,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
|
FeatureCan,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useRefreshCashflowAccounts } from '@/hooks/query';
|
import { useRefreshCashflowAccounts } from '@/hooks/query';
|
||||||
import { CashflowAction, AbilitySubject } from '@/constants/abilityOption';
|
import { CashflowAction, AbilitySubject } from '@/constants/abilityOption';
|
||||||
@@ -21,7 +22,7 @@ import withCashflowAccountsTableActions from '../AccountTransactions/withCashflo
|
|||||||
|
|
||||||
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
|
import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils';
|
||||||
|
|
||||||
import { ACCOUNT_TYPE } from '@/constants';
|
import { ACCOUNT_TYPE, Features } from '@/constants';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
@@ -110,12 +111,14 @@ function CashFlowAccountsActionsBar({
|
|||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
|
||||||
<NavbarGroup align={Alignment.RIGHT}>
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
<Button
|
<FeatureCan feature={Features.BankSyncing}>
|
||||||
className={Classes.MINIMAL}
|
<Button
|
||||||
text={'Connect to Bank / Credit Card'}
|
className={Classes.MINIMAL}
|
||||||
onClick={handleConnectToBank}
|
text={'Connect to Bank / Credit Card'}
|
||||||
/>
|
onClick={handleConnectToBank}
|
||||||
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
</FeatureCan>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="refresh-16" iconSize={14} />}
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
|||||||
2703
pnpm-lock.yaml
generated
2703
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
|||||||
packages:
|
|
||||||
- "packages/*"
|
|
||||||
24
scripts/backup.sh
Normal file
24
scripts/backup.sh
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Takes a backup of database Docker volume and compress into one .tar.gz
|
||||||
|
# file and upload to s3 package through s3cmd.
|
||||||
|
S3_BUCKET="s3://bigcapital-backup"
|
||||||
|
|
||||||
|
# Generate the current date and time formatted as YYYY-MM-DD-HH-MM-SS
|
||||||
|
CURRENT_DATETIME=$(date +"%Y-%m-%d-%H-%M-%S")
|
||||||
|
|
||||||
|
# Define the filename with the current date and time
|
||||||
|
FILE_NAME="bigcapital-mariadb-${CURRENT_DATETIME}.tar.gz"
|
||||||
|
|
||||||
|
# Create a sample file (replace this with your actual file creation process)
|
||||||
|
echo "This is a sample file created on ${CURRENT_DATETIME}" > "$FILE_NAME"
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
--mount source=bigcapital_prod_mysql,target=/data/db \
|
||||||
|
-v $(pwd):/backup \
|
||||||
|
busybox \
|
||||||
|
tar -czvf "/backup/$FILE_NAME" /data/db
|
||||||
|
|
||||||
|
# Upload the file to S3 using s3cmd
|
||||||
|
s3cmd put "$FILE_NAME" "$S3_BUCKET/"
|
||||||
|
|
||||||
|
# Remove the temporary file
|
||||||
|
rm "$FILE_NAME"
|
||||||
7
scripts/store-backup.sh
Normal file
7
scripts/store-backup.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
# Store the backup.
|
||||||
|
docker run --rm \
|
||||||
|
--mount source=bigcapital_dev_mysql,target=/data/db \
|
||||||
|
-v $(pwd):/backup \
|
||||||
|
busybox \
|
||||||
|
tar -xzvf /backup/bigcapital-mariadb-2024-04-24-15-14-40.tar.gz -C /
|
||||||
Reference in New Issue
Block a user