Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45d5b658e8 | ||
|
|
f0cbe4a7de | ||
|
|
9ad411af65 |
@@ -1,4 +1,4 @@
|
|||||||
from brewman.main import init
|
from .main import init
|
||||||
|
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = "11.1.4"
|
__version__ = "11.1.5"
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import json
|
||||||
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
workers_per_core_str = os.getenv("WORKERS_PER_CORE", "1")
|
||||||
|
max_workers_str = os.getenv("MAX_WORKERS")
|
||||||
|
use_max_workers = None
|
||||||
|
if max_workers_str:
|
||||||
|
use_max_workers = int(max_workers_str)
|
||||||
|
web_concurrency_str = os.getenv("WEB_CONCURRENCY", None)
|
||||||
|
|
||||||
|
host = os.getenv("HOST", "0.0.0.0")
|
||||||
|
port = os.getenv("PORT", "9994")
|
||||||
|
bind_env = os.getenv("BIND", None)
|
||||||
|
use_loglevel = os.getenv("LOG_LEVEL", "info")
|
||||||
|
if bind_env:
|
||||||
|
use_bind = bind_env
|
||||||
|
else:
|
||||||
|
use_bind = f"{host}:{port}"
|
||||||
|
|
||||||
|
cores = multiprocessing.cpu_count()
|
||||||
|
workers_per_core = float(workers_per_core_str)
|
||||||
|
default_web_concurrency = workers_per_core * cores
|
||||||
|
if web_concurrency_str:
|
||||||
|
web_concurrency = int(web_concurrency_str)
|
||||||
|
assert web_concurrency > 0
|
||||||
|
else:
|
||||||
|
web_concurrency = max(int(default_web_concurrency), 2)
|
||||||
|
if use_max_workers:
|
||||||
|
web_concurrency = min(web_concurrency, use_max_workers)
|
||||||
|
accesslog_var = os.getenv("ACCESS_LOG", "-")
|
||||||
|
use_accesslog = accesslog_var or None
|
||||||
|
errorlog_var = os.getenv("ERROR_LOG", "-")
|
||||||
|
use_errorlog = errorlog_var or None
|
||||||
|
graceful_timeout_str = os.getenv("GRACEFUL_TIMEOUT", "120")
|
||||||
|
timeout_str = os.getenv("TIMEOUT", "120")
|
||||||
|
keepalive_str = os.getenv("KEEP_ALIVE", "5")
|
||||||
|
|
||||||
|
# Gunicorn config variables
|
||||||
|
loglevel = use_loglevel
|
||||||
|
workers = web_concurrency
|
||||||
|
bind = use_bind
|
||||||
|
errorlog = use_errorlog
|
||||||
|
worker_tmp_dir = "/dev/shm"
|
||||||
|
accesslog = use_accesslog
|
||||||
|
graceful_timeout = int(graceful_timeout_str)
|
||||||
|
timeout = int(timeout_str)
|
||||||
|
keepalive = int(keepalive_str)
|
||||||
|
|
||||||
|
|
||||||
|
# For debugging and testing
|
||||||
|
log_data = {
|
||||||
|
"loglevel": loglevel,
|
||||||
|
"workers": workers,
|
||||||
|
"bind": bind,
|
||||||
|
"graceful_timeout": graceful_timeout,
|
||||||
|
"timeout": timeout,
|
||||||
|
"keepalive": keepalive,
|
||||||
|
"errorlog": errorlog,
|
||||||
|
"accesslog": accesslog,
|
||||||
|
# Additional, non-gunicorn variables
|
||||||
|
"workers_per_core": workers_per_core,
|
||||||
|
"use_max_workers": use_max_workers,
|
||||||
|
"host": host,
|
||||||
|
"port": port,
|
||||||
|
}
|
||||||
|
print(json.dumps(log_data))
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
[loggers]
|
||||||
|
keys=root, gunicorn.error, gunicorn.access
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys=console, error, access
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys=generic, error, access
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level=INFO
|
||||||
|
handlers=console
|
||||||
|
qualname=root
|
||||||
|
|
||||||
|
[logger_gunicorn.error]
|
||||||
|
level=INFO
|
||||||
|
handlers=console
|
||||||
|
qualname=gunicorn.error
|
||||||
|
|
||||||
|
[logger_gunicorn.access]
|
||||||
|
level=INFO
|
||||||
|
handlers=access
|
||||||
|
qualname=gunicorn.access
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class=StreamHandler
|
||||||
|
formatter=generic
|
||||||
|
args=(sys.stdout, )
|
||||||
|
|
||||||
|
[handler_error]
|
||||||
|
class=StreamHandler
|
||||||
|
formatter=error
|
||||||
|
args=(sys.stdout, )
|
||||||
|
|
||||||
|
[handler_access]
|
||||||
|
class=StreamHandler
|
||||||
|
formatter=access
|
||||||
|
args=(sys.stdout, )
|
||||||
|
|
||||||
|
[formatter_generic]
|
||||||
|
format=%(asctime)s [%(name)s %(levelname)s %(process)d] %(message)s
|
||||||
|
datefmt=%Y-%m-%d %H:%M:%S %Z
|
||||||
|
class=logging.Formatter
|
||||||
|
|
||||||
|
[formatter_error]
|
||||||
|
format=%(asctime)s [%(name)s %(levelname)s %(process)d] %(message)s | %(funcName)s() | %(pathname)s L%(lineno)-4d
|
||||||
|
datefmt=%Y-%m-%d %H:%M:%S %Z
|
||||||
|
class=logging.Formatter
|
||||||
|
|
||||||
|
[formatter_access]
|
||||||
|
format=%(asctime)s [%(name)s %(levelname)s %(process)d] %(message)s
|
||||||
|
datefmt=%Y-%m-%d %H:%M:%S %Z
|
||||||
|
class=logging.Formatter
|
||||||
@@ -1,27 +1,28 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "brewman"
|
name = "brewman"
|
||||||
version = "11.1.4"
|
version = "11.1.5"
|
||||||
description = "Accounting plus inventory management for a restaurant."
|
description = "Accounting plus inventory management for a restaurant."
|
||||||
authors = ["tanshu <git@tanshu.com>"]
|
authors = ["tanshu <git@tanshu.com>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
uvicorn = {extras = ["standard"], version = "^0.21.1"}
|
uvicorn = {extras = ["standard"], version = "^0.23.2"}
|
||||||
fastapi = {extras = ["all"], version = "^0.100.0"}
|
fastapi = {extras = ["all"], version = "^0.101.0"}
|
||||||
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
|
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
|
||||||
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
|
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
|
||||||
psycopg2-binary = "^2.9.5"
|
psycopg2-binary = "^2.9.7"
|
||||||
SQLAlchemy = "^2.0.7"
|
SQLAlchemy = "^2.0.19"
|
||||||
python-multipart = "^0.0.6"
|
python-multipart = "^0.0.6"
|
||||||
PyJWT = "^2.8.0"
|
PyJWT = "^2.8.0"
|
||||||
alembic = "^1.11.1"
|
alembic = "^1.11.2"
|
||||||
itsdangerous = "^2.1.2"
|
itsdangerous = "^2.1.2"
|
||||||
python-dotenv = "^1.0.0"
|
python-dotenv = "^1.0.0"
|
||||||
pydantic = {extras = ["dotenv"], version = "^2.0.3"}
|
pydantic = {extras = ["dotenv"], version = "^2.1.1"}
|
||||||
starlette = "^0.27.0"
|
starlette = "^0.27.0"
|
||||||
pandas = "^2.0.0"
|
pandas = "^2.0.0"
|
||||||
arq = "^0.25.0"
|
arq = "^0.25.0"
|
||||||
openpyxl = "^3.1.2"
|
openpyxl = "^3.1.2"
|
||||||
|
gunicorn = "^21.2.0"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
flake8 = "^6.0.0"
|
flake8 = "^6.0.0"
|
||||||
|
|||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
gunicorn brewman.main:app --worker-class uvicorn.workers.UvicornWorker --config ./gunicorn.conf.py --log-config ./logging.conf
|
||||||
@@ -50,4 +50,4 @@ RUN chmod 777 /app/docker-entrypoint.sh \
|
|||||||
&& ln -s /app/docker-entrypoint.sh /
|
&& ln -s /app/docker-entrypoint.sh /
|
||||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
|
||||||
CMD ["poetry", "run", "python", "-m", "brewman"]
|
CMD ["poetry", "run", "gunicorn", "brewman.main:app", "--worker-class", "uvicorn.workers.UvicornWorker", "--config", "/app/gunicorn.conf.py", "--log-config", "/app/logging.conf"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "overlord",
|
"name": "overlord",
|
||||||
"version": "11.1.4",
|
"version": "11.1.5",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ export class EmployeeBenefitsComponent implements OnInit, AfterViewInit {
|
|||||||
if (formValue === undefined) {
|
if (formValue === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const grossSalary = +(formValue.grossSalary ?? '0');
|
const grossSalary = Number(formValue.grossSalary);
|
||||||
const daysWorked = +(formValue.daysWorked ?? '0');
|
const daysWorked = Number(formValue.daysWorked);
|
||||||
const date = this.form.value.date ?? new Date();
|
const date = this.form.value.date ?? new Date();
|
||||||
const daysInMonth = moment(date).daysInMonth();
|
const daysInMonth = moment(date).daysInMonth();
|
||||||
const esi = EmployeeBenefitsComponent.getEsi(grossSalary, daysWorked, daysInMonth);
|
const esi = EmployeeBenefitsComponent.getEsi(grossSalary, daysWorked, daysInMonth);
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
|
|||||||
const formValue = this.form.value;
|
const formValue = this.form.value;
|
||||||
this.item.name = formValue.name ?? '';
|
this.item.name = formValue.name ?? '';
|
||||||
this.item.designation = formValue.designation ?? '';
|
this.item.designation = formValue.designation ?? '';
|
||||||
this.item.salary = +(formValue.salary ?? '0');
|
this.item.salary = Number(formValue.salary);
|
||||||
this.item.points = +(formValue.points ?? '0');
|
this.item.points = Number(formValue.points);
|
||||||
this.item.isActive = formValue.isActive ?? true;
|
this.item.isActive = formValue.isActive ?? true;
|
||||||
this.item.costCentre.id = formValue.costCentre ?? '';
|
this.item.costCentre.id = formValue.costCentre ?? '';
|
||||||
this.item.joiningDate = moment(formValue.joiningDate).format('DD-MMM-YYYY');
|
this.item.joiningDate = moment(formValue.joiningDate).format('DD-MMM-YYYY');
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ export class ProductLedgerDataSource extends DataSource<ProductLedgerItem> {
|
|||||||
case 'date':
|
case 'date':
|
||||||
return compare(a.date, b.date, isAsc);
|
return compare(a.date, b.date, isAsc);
|
||||||
case 'debitQuantity':
|
case 'debitQuantity':
|
||||||
return compare(Number(a.debitQuantity ?? '0'), Number(b.debitQuantity ?? '0'), isAsc);
|
return compare(Number(a.debitQuantity), Number(b.debitQuantity), isAsc);
|
||||||
case 'debitAmount':
|
case 'debitAmount':
|
||||||
return compare(Number(a.debitAmount ?? '0'), Number(b.debitAmount ?? '0'), isAsc);
|
return compare(Number(a.debitAmount), Number(b.debitAmount), isAsc);
|
||||||
case 'creditQuantity':
|
case 'creditQuantity':
|
||||||
return compare(Number(a.creditQuantity ?? '0'), Number(b.creditQuantity ?? '0'), isAsc);
|
return compare(Number(a.creditQuantity), Number(b.creditQuantity), isAsc);
|
||||||
case 'creditAmount':
|
case 'creditAmount':
|
||||||
return compare(Number(a.creditAmount ?? '0'), Number(b.creditAmount ?? '0'), isAsc);
|
return compare(Number(a.creditAmount), Number(b.creditAmount), isAsc);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,12 +113,12 @@ export class ProductLedgerComponent implements OnInit, AfterViewInit {
|
|||||||
this.runningAmount = 0;
|
this.runningAmount = 0;
|
||||||
this.info.body.forEach((item) => {
|
this.info.body.forEach((item) => {
|
||||||
if (item.type !== 'Opening Balance') {
|
if (item.type !== 'Opening Balance') {
|
||||||
this.debitAmount += Number(item.debitAmount ?? '0');
|
this.debitAmount += Number(item.debitAmount);
|
||||||
this.creditQuantity += Number(item.creditQuantity ?? '0');
|
this.creditQuantity += Number(item.creditQuantity);
|
||||||
this.creditAmount += Number(item.creditAmount ?? '0');
|
this.creditAmount += Number(item.creditAmount);
|
||||||
}
|
}
|
||||||
this.runningQuantity += Number(item.debitQuantity ?? '0') - Number(item.creditQuantity ?? '0');
|
this.runningQuantity += Number(item.debitQuantity) - Number(item.creditQuantity);
|
||||||
this.runningAmount += Number(item.debitAmount ?? '0') - Number(item.creditAmount ?? '0');
|
this.runningAmount += Number(item.debitAmount) - Number(item.creditAmount);
|
||||||
item.runningQuantity = this.runningQuantity;
|
item.runningQuantity = this.runningQuantity;
|
||||||
item.runningAmount = this.runningAmount;
|
item.runningAmount = this.runningAmount;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -113,22 +113,22 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
|||||||
if (formValue === undefined) {
|
if (formValue === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fraction = +(formValue.fraction ?? '0');
|
const fraction = Number(formValue.fraction);
|
||||||
if (fraction < 1) {
|
if (fraction < 1) {
|
||||||
this.toaster.show('Danger', 'Fraction has to be >= 1');
|
this.toaster.show('Danger', 'Fraction has to be >= 1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const productYield = +(formValue.productYield ?? '0');
|
const productYield = Number(formValue.productYield);
|
||||||
if (productYield < 0 || productYield > 1) {
|
if (productYield < 0 || productYield > 1) {
|
||||||
this.toaster.show('Danger', 'Product Yield has to be > 0 and <= 1');
|
this.toaster.show('Danger', 'Product Yield has to be > 0 and <= 1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const costPrice = +(formValue.costPrice ?? '0');
|
const costPrice = Number(formValue.costPrice);
|
||||||
if (costPrice < 0) {
|
if (costPrice < 0) {
|
||||||
this.toaster.show('Danger', 'Price has to be >= 0');
|
this.toaster.show('Danger', 'Price has to be >= 0');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const salePrice = +(formValue.salePrice ?? '0');
|
const salePrice = Number(formValue.salePrice);
|
||||||
if (salePrice < 0) {
|
if (salePrice < 0) {
|
||||||
this.toaster.show('Danger', 'Sale Price has to be >= 0');
|
this.toaster.show('Danger', 'Sale Price has to be >= 0');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ export const environment = {
|
|||||||
production: true,
|
production: true,
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||||
version: '11.1.4',
|
version: '11.1.5',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const environment = {
|
|||||||
production: false,
|
production: false,
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
|
||||||
version: '11.1.4',
|
version: '11.1.5',
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user