2016-12-24 11:41:01 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import uuid
|
|
|
|
|
2020-10-07 15:18:43 +00:00
|
|
|
import transaction
|
2016-12-24 11:41:01 +00:00
|
|
|
|
|
|
|
from brewman.models.auth import (
|
|
|
|
Client,
|
|
|
|
Group,
|
2020-10-07 15:18:43 +00:00
|
|
|
LoginHistory,
|
2016-12-24 11:41:01 +00:00
|
|
|
Role,
|
|
|
|
User,
|
|
|
|
role_group,
|
|
|
|
user_group,
|
|
|
|
)
|
|
|
|
from brewman.models.master import (
|
2018-07-07 11:01:44 +00:00
|
|
|
Account,
|
|
|
|
AccountBase,
|
2020-10-07 15:18:43 +00:00
|
|
|
CostCentre,
|
|
|
|
DbSetting,
|
|
|
|
Employee,
|
|
|
|
Product,
|
2016-12-24 11:41:01 +00:00
|
|
|
ProductGroup,
|
|
|
|
Recipe,
|
|
|
|
RecipeItem,
|
|
|
|
)
|
|
|
|
from brewman.models.voucher import (
|
|
|
|
Attendance,
|
|
|
|
Batch,
|
2020-10-07 15:18:43 +00:00
|
|
|
DbImage,
|
|
|
|
EmployeeBenefit,
|
2016-12-24 11:41:01 +00:00
|
|
|
Fingerprint,
|
2020-10-07 15:18:43 +00:00
|
|
|
Incentive,
|
2016-12-24 11:41:01 +00:00
|
|
|
Inventory,
|
|
|
|
Journal,
|
|
|
|
Product,
|
|
|
|
Voucher,
|
|
|
|
)
|
2020-10-07 15:18:43 +00:00
|
|
|
from pyramid.paster import get_appsettings, setup_logging
|
|
|
|
from pyramid.scripts.common import parse_vars
|
|
|
|
|
|
|
|
from ..models import get_engine, get_session_factory, get_tm_session
|
|
|
|
from ..models.meta import Base
|
2016-12-24 11:41:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def usage(argv):
|
|
|
|
cmd = os.path.basename(argv[0])
|
2020-10-07 16:59:24 +00:00
|
|
|
print(
|
|
|
|
"usage: %s <config_uri> [var=value]\n"
|
|
|
|
'(example: "%s development.ini")' % (cmd, cmd)
|
|
|
|
)
|
2016-12-24 11:41:01 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv=sys.argv):
|
|
|
|
if len(argv) < 2:
|
|
|
|
usage(argv)
|
|
|
|
config_uri = argv[1]
|
|
|
|
options = parse_vars(argv[2:])
|
|
|
|
setup_logging(config_uri)
|
|
|
|
settings = get_appsettings(config_uri, options=options)
|
|
|
|
|
|
|
|
engine = get_engine(settings)
|
|
|
|
Base.metadata.create_all(engine)
|
|
|
|
|
|
|
|
session_factory = get_session_factory(engine)
|
|
|
|
|
|
|
|
with transaction.manager:
|
|
|
|
dbsession = get_tm_session(session_factory, transaction.manager)
|
|
|
|
|
2020-10-07 16:59:24 +00:00
|
|
|
user = User(
|
|
|
|
"Admin", "123456", False, uuid.UUID("8de98592-76d9-c74d-bb3f-d6184d388b5a")
|
|
|
|
)
|
2016-12-24 11:41:01 +00:00
|
|
|
dbsession.add(user)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
|
|
|
groups = [
|
|
|
|
Group("Owner", uuid.UUID("52e08c0c-048a-784f-be10-6e129ad4b5d4")),
|
|
|
|
Group("Accountant", uuid.UUID("bc4c2d23-437a-984d-abd4-7d5fce677547")),
|
2020-10-07 16:59:24 +00:00
|
|
|
Group(
|
|
|
|
"Accounts Manager", uuid.UUID("cfc44fa7-3392-5b45-b311-5959333f568f")
|
|
|
|
),
|
2019-04-06 04:13:12 +00:00
|
|
|
]
|
|
|
|
|
2016-12-24 11:41:01 +00:00
|
|
|
for group in groups:
|
|
|
|
dbsession.add(group)
|
|
|
|
user.groups.append(group)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
|
|
|
roles = [
|
|
|
|
Role("Attendance", uuid.UUID("09d05434-a09a-fa45-963b-769a2e3fc667")),
|
|
|
|
Role("Trial Balance", uuid.UUID("3b099fec-ddc5-4243-b30e-afb78d9ca14a")),
|
|
|
|
Role("Cash Flow", uuid.UUID("c4d3ae29-420b-ea4c-ae90-00a356263fd9")),
|
|
|
|
Role("Cost Centres", uuid.UUID("6fcc1a20-6aec-e840-b334-1632b34aeab8")),
|
|
|
|
Role("Users", uuid.UUID("c5b7d9d7-f178-0e45-8ea4-bf4e08ec901b")),
|
|
|
|
Role("Daybook", uuid.UUID("c3edb554-a057-8942-8030-37b8e926d583")),
|
2020-10-07 15:18:43 +00:00
|
|
|
Role(
|
|
|
|
"Edit Posted Vouchers",
|
|
|
|
uuid.UUID("d6675817-ddf5-bf40-9de6-fa223eb4aaa6"),
|
|
|
|
),
|
2019-04-06 04:13:12 +00:00
|
|
|
Role("Employees", uuid.UUID("e4edd0ac-7f5d-e64d-8611-73fdc4cd8ba2")),
|
|
|
|
Role("Fingerprints", uuid.UUID("d9c45323-f997-ba46-9407-8a7145f0828b")),
|
|
|
|
Role("Issue", uuid.UUID("03b602eb-f58a-b94f-af58-8cb47d7849d0")),
|
|
|
|
Role("Journal", uuid.UUID("7661388f-62ce-1c41-8e0d-0326ee5d4018")),
|
|
|
|
Role("Accounts", uuid.UUID("f438262f-72dd-2f4e-9186-5abc3af44fba")),
|
|
|
|
Role("Product Ledger", uuid.UUID("018a2408-e804-1446-90c5-b015829da6ba")),
|
2020-10-07 16:59:24 +00:00
|
|
|
Role(
|
|
|
|
"Backdated Vouchers", uuid.UUID("b67b2062-5ca7-134f-8258-5d284dd92426")
|
|
|
|
),
|
2019-04-06 04:13:12 +00:00
|
|
|
Role("Payment", uuid.UUID("f85c0b52-c3fd-7141-8957-7a56cdc014a4")),
|
|
|
|
Role("Post Vouchers", uuid.UUID("36e741da-1a57-b047-a59e-dcd58fcf4338")),
|
|
|
|
Role("Products", uuid.UUID("74fa6d21-eebb-e14c-8153-bebc57190ab4")),
|
|
|
|
Role("Product Groups", uuid.UUID("08413a22-cf88-fd43-b2b7-365d2951d99f")),
|
|
|
|
Role("Profit & Loss", uuid.UUID("0492ebb3-76f3-204e-ab94-bbfe880f0691")),
|
|
|
|
Role("Purchase", uuid.UUID("12335acb-8630-2d41-a191-1517c8d172de")),
|
|
|
|
Role("Purchase Entries", uuid.UUID("78a6422b-aa11-174c-9dfa-412a99e87e02")),
|
|
|
|
Role("Purchase Return", uuid.UUID("ab33196e-d9e4-114c-ac8c-997954363756")),
|
|
|
|
Role("Receipt", uuid.UUID("1f1ce53e-76ff-a346-974a-65db6f606e5f")),
|
|
|
|
Role("Recipes", uuid.UUID("ffb7fb65-d42c-424d-9ff1-45069e3b4a29")),
|
|
|
|
Role("Closing Stock", uuid.UUID("97515732-24e4-c94d-9585-d4bd7f6c7891")),
|
|
|
|
Role("Ledger", uuid.UUID("a2120944-243f-3f49-be57-0ad633ce4801")),
|
2020-10-07 16:59:24 +00:00
|
|
|
Role(
|
|
|
|
"Raw Material Cost", uuid.UUID("d462842b-baf1-2343-95e5-ffdba9bbc163")
|
|
|
|
),
|
2020-10-07 15:18:43 +00:00
|
|
|
Role(
|
|
|
|
"Edit Other User's Vouchers",
|
|
|
|
uuid.UUID("a8328891-7ce2-a943-8c29-2eabc1ffeea3"),
|
|
|
|
),
|
2019-04-06 04:13:12 +00:00
|
|
|
Role("Clients", uuid.UUID("cfad44f0-f2a9-7045-89d7-9019cf0f371a")),
|
2020-05-21 07:41:47 +00:00
|
|
|
Role("Employee Benefit", uuid.UUID("92d70e80-1c32-384d-959e-abf84b804696")),
|
2019-04-06 04:13:12 +00:00
|
|
|
Role("Messages", uuid.UUID("f586d128-b6d9-4090-a913-78fcbdb68e59")),
|
|
|
|
Role("Lock Date", uuid.UUID("d52de0be-9388-4b0b-a359-7e122ab6e53a")),
|
|
|
|
Role("Net Transactions", uuid.UUID("2c40f7cf-67fc-4efa-a670-8d16a2e7884d")),
|
|
|
|
Role("Balance Sheet", uuid.UUID("40deb018-b8f2-460a-88be-8972c9fcdf04")),
|
|
|
|
Role("Advanced Delete", uuid.UUID("197ebcd2-bc4a-4b65-a138-ce942ece32ea")),
|
|
|
|
Role("Rebase", uuid.UUID("de204a88-5f9d-4579-a2d6-aa2f25efde42")),
|
|
|
|
Role("Reset Stock", uuid.UUID("aecaf82f-aa41-4634-b754-0c1308b621b1")),
|
|
|
|
Role("Reconcile", uuid.UUID("a5cb51cb-e38e-4705-84a7-cc1e9a8b866b")),
|
|
|
|
Role("Stock Movement", uuid.UUID("20b707ee-2b59-41ad-be87-76d5fe1efca8")),
|
|
|
|
Role("Purchases", uuid.UUID("cf7019c8-3fd3-45b0-9a42-601029ce5b71")),
|
|
|
|
Role("Dashboard", uuid.UUID("53eecc09-bd06-4890-b6f5-6885dda762d4")),
|
2020-05-12 15:22:07 +00:00
|
|
|
Role("Incentive", uuid.UUID("99b56390-96c2-4f3d-8b0f-5ae3c868594f")),
|
2019-04-06 04:13:12 +00:00
|
|
|
Role("Maintenance", uuid.UUID("770532e4-21de-4712-8a6b-4ff9fd63a503")),
|
|
|
|
]
|
|
|
|
|
2016-12-24 11:41:01 +00:00
|
|
|
for role in roles:
|
|
|
|
dbsession.add(role)
|
|
|
|
groups[0].roles.append(role)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
|
|
|
cost_centres = [
|
2020-10-07 16:59:24 +00:00
|
|
|
CostCentre(
|
|
|
|
"Overall", uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"), True
|
|
|
|
),
|
|
|
|
CostCentre(
|
|
|
|
"Purchase", uuid.UUID("7b845f95-dfef-fa4a-897c-f0baf15284a3"), True
|
|
|
|
),
|
|
|
|
CostCentre(
|
|
|
|
"Kitchen", uuid.UUID("b2d398ce-e3cc-c542-9feb-5d7783e899df"), True
|
|
|
|
),
|
2019-04-06 04:13:12 +00:00
|
|
|
]
|
|
|
|
|
2016-12-24 11:41:01 +00:00
|
|
|
for cost_centre in cost_centres:
|
|
|
|
dbsession.add(cost_centre)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
2018-07-14 06:27:39 +00:00
|
|
|
accounts = [
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
1,
|
|
|
|
"All Purchases",
|
|
|
|
2,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("7b845f95-dfef-fa4a-897c-f0baf15284a3"),
|
|
|
|
uuid.UUID("240dd899-c413-854c-a7eb-67a29d154490"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
1,
|
|
|
|
"Local Purchase",
|
|
|
|
9,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("d2b75912-505f-2548-9093-466dfff6a0f9"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
1,
|
|
|
|
"ESI/PF - Payable",
|
|
|
|
11,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("42277912-cc18-854b-b134-9f4b00dba419"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
2,
|
|
|
|
"ESI/PF - Expense",
|
|
|
|
7,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("d2a1a286-e900-764b-a1a5-9f4b00dbb940"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
1,
|
|
|
|
"Cash in Hand",
|
|
|
|
1,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("ed2341bb-80b8-9649-90db-f9aaca183bb3"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
1,
|
|
|
|
"Staff Salary",
|
|
|
|
7,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("5c2b54d0-c174-004d-a0d5-92cdaadcefa7"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
2,
|
2020-05-12 15:22:07 +00:00
|
|
|
"Incentives",
|
2019-04-06 04:13:12 +00:00
|
|
|
11,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("b7eff754-e8ba-e047-ab06-9132c15c7640"),
|
|
|
|
True,
|
2018-07-14 06:27:39 +00:00
|
|
|
),
|
|
|
|
Account(
|
2019-04-06 04:13:12 +00:00
|
|
|
1,
|
|
|
|
"Suspense",
|
|
|
|
4,
|
|
|
|
False,
|
|
|
|
True,
|
|
|
|
False,
|
|
|
|
uuid.UUID("36f59436-522a-0746-ae94-e0f746bf6c0d"),
|
|
|
|
uuid.UUID("3854e317-6f3b-5142-ab26-9c44d4cddd08"),
|
|
|
|
True,
|
|
|
|
),
|
2018-07-14 06:27:39 +00:00
|
|
|
]
|
2019-04-06 04:13:12 +00:00
|
|
|
|
2018-07-07 11:01:44 +00:00
|
|
|
for account in accounts:
|
|
|
|
dbsession.add(account)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
2020-10-07 16:59:24 +00:00
|
|
|
product_group = ProductGroup(
|
|
|
|
"Suspense", uuid.UUID("ae59a20c-87bb-444a-8abb-915ad5e58b83"), True
|
|
|
|
)
|
2016-12-24 11:41:01 +00:00
|
|
|
dbsession.add(product_group)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
2020-10-07 16:59:24 +00:00
|
|
|
dbsession.add(
|
|
|
|
ProductGroup(
|
|
|
|
"Semi", uuid.UUID("e6bf81b9-1e9b-499f-81d5-ab5662e9d9b1"), True
|
|
|
|
)
|
|
|
|
)
|
|
|
|
dbsession.add(
|
|
|
|
ProductGroup(
|
|
|
|
"Menu Items", uuid.UUID("dad46805-f577-4e5b-8073-9b788e0173fc"), True
|
|
|
|
)
|
|
|
|
)
|
2019-04-06 04:13:12 +00:00
|
|
|
|
|
|
|
product = Product(
|
|
|
|
1,
|
|
|
|
"Suspense",
|
|
|
|
"",
|
|
|
|
1,
|
|
|
|
"",
|
|
|
|
1,
|
|
|
|
uuid.UUID("ae59a20c-87bb-444a-8abb-915ad5e58b83"),
|
|
|
|
uuid.UUID("240dd899-c413-854c-a7eb-67a29d154490"),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
False,
|
|
|
|
False,
|
|
|
|
False,
|
|
|
|
uuid.UUID("aa79a643-9ddc-4790-ac7f-a41f9efb4c15"),
|
|
|
|
True,
|
|
|
|
)
|
2016-12-24 11:41:01 +00:00
|
|
|
dbsession.add(product)
|