Merge branch 'main' of http://10.10.1.136:3000/ismail/haikal into frontend
This commit is contained in:
commit
f41aaf14f7
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,750 @@ def create_settings(pk):
|
||||
|
||||
@background
|
||||
def create_coa_accounts(pk):
|
||||
with transaction.atomic():
|
||||
instance = Dealer.objects.select_for_update().get(pk=pk)
|
||||
entity = instance.entity
|
||||
coa = entity.get_default_coa()
|
||||
|
||||
# accounts_data = [
|
||||
# # Current Assets (must start with 1)
|
||||
# {
|
||||
# 'code': '1010',
|
||||
# 'name': 'Cash on Hand',
|
||||
# 'role': roles.ASSET_CA_CASH,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': True,
|
||||
# },
|
||||
# {
|
||||
# 'code': '1020',
|
||||
# 'name': 'Bank',
|
||||
# 'role': roles.ASSET_CA_CASH,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': True,
|
||||
# },
|
||||
# {
|
||||
# 'code': '1030',
|
||||
# 'name': 'Accounts Receivable',
|
||||
# 'role': roles.ASSET_CA_RECEIVABLES,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': True
|
||||
# },
|
||||
# {
|
||||
# 'code': '1040',
|
||||
# 'name': 'Inventory (Cars)',
|
||||
# 'role': roles.ASSET_CA_INVENTORY,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': True
|
||||
# },
|
||||
# {
|
||||
# 'code': '1045',
|
||||
# 'name': 'Spare Parts Inventory',
|
||||
# 'role': roles.ASSET_CA_INVENTORY,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1050',
|
||||
# 'name': 'Employee Advances',
|
||||
# 'role': roles.ASSET_CA_RECEIVABLES,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1060',
|
||||
# 'name': 'Prepaid Expenses',
|
||||
# 'role': roles.ASSET_CA_PREPAID,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1070',
|
||||
# 'name': 'Notes Receivable',
|
||||
# 'role': roles.ASSET_LTI_NOTES_RECEIVABLE,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
|
||||
# # Fixed Assets (must also start with 1)
|
||||
# {
|
||||
# 'code': '1110',
|
||||
# 'name': 'Lands',
|
||||
# 'role': roles.ASSET_LTI_LAND,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1111',
|
||||
# 'name': 'Buildings',
|
||||
# 'role': roles.ASSET_PPE_BUILDINGS,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1112',
|
||||
# 'name': 'Company Vehicles',
|
||||
# 'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1113',
|
||||
# 'name': 'Equipment & Tools',
|
||||
# 'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1114',
|
||||
# 'name': 'Furniture & Fixtures',
|
||||
# 'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1115',
|
||||
# 'name': 'Other Fixed Assets',
|
||||
# 'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1120',
|
||||
# 'name': 'Long-term Investments',
|
||||
# 'role': roles.ASSET_LTI_SECURITIES,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '1130',
|
||||
# 'name': 'Intangible Assets',
|
||||
# 'role': roles.ASSET_INTANGIBLE_ASSETS,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
|
||||
# # Current Liabilities (must start with 2)
|
||||
# {
|
||||
# 'code': '2010',
|
||||
# 'name': 'Accounts Payable',
|
||||
# 'role': roles.LIABILITY_CL_ACC_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': True
|
||||
# },
|
||||
# {
|
||||
# 'code': '2020',
|
||||
# 'name': 'Notes Payable',
|
||||
# 'role': roles.LIABILITY_CL_ST_NOTES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2030',
|
||||
# 'name': 'Short-term Loans',
|
||||
# 'role': roles.LIABILITY_CL_ST_NOTES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2040',
|
||||
# 'name': 'Employee Payables',
|
||||
# 'role': roles.LIABILITY_CL_WAGES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2050',
|
||||
# 'name': 'Accrued Expenses',
|
||||
# 'role': roles.LIABILITY_CL_OTHER,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2060',
|
||||
# 'name': 'Accrued Taxes',
|
||||
# 'role': roles.LIABILITY_CL_TAXES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2070',
|
||||
# 'name': 'Provisions',
|
||||
# 'role': roles.LIABILITY_CL_OTHER,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
|
||||
# # Long-term Liabilities (must also start with 2)
|
||||
# {
|
||||
# 'code': '2210',
|
||||
# 'name': 'Long-term Bank Loans',
|
||||
# 'role': roles.LIABILITY_LTL_NOTES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2220',
|
||||
# 'name': 'Lease Liabilities',
|
||||
# 'role': roles.LIABILITY_LTL_NOTES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '2230',
|
||||
# 'name': 'Other Long-term Liabilities',
|
||||
# 'role': roles.LIABILITY_LTL_NOTES_PAYABLE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
|
||||
# # Equity (must start with 3)
|
||||
# {
|
||||
# 'code': '3010',
|
||||
# 'name': 'Capital',
|
||||
# 'role': roles.EQUITY_CAPITAL,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': True
|
||||
# },
|
||||
# {
|
||||
# 'code': '3020',
|
||||
# 'name': 'Statutory Reserve',
|
||||
# 'role': roles.EQUITY_ADJUSTMENT,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '3030',
|
||||
# 'name': 'Retained Earnings',
|
||||
# 'role': roles.EQUITY_ADJUSTMENT,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '3040',
|
||||
# 'name': 'Profit & Loss for the Period',
|
||||
# 'role': roles.EQUITY_ADJUSTMENT,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
|
||||
# # Revenue (must start with 4)
|
||||
# {
|
||||
# 'code': '4010',
|
||||
# 'name': 'Car Sales',
|
||||
# 'role': roles.INCOME_OPERATIONAL,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': True
|
||||
# },
|
||||
# {
|
||||
# 'code': '4020',
|
||||
# 'name': 'After-Sales Services',
|
||||
# 'role': roles.INCOME_OPERATIONAL,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '4030',
|
||||
# 'name': 'Car Rental Income',
|
||||
# 'role': roles.INCOME_PASSIVE,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '4040',
|
||||
# 'name': 'Other Income',
|
||||
# 'role': roles.INCOME_OTHER,
|
||||
# 'balance_type': roles.CREDIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
|
||||
# # Expenses (must start with 5 for COGS, 6 for others)
|
||||
# {
|
||||
# 'code': '5010',
|
||||
# 'name': 'Cost of Goods Sold',
|
||||
# 'role': roles.COGS,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': True
|
||||
# },
|
||||
# {
|
||||
# 'code': '5015',
|
||||
# 'name': 'Spare Parts Cost Consumed',
|
||||
# 'role': roles.COGS,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6010',
|
||||
# 'name': 'Salaries & Wages',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6020',
|
||||
# 'name': 'Rent',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6030',
|
||||
# 'name': 'Utilities',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6040',
|
||||
# 'name': 'Advertising & Marketing',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6050',
|
||||
# 'name': 'Maintenance',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6060',
|
||||
# 'name': 'Operating Expenses',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6070',
|
||||
# 'name': 'Depreciation',
|
||||
# 'role': roles.EXPENSE_DEPRECIATION,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6080',
|
||||
# 'name': 'Fees & Taxes',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6090',
|
||||
# 'name': 'Bank Charges',
|
||||
# 'role': roles.EXPENSE_OPERATIONAL,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# },
|
||||
# {
|
||||
# 'code': '6100',
|
||||
# 'name': 'Other Expenses',
|
||||
# 'role': roles.EXPENSE_OTHER,
|
||||
# 'balance_type': roles.DEBIT,
|
||||
# 'locked': False
|
||||
# }
|
||||
# ]
|
||||
|
||||
accounts_data = [
|
||||
# Current Assets (must start with 1)
|
||||
{
|
||||
'code': '1010',
|
||||
'name': 'Cash on Hand',
|
||||
'role': roles.ASSET_CA_CASH,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': True,
|
||||
'default': True # Default for ASSET_CA_CASH
|
||||
},
|
||||
{
|
||||
'code': '1020',
|
||||
'name': 'Bank',
|
||||
'role': roles.ASSET_CA_CASH,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': True,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '1030',
|
||||
'name': 'Accounts Receivable',
|
||||
'role': roles.ASSET_CA_RECEIVABLES,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': True,
|
||||
'default': True # Default for ASSET_CA_RECEIVABLES
|
||||
},
|
||||
{
|
||||
'code': '1040',
|
||||
'name': 'Inventory (Cars)',
|
||||
'role': roles.ASSET_CA_INVENTORY,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': True,
|
||||
'default': True # Default for ASSET_CA_INVENTORY
|
||||
},
|
||||
{
|
||||
'code': '1045',
|
||||
'name': 'Spare Parts Inventory',
|
||||
'role': roles.ASSET_CA_INVENTORY,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '1050',
|
||||
'name': 'Employee Advances',
|
||||
'role': roles.ASSET_CA_RECEIVABLES,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '1060',
|
||||
'name': 'Prepaid Expenses',
|
||||
'role': roles.ASSET_CA_PREPAID,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_CA_PREPAID
|
||||
},
|
||||
{
|
||||
'code': '1070',
|
||||
'name': 'Notes Receivable',
|
||||
'role': roles.ASSET_LTI_NOTES_RECEIVABLE,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_LTI_NOTES_RECEIVABLE
|
||||
},
|
||||
|
||||
# Fixed Assets (must also start with 1)
|
||||
{
|
||||
'code': '1110',
|
||||
'name': 'Lands',
|
||||
'role': roles.ASSET_LTI_LAND,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_LTI_LAND
|
||||
},
|
||||
{
|
||||
'code': '1111',
|
||||
'name': 'Buildings',
|
||||
'role': roles.ASSET_PPE_BUILDINGS,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_PPE_BUILDINGS
|
||||
},
|
||||
{
|
||||
'code': '1112',
|
||||
'name': 'Company Vehicles',
|
||||
'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_PPE_EQUIPMENT
|
||||
},
|
||||
{
|
||||
'code': '1113',
|
||||
'name': 'Equipment & Tools',
|
||||
'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '1114',
|
||||
'name': 'Furniture & Fixtures',
|
||||
'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '1115',
|
||||
'name': 'Other Fixed Assets',
|
||||
'role': roles.ASSET_PPE_EQUIPMENT,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '1120',
|
||||
'name': 'Long-term Investments',
|
||||
'role': roles.ASSET_LTI_SECURITIES,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_LTI_SECURITIES
|
||||
},
|
||||
{
|
||||
'code': '1130',
|
||||
'name': 'Intangible Assets',
|
||||
'role': roles.ASSET_INTANGIBLE_ASSETS,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for ASSET_INTANGIBLE_ASSETS
|
||||
},
|
||||
|
||||
# Current Liabilities (must start with 2)
|
||||
{
|
||||
'code': '2010',
|
||||
'name': 'Accounts Payable',
|
||||
'role': roles.LIABILITY_CL_ACC_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': True,
|
||||
'default': True # Default for LIABILITY_CL_ACC_PAYABLE
|
||||
},
|
||||
{
|
||||
'code': '2020',
|
||||
'name': 'Notes Payable',
|
||||
'role': roles.LIABILITY_CL_ST_NOTES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for LIABILITY_CL_ST_NOTES_PAYABLE
|
||||
},
|
||||
{
|
||||
'code': '2030',
|
||||
'name': 'Short-term Loans',
|
||||
'role': roles.LIABILITY_CL_ST_NOTES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '2040',
|
||||
'name': 'Employee Payables',
|
||||
'role': roles.LIABILITY_CL_WAGES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for LIABILITY_CL_WAGES_PAYABLE
|
||||
},
|
||||
{
|
||||
'code': '2050',
|
||||
'name': 'Accrued Expenses',
|
||||
'role': roles.LIABILITY_CL_OTHER,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for LIABILITY_CL_OTHER
|
||||
},
|
||||
{
|
||||
'code': '2060',
|
||||
'name': 'Accrued Taxes',
|
||||
'role': roles.LIABILITY_CL_TAXES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for LIABILITY_CL_TAXES_PAYABLE
|
||||
},
|
||||
{
|
||||
'code': '2070',
|
||||
'name': 'Provisions',
|
||||
'role': roles.LIABILITY_CL_OTHER,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
|
||||
# Long-term Liabilities (must also start with 2)
|
||||
{
|
||||
'code': '2210',
|
||||
'name': 'Long-term Bank Loans',
|
||||
'role': roles.LIABILITY_LTL_NOTES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for LIABILITY_LTL_NOTES_PAYABLE
|
||||
},
|
||||
{
|
||||
'code': '2220',
|
||||
'name': 'Lease Liabilities',
|
||||
'role': roles.LIABILITY_LTL_NOTES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '2230',
|
||||
'name': 'Other Long-term Liabilities',
|
||||
'role': roles.LIABILITY_LTL_NOTES_PAYABLE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
|
||||
# Equity (must start with 3)
|
||||
{
|
||||
'code': '3010',
|
||||
'name': 'Capital',
|
||||
'role': roles.EQUITY_CAPITAL,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': True,
|
||||
'default': True # Default for EQUITY_CAPITAL
|
||||
},
|
||||
{
|
||||
'code': '3020',
|
||||
'name': 'Statutory Reserve',
|
||||
'role': roles.EQUITY_ADJUSTMENT,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for EQUITY_ADJUSTMENT
|
||||
},
|
||||
{
|
||||
'code': '3030',
|
||||
'name': 'Retained Earnings',
|
||||
'role': roles.EQUITY_ADJUSTMENT,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '3040',
|
||||
'name': 'Profit & Loss for the Period',
|
||||
'role': roles.EQUITY_ADJUSTMENT,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
|
||||
# Revenue (must start with 4)
|
||||
{
|
||||
'code': '4010',
|
||||
'name': 'Car Sales',
|
||||
'role': roles.INCOME_OPERATIONAL,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': True,
|
||||
'default': True # Default for INCOME_OPERATIONAL
|
||||
},
|
||||
{
|
||||
'code': '4020',
|
||||
'name': 'After-Sales Services',
|
||||
'role': roles.INCOME_OPERATIONAL,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '4030',
|
||||
'name': 'Car Rental Income',
|
||||
'role': roles.INCOME_PASSIVE,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for INCOME_PASSIVE
|
||||
},
|
||||
{
|
||||
'code': '4040',
|
||||
'name': 'Other Income',
|
||||
'role': roles.INCOME_OTHER,
|
||||
'balance_type': roles.CREDIT,
|
||||
'locked': False,
|
||||
'default': True # Default for INCOME_OTHER
|
||||
},
|
||||
|
||||
# Expenses (must start with 5 for COGS, 6 for others)
|
||||
{
|
||||
'code': '5010',
|
||||
'name': 'Cost of Goods Sold',
|
||||
'role': roles.COGS,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': True,
|
||||
'default': True # Default for COGS
|
||||
},
|
||||
{
|
||||
'code': '5015',
|
||||
'name': 'Spare Parts Cost Consumed',
|
||||
'role': roles.COGS,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6010',
|
||||
'name': 'Salaries & Wages',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for EXPENSE_OPERATIONAL
|
||||
},
|
||||
{
|
||||
'code': '6020',
|
||||
'name': 'Rent',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6030',
|
||||
'name': 'Utilities',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6040',
|
||||
'name': 'Advertising & Marketing',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6050',
|
||||
'name': 'Maintenance',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6060',
|
||||
'name': 'Operating Expenses',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6070',
|
||||
'name': 'Depreciation',
|
||||
'role': roles.EXPENSE_DEPRECIATION,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for EXPENSE_DEPRECIATION
|
||||
},
|
||||
{
|
||||
'code': '6080',
|
||||
'name': 'Fees & Taxes',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6090',
|
||||
'name': 'Bank Charges',
|
||||
'role': roles.EXPENSE_OPERATIONAL,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': False
|
||||
},
|
||||
{
|
||||
'code': '6100',
|
||||
'name': 'Other Expenses',
|
||||
'role': roles.EXPENSE_OTHER,
|
||||
'balance_type': roles.DEBIT,
|
||||
'locked': False,
|
||||
'default': True # Default for EXPENSE_OTHER
|
||||
}
|
||||
]
|
||||
|
||||
for account_data in accounts_data:
|
||||
try:
|
||||
account = entity.create_account(
|
||||
coa_model=coa,
|
||||
code=account_data['code'],
|
||||
name=_(account_data['name']),
|
||||
role=_(account_data['role']),
|
||||
balance_type=_(account_data['balance_type']),
|
||||
active=True
|
||||
)
|
||||
account.role_default = account_data['default']
|
||||
account.save()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@background
|
||||
def create_coa_accounts1(pk):
|
||||
with transaction.atomic():
|
||||
instance = Dealer.objects.select_for_update().get(pk=pk)
|
||||
entity = instance.entity
|
||||
|
||||
@ -129,7 +129,7 @@ def period_navigation(context, base_url: str):
|
||||
def balance_sheet_statement(context, io_model, to_date=None):
|
||||
user_model = context['user']
|
||||
activity = context['request'].GET.get('activity')
|
||||
entity_slug = context['view'].kwargs.get('entity_slug')
|
||||
entity_slug = context['view'].kwargs.get('entity_slug')
|
||||
if not to_date:
|
||||
to_date = context['to_date']
|
||||
|
||||
@ -358,4 +358,9 @@ def splitlines(value):
|
||||
def currency_format(value):
|
||||
if not value:
|
||||
value = 0.00
|
||||
return number_format(value, decimal_pos=2, use_l10n=True, force_grouping=True)
|
||||
return number_format(value, decimal_pos=2, use_l10n=True, force_grouping=True)
|
||||
|
||||
|
||||
@register.filter
|
||||
def filter_by_role(accounts, role_prefix):
|
||||
return [account for account in accounts if account.role.startswith(role_prefix)]
|
||||
@ -4836,6 +4836,7 @@ class LeadDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
|
||||
lead=self.object
|
||||
)
|
||||
context["transfer_form"] = forms.LeadTransferForm()
|
||||
context["transfer_form"].fields["transfer_to"].queryset = (models.Staff.objects.filter(dealer=self.object.dealer,staff_type="sales"))
|
||||
context["activity_form"] = forms.ActivityForm()
|
||||
context["staff_task_form"] = forms.StaffTaskForm()
|
||||
context["note_form"] = forms.NoteForm()
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load i18n custom_filters %}
|
||||
{% block title %}{% trans "Accounts" %}{% endblock title %}
|
||||
{% block accounts %}
|
||||
<a class="nav-link active fw-bold">
|
||||
@ -8,120 +8,137 @@
|
||||
</a>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<!--test-->
|
||||
<div class="row mt-4">
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<h3 class=""><i class="fa-solid fa-book"></i> {% trans "Accounts" %}</h3>
|
||||
<a href="{% url 'account_create' %}" class="btn btn-md btn-phoenix-primary"><i class="fa fa-plus me-2"></i>{% trans 'New Account' %}</a>
|
||||
</div>
|
||||
{% include "partials/search_box.html" %}
|
||||
|
||||
{% if page_obj.object_list %}
|
||||
<div class="table-responsive px-1 scrollbar mt-3">
|
||||
<table class="table align-items-center table-flush">
|
||||
<thead>
|
||||
<tr class="bg-body-highlight">
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Type" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Account Name" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Code" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Balance Type" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Active" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list">
|
||||
{% for account in accounts %}
|
||||
<!-- Account Type Tabs -->
|
||||
<div class="mb-4">
|
||||
<ul class="nav nav-tabs" id="accountTypeTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="assets-tab" data-bs-toggle="tab" data-bs-target="#assets" type="button" role="tab" aria-controls="assets" aria-selected="true">
|
||||
<i class="fas fa-wallet me-2"></i>{% trans "Assets" %}
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="cogs-tab" data-bs-toggle="tab" data-bs-target="#cogs" type="button" role="tab" aria-controls="cogs" aria-selected="false">
|
||||
<i class="fas fa-boxes me-2"></i>{% trans "COGS" %}
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="capital-tab" data-bs-toggle="tab" data-bs-target="#capital" type="button" role="tab" aria-controls="capital" aria-selected="false">
|
||||
<i class="fas fa-landmark me-2"></i>{% trans "Capital" %}
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="income-tab" data-bs-toggle="tab" data-bs-target="#income" type="button" role="tab" aria-controls="income" aria-selected="false">
|
||||
<i class="fas fa-money-bill-wave me-2"></i>{% trans "Income" %}
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="expenses-tab" data-bs-toggle="tab" data-bs-target="#expenses" type="button" role="tab" aria-controls="expenses" aria-selected="false">
|
||||
<i class="fas fa-receipt me-2"></i>{% trans "Expenses" %}
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="liabilities-tab" data-bs-toggle="tab" data-bs-target="#liabilities" type="button" role="tab" aria-controls="liabilities" aria-selected="false">
|
||||
<i class="fas fa-receipt me-2"></i>{% trans "Liabilities" %}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="modal fade" id="deleteModal"
|
||||
data-bs-backdrop="static"
|
||||
data-bs-keyboard="false"
|
||||
tabindex="-1"
|
||||
aria-labelledby="deleteModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel">
|
||||
<div class="tab-content p-3 border border-top-0 rounded-bottom" id="accountTypeTabsContent">
|
||||
<!-- Assets Tab -->
|
||||
<div class="tab-pane fade show active" id="assets" role="tabpanel" aria-labelledby="assets-tab">
|
||||
{% include "partials/search_box.html" %}
|
||||
{% with accounts=accounts|filter_by_role:"ex_" %}
|
||||
{% include "ledger/coa_accounts/partials/account_table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% trans "Delete Account" %}
|
||||
<span data-feather="alert-circle"></span>
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<p class="mb-0 text-danger fw-bold">
|
||||
{% trans "Are you sure you want to delete this Account?" %}
|
||||
</p>
|
||||
<div class="d-grid gap-2">
|
||||
<button type="button" class="btn btn-phoenix-secondary btn-sm" data-bs-dismiss="modal">
|
||||
{% trans "No" %}
|
||||
</button>
|
||||
<a type="button" class="btn btn-phoenix-danger btn-sm" href="{% url 'account_delete' account.uuid %}">
|
||||
{% trans "Yes" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- COGS Tab -->
|
||||
<div class="tab-pane fade" id="cogs" role="tabpanel" aria-labelledby="cogs-tab">
|
||||
{% include "partials/search_box.html" %}
|
||||
{% with accounts=accounts|filter_by_role:"cogs" %}
|
||||
{% include "ledger/coa_accounts/partials/account_table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Capital Tab -->
|
||||
<div class="tab-pane fade" id="capital" role="tabpanel" aria-labelledby="capital-tab">
|
||||
{% include "partials/search_box.html" %}
|
||||
{% with accounts=accounts|filter_by_role:"eq_" %}
|
||||
{% include "ledger/coa_accounts/partials/account_table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{{ account.role_bs|upper }}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{{ account.name }}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{{ account.code }}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
<!-- Income Tab -->
|
||||
<div class="tab-pane fade" id="income" role="tabpanel" aria-labelledby="income-tab">
|
||||
{% include "partials/search_box.html" %}
|
||||
{% with accounts=accounts|filter_by_role:"in_" %}
|
||||
{% include "ledger/coa_accounts/partials/account_table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% if account.balance_type == 'debit' %}
|
||||
<div class="badge badge-phoenix fs-10 badge-phoenix-success"><span class="fw-bold"><i class="fa-solid fa-circle-up"></i> {{ _("Debit") }}</span></div>
|
||||
{% else %}
|
||||
<div class="badge badge-phoenix fs-10 badge-phoenix-danger"><span class="fw-bold"><i class="fa-solid fa-circle-down"></i> {{ _("Credit") }}</span></div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{% if account.active %}
|
||||
<span class="fw-bold text-success fas fa-check-circle"></span>
|
||||
{% else %}
|
||||
<span class="fw-bold text-danger far fa-times-circle"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap text-start">
|
||||
<div class="btn-reveal-trigger position-static">
|
||||
<button class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10" type="button" data-bs-toggle="dropdown" data-boundary="window" aria-haspopup="true" aria-expanded="false" data-bs-reference="parent"><span class="fas fa-ellipsis-h fs-10"></span></button>
|
||||
<div class="dropdown-menu dropdown-menu-end py-2"><a href="{% url 'account_detail' account.uuid %}" class="dropdown-item text-success-dark">
|
||||
{% trans "View" %}
|
||||
</a>
|
||||
<div class="dropdown-divider"></div><button class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">{% trans "Delete" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted">{% trans "No Accounts Found" %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- Expenses Tab -->
|
||||
<div class="tab-pane fade" id="expenses" role="tabpanel" aria-labelledby="expenses-tab">
|
||||
{% include "partials/search_box.html" %}
|
||||
{% with accounts=accounts|filter_by_role:"ex_" %}
|
||||
{% include "ledger/coa_accounts/partials/account_table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
<!-- Liabilities Tab -->
|
||||
<div class="tab-pane fade" id="liabilities" role="tabpanel" aria-labelledby="liabilities-tab">
|
||||
{% include "partials/search_box.html" %}
|
||||
{% with accounts=accounts|filter_by_role:"lia_" %}
|
||||
{% include "ledger/coa_accounts/partials/account_table.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<div class="d-flex">
|
||||
{% if is_paginated %}
|
||||
{% include 'partials/pagination.html' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<!--test-->
|
||||
|
||||
<!-- Delete Modal (moved outside tables) -->
|
||||
<div class="modal fade" id="deleteModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel">
|
||||
{% trans "Delete Account" %}
|
||||
<span data-feather="alert-circle"></span>
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<p class="mb-0 text-danger fw-bold">
|
||||
{% trans "Are you sure you want to delete this Account?" %}
|
||||
</p>
|
||||
<div class="d-grid gap-2">
|
||||
<button type="button" class="btn btn-phoenix-secondary btn-sm" data-bs-dismiss="modal">
|
||||
{% trans "No" %}
|
||||
</button>
|
||||
<a id="deleteAccountBtn" type="button" class="btn btn-phoenix-danger btn-sm" href="#">
|
||||
{% trans "Yes" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block customerJS %}
|
||||
<script>
|
||||
// Handle delete modal for all tables
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var deleteModal = document.getElementById('deleteModal');
|
||||
deleteModal.addEventListener('show.bs.modal', function(event) {
|
||||
var button = event.relatedTarget;
|
||||
var accountId = button.closest('tr').getAttribute('data-account-id');
|
||||
document.getElementById('deleteAccountBtn').href = `/accounts/delete/${accountId}/`;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
69
templates/ledger/coa_accounts/partials/account_table.html
Normal file
69
templates/ledger/coa_accounts/partials/account_table.html
Normal file
@ -0,0 +1,69 @@
|
||||
{% load i18n %}
|
||||
{% if accounts %}
|
||||
<div class="table-responsive px-1 scrollbar mt-3">
|
||||
<table class="table align-items-center table-flush">
|
||||
<thead>
|
||||
<tr class="bg-body-highlight">
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Account Name" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Code" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Balance Type" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col">{% trans "Active" %}</th>
|
||||
<th class="sort white-space-nowrap align-middle" scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list">
|
||||
{% for account in accounts %}
|
||||
<tr class="hover-actions-trigger btn-reveal-trigger position-static" data-account-id="{{ account.uuid }}">
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{{ account.name }}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{{ account.code }}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{% if account.balance_type == 'debit' %}
|
||||
<div class="badge badge-phoenix fs-10 badge-phoenix-success"><span class="fw-bold"><i class="fa-solid fa-circle-up"></i> {{ _("Debit") }}</span></div>
|
||||
{% else %}
|
||||
<div class="badge badge-phoenix fs-10 badge-phoenix-danger"><span class="fw-bold"><i class="fa-solid fa-circle-down"></i> {{ _("Credit") }}</span></div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="align-middle product white-space-nowrap">
|
||||
{% if account.active %}
|
||||
<span class="fw-bold text-success fas fa-check-circle"></span>
|
||||
{% else %}
|
||||
<span class="fw-bold text-danger far fa-times-circle"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap text-start">
|
||||
<div class="btn-reveal-trigger position-static">
|
||||
<button class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10" type="button" data-bs-toggle="dropdown" data-boundary="window" aria-haspopup="true" aria-expanded="false" data-bs-reference="parent"><span class="fas fa-ellipsis-h fs-10"></span></button>
|
||||
<div class="dropdown-menu dropdown-menu-end py-2">
|
||||
<a href="{% url 'account_detail' account.uuid %}" class="dropdown-item text-success-dark">
|
||||
{% trans "View" %}
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<button class="dropdown-item text-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">{% trans "Delete" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted">{% trans "No Accounts Found" %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<div class="d-flex">
|
||||
{% if is_paginated %}
|
||||
{% include 'partials/pagination.html' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert ">
|
||||
{% trans "No accounts found in this category." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
Loading…
x
Reference in New Issue
Block a user