Compare commits

..
6 Commits
23 changed files with 81 additions and 113 deletions
+1 -1
View File
@@ -1 +1 @@
__version__ = "11.1.5"
__version__ = "11.1.7"
+26
View File
@@ -1,3 +1,5 @@
import uuid
from typing import TYPE_CHECKING
from sqlalchemy.orm import Mapped, relationship
@@ -18,6 +20,30 @@ class Account(AccountBase):
"Product", primaryjoin="Account.id==Product.account_id", back_populates="account"
)
def __init__(
self,
name: str,
type_id: int,
is_starred: bool,
is_active: bool,
is_reconcilable: bool,
cost_centre_id: uuid.UUID,
code: int | None = None,
id_: uuid.UUID | None = None,
is_fixture: bool = False,
) -> None:
if code is not None:
self.code = code
self.name = name
self.type_id = type_id
self.is_starred = is_starred
self.is_active = is_active
self.is_reconcilable = is_reconcilable
self.cost_centre_id = cost_centre_id
if id_ is not None:
self.id = id_
self.is_fixture = is_fixture
def can_delete(self, advanced_delete: bool) -> tuple[bool, str]:
if len(self.products) > 0:
return False, "Account has products"
-7
View File
@@ -70,13 +70,6 @@ class AccountBase:
self.id = id_
self.is_fixture = is_fixture
def create(self, db: Session) -> "AccountBase":
self.code = db.execute(
select(func.coalesce(func.max(AccountBase.code), 0) + 1).where(AccountBase.type_id == self.type_id)
).scalar_one()
db.add(self)
return self
def can_delete(self, advanced_delete: bool) -> tuple[bool, str]:
if self.is_fixture:
return False, f"{self.name} is a fixture and cannot be edited or deleted."
+2 -3
View File
@@ -35,15 +35,14 @@ def save(
with SessionFuture() as db:
item = Account(
name=data.name,
code=Account.get_code(data.type_, db),
type_id=data.type_,
is_starred=data.is_starred,
is_active=data.is_active,
is_reconcilable=data.is_reconcilable,
cost_centre_id=data.cost_centre.id_,
)
item.code = db.execute(
select(func.coalesce(func.max(Account.code), 0) + 1).where(Account.type_id == item.type_id)
).scalar_one()
db.add(item)
db.commit()
except SQLAlchemyError as e:
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "brewman"
version = "11.1.5"
version = "11.1.7"
description = "Accounting plus inventory management for a restaurant."
authors = ["tanshu <git@tanshu.com>"]
+1 -1
View File
@@ -32,5 +32,5 @@ else
echo "No version bump"
fi
cd "$parent_path/docker" || exit
docker save brewman:latest | bzip2 | pv | ssh beacon 'bunzip2 | sudo docker load'
docker save brewman:latest | bzip2 | pv | ssh gondor 'bunzip2 | sudo docker load'
ansible-playbook --inventory hosts playbook.yml
@@ -2,15 +2,11 @@ HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN
DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/brewman_hinchco
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/brewman_{{ name }}
MODULE_NAME=brewman.main
PROJECT_NAME=brewman
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=123456
POSTGRES_DB=brewman_hinchco
SECRET_KEY=7b889cff76532fde8483304cf415243f70df200518ba9aee4d26c0709ad6fbd1
MIDDLEWARE_SECRET_KEY=1e36e7f678
SECRET_KEY={{ secret_key }}
MIDDLEWARE_SECRET_KEY={{ middleware_key }}
ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=30
ALEMBIC_LOG_LEVEL=INFO
-17
View File
@@ -1,17 +0,0 @@
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN
DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/acc
MODULE_NAME=brewman.main
PROJECT_NAME=brewman
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=123456
POSTGRES_DB=exp
SECRET_KEY=c9bee2d38676447c2f7a9ea715446e2fd09f16fbaa5b3f6a6f207ec18993987f
MIDDLEWARE_SECRET_KEY=cb71666b9c
ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=30
ALEMBIC_LOG_LEVEL=INFO
ALEMBIC_SQLALCHEMY_LOG_LEVEL=WARN
-17
View File
@@ -1,17 +0,0 @@
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN
DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/exp
MODULE_NAME=brewman.main
PROJECT_NAME=brewman
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=123456
POSTGRES_DB=exp
SECRET_KEY=8546a61262dab7c05ccf2e26abe30bc10966904df6dfd29259ea85dd0844a8e7
MIDDLEWARE_SECRET_KEY=da6fcd999b
ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=30
ALEMBIC_LOG_LEVEL=INFO
ALEMBIC_SQLALCHEMY_LOG_LEVEL=WARN
-17
View File
@@ -1,17 +0,0 @@
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN
DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/hops
MODULE_NAME=brewman.main
PROJECT_NAME=brewman
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=123456
POSTGRES_DB=exp
SECRET_KEY=cfb3be420c4e2b0ed423b2e4e238713d0461e2ba56198138ad6c4d82aef6295c
MIDDLEWARE_SECRET_KEY=9c2bdd24be
ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=30
ALEMBIC_LOG_LEVEL=INFO
ALEMBIC_SQLALCHEMY_LOG_LEVEL=WARN
-17
View File
@@ -1,17 +0,0 @@
HOST=0.0.0.0
PORT=80
LOG_LEVEL=WARN
DEBUG=false
SQLALCHEMY_DATABASE_URI=postgresql://postgres:123456@db:5432/mhl
MODULE_NAME=brewman.main
PROJECT_NAME=brewman
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=123456
POSTGRES_DB=exp
SECRET_KEY=c9fd1b99931feb083f67470170650420b99eb35368d3de186427166c28d32c8b
MIDDLEWARE_SECRET_KEY=9183bdcfb0
ALGORITHM=HS256
JWT_TOKEN_EXPIRE_MINUTES=30
ALEMBIC_LOG_LEVEL=INFO
ALEMBIC_SQLALCHEMY_LOG_LEVEL=WARN
+5 -5
View File
@@ -5,11 +5,11 @@
# - A hostname/ip can be a member of multiple groups
[brewman]
acc ansible_host=beacon var_file=vars/acc.yml
exp ansible_host=beacon var_file=vars/exp.yml
hops ansible_host=beacon var_file=vars/hops.yml
mhl ansible_host=beacon var_file=vars/mhl.yml
hinchco ansible_host=beacon var_file=vars/hinchco.yml
acc ansible_host=gondor var_file=vars/acc.yml
exp ansible_host=gondor var_file=vars/exp.yml
hops ansible_host=gondor var_file=vars/hops.yml
mhl ansible_host=gondor var_file=vars/mhl.yml
hinchco ansible_host=gondor var_file=vars/hinchco.yml
[all:vars]
ansible_python_interpreter=/usr/bin/python3
+6 -3
View File
@@ -6,6 +6,7 @@
become: true
vars_files:
- "{{ var_file }}"
- vars/default.yml
tasks:
- name: Copy dockerfile
@@ -30,7 +31,7 @@
- name: Upload the .env file
template:
src: "{{ env_file }}"
src: "files/.env"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
@@ -40,8 +41,10 @@
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
links:
- "postgres:db"
etc_hosts:
db : "{{ db_host }}"
# links:
# - "postgres:db"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
+5 -2
View File
@@ -1,6 +1,9 @@
---
name: acc
http_host: "acc.hopsngrains.com"
http_conf: "acc.hopsngrains.com.conf"
host_port: "8659"
host_directory: "brewman-acc"
env_file: "files/.env-acc"
secret_key: c9bee2d38676447c2f7a9ea715446e2fd09f16fbaa5b3f6a6f207ec18993987f
middleware_key: cb71666b9c
+4
View File
@@ -0,0 +1,4 @@
---
db_host: 172.26.12.67
host_directory: "brewman-{{ name }}"
db_name: "brewman_{{ name }}"
+5 -2
View File
@@ -1,6 +1,9 @@
---
name: exp
http_host: "exp.tanshu.com"
http_conf: "exp.tanshu.com.conf"
host_port: "8656"
host_directory: "brewman-exp"
env_file: "files/.env-exp"
secret_key: 8546a61262dab7c05ccf2e26abe30bc10966904df6dfd29259ea85dd0844a8e7
middleware_key: da6fcd999b
+5 -2
View File
@@ -1,6 +1,9 @@
---
name: hinchco
http_host: "acc.hinchco.in"
http_conf: "acc.hinchco.in.conf"
host_port: "8655"
host_directory: "brewman-hinchco"
env_file: "files/.env-hinchco"
secret_key: 7b889cff76532fde8483304cf415243f70df200518ba9aee4d26c0709ad6fbd1
middleware_key: 1e36e7f678
+5 -2
View File
@@ -1,6 +1,9 @@
---
name: hops
http_host: "hops.hopsngrains.com"
http_conf: "hops.hopsngrains.com.conf"
host_port: "8658"
host_directory: "brewman-hops"
env_file: "files/.env-hops"
secret_key: cfb3be420c4e2b0ed423b2e4e238713d0461e2ba56198138ad6c4d82aef6295c
middleware_key: 9c2bdd24be
+5 -2
View File
@@ -1,6 +1,9 @@
---
name: mhl
http_host: "mhl.hopsngrains.com"
http_conf: "mhl.hopsngrains.com.conf"
host_port: "8657"
host_directory: "brewman-mhl"
env_file: "files/.env-mhl"
secret_key: c9fd1b99931feb083f67470170650420b99eb35368d3de186427166c28d32c8b
middleware_key: 9183bdcfb0
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "overlord",
"version": "11.1.5",
"version": "11.1.7",
"scripts": {
"ng": "ng",
"start": "ng serve",
+4 -4
View File
@@ -193,10 +193,10 @@ export class IssueComponent implements OnInit, AfterViewInit, OnDestroy {
this.voucher.inventories.push(
new Inventory({
quantity,
rate: this.batch.rate,
tax: this.batch.tax,
discount: this.batch.discount,
amount: quantity * this.batch.rate * (1 + this.batch.tax) * (1 - this.batch.discount),
rate: +this.batch.rate,
tax: +this.batch.tax,
discount: +this.batch.discount,
amount: quantity * +this.batch.rate * (1 + +this.batch.tax) * (1 - +this.batch.discount),
batch: this.batch,
}),
);
@@ -2,5 +2,5 @@ export const environment = {
production: true,
// eslint-disable-next-line @typescript-eslint/naming-convention
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
version: '11.1.5',
version: '11.1.7',
};
+1 -1
View File
@@ -6,7 +6,7 @@ export const environment = {
production: false,
// eslint-disable-next-line @typescript-eslint/naming-convention
ACCESS_TOKEN_REFRESH_MINUTES: 10, // refresh token 10 minutes before expiry
version: '11.1.5',
version: '11.1.7',
};
/*