-- =============================================================================
-- SoftShore Billing v2.0 - cPanel Production MySQL 8 / MariaDB Complete Dump
-- Pre-configured with 1 Company ("Demo Company"), Super Admin, 7 Demo Users,
-- 33 COA Accounts, 5 Customers, 5 Products, Subscriptions, Invoices & GL
-- Generated At: 2026-10-05T15:13:24.371Z
-- =============================================================================

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- =============================================================================
-- SoftShore Billing v2.0 - Complete MySQL 8 Database Schema
-- Multi-Tenant SaaS Billing, Integrated CRM & Full-Phase Double-Entry Accounting
-- Prepared for: SoftShore Technology
-- =============================================================================

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- 1. Subscription Plans (Platform Level)
CREATE TABLE IF NOT EXISTS plans (
    id VARCHAR(50) PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    price_monthly DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    price_yearly DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    currency VARCHAR(10) NOT NULL DEFAULT 'BDT',
    max_users INT NOT NULL DEFAULT 5,
    max_branches INT NOT NULL DEFAULT 1,
    max_invoices_month INT NOT NULL DEFAULT 500,
    features JSON NOT NULL,
    status ENUM('active', 'inactive') DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 2. Tenants (Subscribing Companies)
CREATE TABLE IF NOT EXISTS tenants (
    id VARCHAR(50) PRIMARY KEY,
    name VARCHAR(150) NOT NULL,
    subdomain VARCHAR(100) NOT NULL UNIQUE,
    custom_domain VARCHAR(150) NULL,
    plan_id VARCHAR(50) NOT NULL,
    status ENUM('active', 'trial', 'suspended', 'cancelled') DEFAULT 'active',
    currency VARCHAR(10) NOT NULL DEFAULT 'BDT',
    timezone VARCHAR(64) NOT NULL DEFAULT 'Asia/Dhaka',
    tax_id VARCHAR(80) NULL,
    vat_rate DECIMAL(5, 2) NOT NULL DEFAULT 15.00,
    email VARCHAR(150) NULL,
    phone VARCHAR(50) NULL,
    address TEXT NULL,
    logo_url VARCHAR(255) NULL,
    onboarding_completed BOOLEAN DEFAULT FALSE,
    settings JSON NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_tenant_subdomain (subdomain),
    INDEX idx_tenant_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 3. Branches / Cost Centers
CREATE TABLE IF NOT EXISTS branches (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    code VARCHAR(30) NOT NULL,
    name VARCHAR(150) NOT NULL,
    address TEXT NULL,
    phone VARCHAR(50) NULL,
    manager_id VARCHAR(50) NULL,
    is_main BOOLEAN DEFAULT FALSE,
    status ENUM('active', 'inactive') DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_branch_tenant (tenant_id),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 4. Roles (RBAC)
CREATE TABLE IF NOT EXISTS roles (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NULL,
    name VARCHAR(80) NOT NULL,
    scope ENUM('platform', 'tenant', 'branch', 'self') NOT NULL DEFAULT 'tenant',
    permissions JSON NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_role_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 5. Users
CREATE TABLE IF NOT EXISTS users (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NULL,
    branch_id VARCHAR(50) NULL,
    role_id VARCHAR(50) NOT NULL,
    role_name VARCHAR(80) NOT NULL,
    name VARCHAR(150) NOT NULL,
    email VARCHAR(150) NOT NULL,
    password_hash VARCHAR(255) NOT NULL,
    two_factor_enabled BOOLEAN DEFAULT FALSE,
    status ENUM('active', 'invited', 'suspended') DEFAULT 'active',
    last_login_at TIMESTAMP NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_user_tenant_email (tenant_id, email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 6. Customers
CREATE TABLE IF NOT EXISTS customers (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    code VARCHAR(40) NOT NULL,
    name VARCHAR(150) NOT NULL,
    company VARCHAR(150) NULL,
    email VARCHAR(150) NOT NULL,
    phone VARCHAR(50) NOT NULL,
    address TEXT NULL,
    tax_id VARCHAR(80) NULL,
    tags JSON NULL,
    credit_limit DECIMAL(15, 2) DEFAULT 100000.00,
    advance_balance DECIMAL(15, 2) DEFAULT 0.00,
    payment_score INT DEFAULT 90,
    status ENUM('active', 'inactive', 'overdue_hold') DEFAULT 'active',
    notes TEXT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_customer_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 7. CRM Leads & Pipeline
CREATE TABLE IF NOT EXISTS leads (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    name VARCHAR(150) NOT NULL,
    company VARCHAR(150) NULL,
    email VARCHAR(150) NULL,
    phone VARCHAR(50) NULL,
    source VARCHAR(80) DEFAULT 'Website',
    stage ENUM('New', 'Contacted', 'Qualified', 'Won', 'Lost') DEFAULT 'New',
    estimated_value DECIMAL(15, 2) DEFAULT 0.00,
    probability INT DEFAULT 25,
    assigned_to VARCHAR(100) NULL,
    interested_product_id VARCHAR(50) NULL,
    notes TEXT NULL,
    converted_customer_id VARCHAR(50) NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_lead_tenant_stage (tenant_id, stage)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 8. CRM Interactions & Executive Tasks
CREATE TABLE IF NOT EXISTS crm_activities (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    entity_type ENUM('lead', 'customer') NOT NULL,
    entity_id VARCHAR(50) NOT NULL,
    activity_type ENUM('call', 'email', 'meeting', 'note', 'task') NOT NULL,
    subject VARCHAR(200) NOT NULL,
    details TEXT NULL,
    due_date DATE NULL,
    is_completed BOOLEAN DEFAULT FALSE,
    assigned_to VARCHAR(100) NULL,
    created_by VARCHAR(100) NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_crm_tenant (tenant_id, entity_type, entity_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 9. Chart of Accounts (COA - Auto-Seeded per Tenant)
CREATE TABLE IF NOT EXISTS accounts (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    code VARCHAR(20) NOT NULL,
    name VARCHAR(150) NOT NULL,
    type ENUM('asset', 'liability', 'equity', 'revenue', 'expense') NOT NULL,
    subtype VARCHAR(80) NULL,
    parent_id VARCHAR(50) NULL,
    is_system BOOLEAN DEFAULT FALSE,
    control_key VARCHAR(50) NULL,
    opening_debit DECIMAL(15, 2) DEFAULT 0.00,
    opening_credit DECIMAL(15, 2) DEFAULT 0.00,
    status ENUM('active', 'archived') DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY uq_tenant_account_code (tenant_id, code),
    INDEX idx_account_tenant_type (tenant_id, type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 10. Products & Services
CREATE TABLE IF NOT EXISTS products (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    type ENUM('product', 'service') NOT NULL DEFAULT 'service',
    sku VARCHAR(60) NOT NULL,
    name VARCHAR(150) NOT NULL,
    category VARCHAR(100) NULL,
    description TEXT NULL,
    price DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    cost DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    tax_rate DECIMAL(5, 2) NOT NULL DEFAULT 15.00,
    unit VARCHAR(30) DEFAULT 'unit',
    track_inventory BOOLEAN DEFAULT FALSE,
    stock_qty INT DEFAULT 0,
    low_stock_alert INT DEFAULT 5,
    revenue_account_code VARCHAR(20) DEFAULT '4100',
    cogs_account_code VARCHAR(20) DEFAULT '5000',
    status ENUM('active', 'inactive') DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_product_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 11. Subscriptions & Recurring Billing Cycles
CREATE TABLE IF NOT EXISTS subscriptions (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    customer_id VARCHAR(50) NOT NULL,
    product_id VARCHAR(50) NOT NULL,
    plan_name VARCHAR(150) NOT NULL,
    cycle ENUM('one_time', 'bi_weekly', 'monthly', 'quarterly', 'half_yearly', 'yearly', 'custom') NOT NULL DEFAULT 'monthly',
    custom_days INT NULL,
    start_date DATE NOT NULL,
    next_invoice_date DATE NOT NULL,
    qty DECIMAL(10, 2) NOT NULL DEFAULT 1.00,
    unit_price DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    discount_type ENUM('percent', 'fixed') DEFAULT 'percent',
    discount_value DECIMAL(15, 2) DEFAULT 0.00,
    tax_rate DECIMAL(5, 2) DEFAULT 15.00,
    auto_renew BOOLEAN DEFAULT TRUE,
    is_deferred_revenue BOOLEAN DEFAULT FALSE,
    deferred_months INT DEFAULT 1,
    status ENUM('active', 'paused', 'cancelled', 'expired') DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_sub_tenant_next (tenant_id, status, next_invoice_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 12. Quotations / Estimates (Value-Add Module)
CREATE TABLE IF NOT EXISTS quotations (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    customer_id VARCHAR(50) NOT NULL,
    lead_id VARCHAR(50) NULL,
    quote_number VARCHAR(50) NOT NULL,
    issue_date DATE NOT NULL,
    expiry_date DATE NOT NULL,
    currency VARCHAR(10) DEFAULT 'BDT',
    items JSON NOT NULL,
    subtotal DECIMAL(15, 2) NOT NULL,
    discount DECIMAL(15, 2) DEFAULT 0.00,
    tax DECIMAL(15, 2) DEFAULT 0.00,
    total DECIMAL(15, 2) NOT NULL,
    status ENUM('Draft', 'Sent', 'Accepted', 'Converted', 'Declined') DEFAULT 'Sent',
    converted_invoice_id VARCHAR(50) NULL,
    notes TEXT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_quote_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 13. Invoices & Multi-Line Items
CREATE TABLE IF NOT EXISTS invoices (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    customer_id VARCHAR(50) NOT NULL,
    subscription_id VARCHAR(50) NULL,
    number VARCHAR(60) NOT NULL,
    date DATE NOT NULL,
    due_date DATE NOT NULL,
    status ENUM('Draft', 'Sent', 'Partially Paid', 'Paid', 'Overdue', 'Cancelled', 'Void') DEFAULT 'Sent',
    currency VARCHAR(10) DEFAULT 'BDT',
    exchange_rate DECIMAL(12, 4) DEFAULT 1.0000,
    subtotal DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    discount DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    tax DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    rounding_adjustment DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
    total DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    paid_amount DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
     credited_amount DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    notes TEXT NULL,
    terms TEXT NULL,
    je_id VARCHAR(50) NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_invoice_tenant_status (tenant_id, status, due_date),
    INDEX idx_invoice_customer (tenant_id, customer_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS invoice_items (
    id VARCHAR(50) PRIMARY KEY,
    invoice_id VARCHAR(50) NOT NULL,
    product_id VARCHAR(50) NULL,
    description VARCHAR(255) NOT NULL,
    qty DECIMAL(10, 2) NOT NULL DEFAULT 1.00,
    unit_price DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    discount DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    tax_rate DECIMAL(5, 2) NOT NULL DEFAULT 15.00,
    tax_amount DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    total DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    account_code VARCHAR(20) DEFAULT '4100',
    FOREIGN KEY (invoice_id) REFERENCES invoices(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 14. Payments
CREATE TABLE IF NOT EXISTS payments (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    invoice_id VARCHAR(50) NULL,
    customer_id VARCHAR(50) NOT NULL,
    receipt_number VARCHAR(60) NOT NULL,
    amount DECIMAL(15, 2) NOT NULL,
    bank_charge DECIMAL(15, 2) DEFAULT 0.00,
    method ENUM('Cash', 'Bank Transfer', 'Card', 'bKash', 'Nagad', 'SSLCommerz', 'Stripe', 'PayPal', 'Advance Wallet') NOT NULL DEFAULT 'Bank Transfer',
    deposit_account_code VARCHAR(20) DEFAULT '1010',
    reference VARCHAR(100) NULL,
    is_advance BOOLEAN DEFAULT FALSE,
    paid_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    status ENUM('Completed', 'Refunded', 'Pending') DEFAULT 'Completed',
    je_id VARCHAR(50) NULL,
    INDEX idx_payment_tenant (tenant_id, paid_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 15. Credit Notes & Refunds
CREATE TABLE IF NOT EXISTS credit_notes (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    invoice_id VARCHAR(50) NOT NULL,
    customer_id VARCHAR(50) NOT NULL,
    cn_number VARCHAR(60) NOT NULL,
    date DATE NOT NULL,
    amount DECIMAL(15, 2) NOT NULL,
    tax_reversal DECIMAL(15, 2) DEFAULT 0.00,
    reason VARCHAR(255) NOT NULL,
    refund_mode ENUM('ar_adjustment', 'cash_refund', 'wallet_credit') DEFAULT 'ar_adjustment',
    status ENUM('Issued', 'Applied', 'Refunded') DEFAULT 'Applied',
    je_id VARCHAR(50) NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_cn_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 16. Vendors & Bills / Expenses (AP & Expenditure Module)
CREATE TABLE IF NOT EXISTS vendors (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    name VARCHAR(150) NOT NULL,
    email VARCHAR(150) NULL,
    phone VARCHAR(50) NULL,
    tax_id VARCHAR(80) NULL,
    category VARCHAR(80) DEFAULT 'Supplier',
    balance_payable DECIMAL(15, 2) DEFAULT 0.00,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_vendor_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS expenses_bills (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    vendor_id VARCHAR(50) NULL,
    voucher_number VARCHAR(60) NOT NULL,
    category ENUM('expense', 'inventory_purchase', 'payroll', 'vat_remittance', 'depreciation') DEFAULT 'expense',
    expense_account_code VARCHAR(20) NOT NULL,
    payment_account_code VARCHAR(20) NOT NULL,
    date DATE NOT NULL,
    due_date DATE NULL,
    amount DECIMAL(15, 2) NOT NULL,
    tax_amount DECIMAL(15, 2) DEFAULT 0.00,
    paid_amount DECIMAL(15, 2) DEFAULT 0.00,
    status ENUM('Paid', 'Unpaid', 'Partially Paid') DEFAULT 'Paid',
    description VARCHAR(255) NOT NULL,
    je_id VARCHAR(50) NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_exp_tenant (tenant_id, date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 17. Fixed Assets Register (Automated Depreciation)
CREATE TABLE IF NOT EXISTS fixed_assets (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    asset_code VARCHAR(40) NOT NULL,
    name VARCHAR(150) NOT NULL,
    purchase_date DATE NOT NULL,
    purchase_cost DECIMAL(15, 2) NOT NULL,
    salvage_value DECIMAL(15, 2) DEFAULT 0.00,
    useful_life_months INT NOT NULL DEFAULT 60,
    accumulated_depreciation DECIMAL(15, 2) DEFAULT 0.00,
    last_depreciation_date DATE NULL,
    status ENUM('Active', 'Fully Depreciated', 'Disposed') DEFAULT 'Active',
    INDEX idx_asset_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 18. Fiscal Years & Monthly Accounting Periods
CREATE TABLE IF NOT EXISTS fiscal_years (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    name VARCHAR(80) NOT NULL,
    start_date DATE NOT NULL,
    end_date DATE NOT NULL,
    status ENUM('open', 'closed') DEFAULT 'open',
    closed_at TIMESTAMP NULL,
    INDEX idx_fy_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS accounting_periods (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    fiscal_year_id VARCHAR(50) NOT NULL,
    month INT NOT NULL,
    year INT NOT NULL,
    name VARCHAR(40) NOT NULL,
    status ENUM('open', 'locked', 'closed') DEFAULT 'open',
    unlock_audit_note TEXT NULL,
    INDEX idx_period_tenant (tenant_id, year, month)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 19. Journal Entries (Double-Entry Header & Lines)
CREATE TABLE IF NOT EXISTS journal_entries (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    branch_id VARCHAR(50) NULL,
    je_number VARCHAR(60) NOT NULL,
    date DATE NOT NULL,
    narration VARCHAR(255) NOT NULL,
    source_module VARCHAR(60) NOT NULL DEFAULT 'Manual',
    event_type VARCHAR(80) NULL,
    reference_id VARCHAR(60) NULL,
    status ENUM('Draft', 'Queued', 'Approved', 'Posted', 'Reversed') DEFAULT 'Posted',
    reversal_of_je_id VARCHAR(50) NULL,
    reversed_by_je_id VARCHAR(50) NULL,
    total_debit DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    total_credit DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    created_by VARCHAR(100) NOT NULL,
    approved_by VARCHAR(100) NULL,
    posted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_je_tenant_date (tenant_id, date, status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS journal_lines (
    id VARCHAR(50) PRIMARY KEY,
    je_id VARCHAR(50) NOT NULL,
    tenant_id VARCHAR(50) NOT NULL,
    account_id VARCHAR(50) NOT NULL,
    account_code VARCHAR(20) NOT NULL,
    account_name VARCHAR(150) NOT NULL,
    debit DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    credit DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    branch_id VARCHAR(50) NULL,
    customer_id VARCHAR(50) NULL,
    vendor_id VARCHAR(50) NULL,
    tax_code VARCHAR(30) NULL,
    memo VARCHAR(255) NULL,
    FOREIGN KEY (je_id) REFERENCES journal_entries(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 20. General Ledger Entries (Immutable Posted Ledger Lines)
CREATE TABLE IF NOT EXISTS ledger_entries (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    account_id VARCHAR(50) NOT NULL,
    account_code VARCHAR(20) NOT NULL,
    je_id VARCHAR(50) NOT NULL,
    je_number VARCHAR(60) NOT NULL,
    line_id VARCHAR(50) NOT NULL,
    date DATE NOT NULL,
    narration VARCHAR(255) NOT NULL,
    debit DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    credit DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    balance_after DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
    branch_id VARCHAR(50) NULL,
    customer_id VARCHAR(50) NULL,
    posted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_gl_tenant_account (tenant_id, account_code, date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 21. Notification Templates & Delivery Logs
CREATE TABLE IF NOT EXISTS notification_templates (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    event VARCHAR(80) NOT NULL,
    label VARCHAR(120) NOT NULL,
    channel ENUM('email', 'sms', 'both', 'in_app') DEFAULT 'both',
    days_offset INT DEFAULT 0,
    email_subject VARCHAR(200) NULL,
    email_body TEXT NULL,
    sms_body TEXT NULL,
    is_enabled BOOLEAN DEFAULT TRUE,
    INDEX idx_nt_tenant (tenant_id, event)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS notification_logs (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NOT NULL,
    channel ENUM('email', 'sms', 'in_app') NOT NULL,
    recipient VARCHAR(150) NOT NULL,
    customer_name VARCHAR(150) NULL,
    event VARCHAR(80) NOT NULL,
    subject VARCHAR(200) NULL,
    message TEXT NOT NULL,
    gateway_response VARCHAR(255) NULL,
    status ENUM('sent', 'delivered', 'queued_dnd', 'failed') DEFAULT 'sent',
    retry_count INT DEFAULT 0,
    sent_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_nl_tenant (tenant_id, sent_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 22. Immutable Audit Logs
CREATE TABLE IF NOT EXISTS audit_logs (
    id VARCHAR(50) PRIMARY KEY,
    tenant_id VARCHAR(50) NULL,
    user_id VARCHAR(50) NULL,
    user_name VARCHAR(120) NOT NULL,
    user_role VARCHAR(80) NOT NULL,
    action VARCHAR(100) NOT NULL,
    entity VARCHAR(80) NOT NULL,
    entity_id VARCHAR(80) NULL,
    summary VARCHAR(255) NOT NULL,
    before_state JSON NULL,
    after_state JSON NULL,
    ip_address VARCHAR(45) DEFAULT '127.0.0.1',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_audit_tenant (tenant_id, created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SET FOREIGN_KEY_CHECKS = 1;


-- Operational State Store Table for Instant Full-Graph Hydration
CREATE TABLE IF NOT EXISTS app_state_store (
    id VARCHAR(50) PRIMARY KEY,
    state_json LONGTEXT NOT NULL,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 1. Seed Subscription Plans
INSERT INTO plans (id, name, price_monthly, price_yearly, currency, max_users, max_branches, max_invoices_month, features, status) VALUES ('plan_trial', 'Starter Trial (14 Days)', 0, 0, 'BDT', 3, 1, 50, '["Auto-Seeded COA & GL","CRM Pipeline","Multi-line Invoicing","Email Notifications"]', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO plans (id, name, price_monthly, price_yearly, currency, max_users, max_branches, max_invoices_month, features, status) VALUES ('plan_basic', 'Basic Growth', 2500, 25000, 'BDT', 10, 2, 1000, '["Auto-Seeded COA & GL","CRM & Lead Conversion","Recurring Subscriptions","BGTel SMS + SMTP Alerts","6 Core Reports"]', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO plans (id, name, price_monthly, price_yearly, currency, max_users, max_branches, max_invoices_month, features, status) VALUES ('plan_pro', 'Business Pro', 6500, 65000, 'BDT', 35, 10, 10000, '["Full Double-Entry GL Engine","All 12 Financial Reports","Multi-Branch Cost Centers","bKash / SSLCommerz / Stripe","AI Cash-Flow Predictor","Fixed Assets & Depreciation"]', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO plans (id, name, price_monthly, price_yearly, currency, max_users, max_branches, max_invoices_month, features, status) VALUES ('plan_enterprise', 'Enterprise Unlimited', 15000, 150000, 'BDT', 999, 100, 500000, '["Unlimited Multi-Branch & Users","Custom Domain Mapping","Maker-Checker GL Posting Queue","Dedicated SLA & Audit Exports","Multi-Currency FX Engine","Full REST API + Webhooks"]', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name);

-- 2. Seed Single Company: Demo Company (ten_softshore)
INSERT INTO tenants (id, name, subdomain, custom_domain, plan_id, status, currency, timezone, tax_id, vat_rate, email, phone, address, onboarding_completed, settings, created_at) VALUES ('ten_softshore', 'Demo Company', 'demo', 'billing.softshore.tech', 'plan_enterprise', 'active', 'BDT', 'Asia/Dhaka', 'BIN-004928172-0101', 15, 'info@softshore.tech', '+8801710328545', 'House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh', 1, '{"notification_types":["email","sms"],"invoice_prefix":"INV-SS","quote_prefix":"QT-SS","brand_color":"#156a83","smtp_host":"mail.softshore.tech","smtp_port":587,"smtp_from":"no-reply@softshore.tech","sms_gateway_url":"https://apipro.bgtelsms.com/onetomany","sms_acode":"30000075","sms_api_key":"00694cc4892224ee3eefffed2330becadcb8cade","sms_sender_id":"KidLand","gateways":{"bkash":{"enabled":true,"merchant_no":"01710328545"},"sslcommerz":{"enabled":true,"store_id":"softshore_live"},"stripe":{"enabled":true,"pub_key":"pk_live_softshore"},"paypal":{"enabled":false}},"dnd_enabled":false,"dnd_start_hour":22,"dnd_end_hour":7,"require_gl_queue_approval":false,"reminder_days_before":[7,3,1],"overdue_days_after":[1,3,7],"invoice_template":{"layout_style":"softshore_official","document_title":"INVOICE","company_display_name":"Demo Company","logo_url":"","show_logo":true,"header_address":"House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh","header_email":"info@softshore.tech","header_website":"www.softshore.tech","header_phone":"+880 1710328545","primary_color":"#156a83","secondary_bg_color":"#dbf1f8","border_accent_color":"#219fc4","bill_to_heading":"BILL TO:","table_column_mode":"description_amount","col_description_label":"DESCRIPTION","col_amount_label":"AMOUNT","min_table_rows":6,"show_previous_due":true,"previous_due_label":"PREVIOUS DUE","total_label":"TOTAL","show_discount_row":true,"discount_label":"DISCOUNT","show_vat_row":false,"vat_label":"VAT / TAX","total_pay_label":"TOTAL PAY AMOUNT","note_heading":"Note:","notes_list":["All the amounts are in Bangladeshi Taka","The amount is VAT & Tax Included"],"show_payment_to":true,"payment_to_heading":"Payment To","bank_account_name":"Softshore Technology","bank_account_no":"2052820500001","bank_name":"BRAC Bank Limited","bank_branch":"Gulshan Branch, Dhaka","bank_swift_code":"BRAKBDDH","payment_mode_note":"Suitable transaction mode could be possible.","show_prepared_by":true,"prepared_by_heading":"Prepared By","prepared_by_name":"Zulfiker Ahmed","prepared_by_designation":"Manager, Account Operations","prepared_by_company":"SoftShore Technology","prepared_by_email":"zulfiker@softshore.tech","prepared_by_website":"www.softshore.tech","footer_disclaimer":"This is a computer-generated invoice and doesn\'t require any signature","footer_underline":true}}', '2026-01-10 08:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name), subdomain=VALUES(subdomain), settings=VALUES(settings);

-- 3. Seed Branches / Cost Centers for Demo Company
INSERT INTO branches (id, tenant_id, code, name, address, phone, manager_id, is_main, status, created_at) VALUES ('br_ten_softshore_hq', 'ten_softshore', 'HQ-01', 'Demo Company - Head Office', 'House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh', '+8801710328545', 'Company Admin', 1, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO branches (id, tenant_id, code, name, address, phone, manager_id, is_main, status, created_at) VALUES ('br_ten_softshore_ctg', 'ten_softshore', 'CTG-02', 'Chattogram Regional Branch', 'WTC Tower, Agrabad C/A, Chattogram', '+8801711998877', 'Nusrat Jahan', 0, 'active', '2026-01-15 09:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO branches (id, tenant_id, code, name, address, phone, manager_id, is_main, status, created_at) VALUES ('br_ten_softshore_syl', 'ten_softshore', 'SYL-03', 'Sylhet Tech Park Hub', 'Zindabazar Commercial Center, Sylhet', '+8801711554433', 'Rafiq Hasan', 0, 'active', '2026-02-01 09:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);

-- 4. Seed RBAC Roles
INSERT INTO roles (id, tenant_id, name, scope, permissions) VALUES ('role_super_admin', NULL, 'Super Admin', 'platform', '["platform.all","tenants.manage","plans.manage","coa_template.manage","cron.run"]') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO roles (id, tenant_id, name, scope, permissions) VALUES ('role_company_admin', 'ten_softshore', 'Company Admin', 'tenant', '["tenant.all","users.manage","branches.manage","coa.manage","invoices.all","payments.all","crm.all","reports.all","settings.manage"]') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO roles (id, tenant_id, name, scope, permissions) VALUES ('role_company_manager', 'ten_softshore', 'Company Manager', 'branch', '["branches.view","invoices.all","subscriptions.all","customers.all","crm.all","reports.operational"]') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO roles (id, tenant_id, name, scope, permissions) VALUES ('role_company_executive', 'ten_softshore', 'Company Executive', 'branch', '["invoices.create","payments.record","customers.assigned","crm.pipeline","tasks.manage"]') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO roles (id, tenant_id, name, scope, permissions) VALUES ('role_accountant', 'ten_softshore', 'Accountant', 'tenant', '["accounting.all","journal.create","journal.approve","reconciliation.manage","periods.close","reports.financial"]') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO roles (id, tenant_id, name, scope, permissions) VALUES ('role_customer', 'ten_softshore', 'Customer', 'self', '["portal.view_invoices","portal.pay_online","portal.download_receipts","portal.statement"]') ON DUPLICATE KEY UPDATE name=VALUES(name);

-- 5. Seed Super Admin & Demo Company Users
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_super', 'ten_softshore', NULL, 'role_super_admin', 'Super Admin', 'Kayser Ahmed (Super Admin)', 'superadmin@softshore.tech', 'admin123', 1, 'active', '2026-10-04 16:45:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_admin', 'ten_softshore', 'br_ten_softshore_hq', 'role_company_admin', 'Company Admin', 'Tanvir Rahman (Company Admin)', 'admin@democompany.com', 'demo123', 1, 'active', '2026-10-04 17:00:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_manager', 'ten_softshore', 'br_ten_softshore_hq', 'role_company_manager', 'Company Manager', 'Nusrat Jahan (Branch Manager)', 'manager@democompany.com', 'demo123', 0, 'active', '2026-10-04 15:20:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_accountant', 'ten_softshore', 'br_ten_softshore_hq', 'role_accountant', 'Accountant', 'Farhana Akter FCA (Chief Accountant)', 'accountant@democompany.com', 'demo123', 1, 'active', '2026-10-04 16:50:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_exec', 'ten_softshore', 'br_ten_softshore_ctg', 'role_company_executive', 'Company Executive', 'Rafiq Hasan (Sales Executive)', 'executive@democompany.com', 'demo123', 0, 'active', '2026-10-04 14:10:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_cs_exec', 'ten_softshore', 'br_ten_softshore_hq', 'role_company_executive', 'Company Executive', 'Sadia Islam (Customer Success Lead)', 'sadia@democompany.com', 'demo123', 0, 'active', '2026-10-04 15:10:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_support_eng', 'ten_softshore', 'br_ten_softshore_syl', 'role_company_executive', 'Company Executive', 'Kamrul Hasan (Cloud Support Engineer)', 'kamrul@democompany.com', 'demo123', 0, 'active', '2026-10-04 13:40:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);
INSERT INTO users (id, tenant_id, branch_id, role_id, role_name, name, email, password_hash, two_factor_enabled, status, last_login_at) VALUES ('usr_customer', 'ten_softshore', 'br_ten_softshore_hq', 'role_customer', 'Customer', 'Mehedi Alam (Square Pharma IT)', 'customer@democompany.com', 'demo123', 0, 'active', '2026-10-04 12:00:00') ON DUPLICATE KEY UPDATE email=VALUES(email), password_hash=VALUES(password_hash), name=VALUES(name);

-- 6. Seed Chart of Accounts (COA) for Demo Company
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1000', 'ten_softshore', '1000', 'Cash on Hand', 'asset', 'cash', 1, 'CASH', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1010', 'ten_softshore', '1010', 'Cash at Bank', 'asset', 'bank', 1, 'BANK', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1020', 'ten_softshore', '1020', 'Mobile Wallet (bKash/Nagad)', 'asset', 'wallet', 1, 'WALLET', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1100', 'ten_softshore', '1100', 'Accounts Receivable (AR)', 'asset', 'receivable', 1, 'AR_CONTROL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1105', 'ten_softshore', '1105', 'AR Control', 'asset', 'control', 1, 'AR_SYSTEM_CONTROL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1200', 'ten_softshore', '1200', 'Inventory', 'asset', 'inventory', 1, 'INVENTORY', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1300', 'ten_softshore', '1300', 'Prepaid Expenses', 'asset', 'current_asset', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1500', 'ten_softshore', '1500', 'Fixed Assets', 'asset', 'fixed_asset', 1, 'FIXED_ASSETS', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_1510', 'ten_softshore', '1510', 'Accumulated Depreciation', 'asset', 'contra_asset', 1, 'ACCUM_DEPRECIATION', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2000', 'ten_softshore', '2000', 'Accounts Payable (AP)', 'liability', 'payable', 1, 'AP_CONTROL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2005', 'ten_softshore', '2005', 'AP Control', 'liability', 'control', 1, 'AP_SYSTEM_CONTROL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2100', 'ten_softshore', '2100', 'VAT/Tax Payable', 'liability', 'tax', 1, 'TAX_CONTROL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2105', 'ten_softshore', '2105', 'Tax Control', 'liability', 'control', 1, 'TAX_SYSTEM_CONTROL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2200', 'ten_softshore', '2200', 'Salaries Payable', 'liability', 'current_liability', 1, 'SALARIES_PAYABLE', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2300', 'ten_softshore', '2300', 'Deferred Revenue (Advance Billings)', 'liability', 'deferred', 1, 'DEFERRED_REVENUE', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_2400', 'ten_softshore', '2400', 'Loans Payable', 'liability', 'long_term_liability', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_3000', 'ten_softshore', '3000', 'Owner\'s Capital', 'equity', 'capital', 1, 'OWNERS_CAPITAL', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_3100', 'ten_softshore', '3100', 'Retained Earnings', 'equity', 'retained_earnings', 1, 'RETAINED_EARNINGS', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_3200', 'ten_softshore', '3200', 'Drawings', 'equity', 'drawings', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_3900', 'ten_softshore', '3900', 'Opening Balance Equity', 'equity', 'system_equity', 1, 'OPENING_BALANCE_EQUITY', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_4000', 'ten_softshore', '4000', 'Product Sales Revenue', 'revenue', 'operating_revenue', 1, 'PRODUCT_REVENUE', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_4100', 'ten_softshore', '4100', 'Service Revenue', 'revenue', 'operating_revenue', 1, 'SERVICE_REVENUE', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_4200', 'ten_softshore', '4200', 'Discounts Given', 'revenue', 'contra_revenue', 1, 'DISCOUNTS_GIVEN', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_4300', 'ten_softshore', '4300', 'Other Income', 'revenue', 'other_income', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5000', 'ten_softshore', '5000', 'Cost of Goods Sold (COGS)', 'expense', 'cogs', 1, 'COGS', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5100', 'ten_softshore', '5100', 'Salaries & Wages', 'expense', 'operating_expense', 1, 'SALARIES_EXPENSE', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5200', 'ten_softshore', '5200', 'Rent Expense', 'expense', 'operating_expense', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5300', 'ten_softshore', '5300', 'Utilities', 'expense', 'operating_expense', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5400', 'ten_softshore', '5400', 'Marketing', 'expense', 'operating_expense', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5500', 'ten_softshore', '5500', 'Bank Charges', 'expense', 'financial_expense', 1, 'BANK_CHARGES', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5600', 'ten_softshore', '5600', 'Depreciation', 'expense', 'non_cash_expense', 1, 'DEPRECIATION_EXPENSE', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5700', 'ten_softshore', '5700', 'Miscellaneous Expense', 'expense', 'operating_expense', 0, NULL, 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO accounts (id, tenant_id, code, name, type, subtype, is_system, control_key, opening_debit, opening_credit, status, created_at) VALUES ('acc_ten_softshore_5900', 'ten_softshore', '5900', 'Rounding Adjustment', 'expense', 'system_adjustment', 1, 'ROUNDING_ADJUSTMENT', 0, 0, 'active', '2026-10-05 15:13:24') ON DUPLICATE KEY UPDATE name=VALUES(name);

-- 7. Seed Demo Company Customers
INSERT INTO customers (id, tenant_id, branch_id, code, name, company, email, phone, address, tax_id, tags, credit_limit, advance_balance, payment_score, status, notes, created_at) VALUES ('cust_1', 'ten_softshore', 'br_ten_softshore_hq', 'CUST-1001', 'Square Pharmaceuticals PLC', 'Square Pharmaceuticals PLC', 'mehedi@squarepharma.com.bd', '+8801710328545', 'Square Centre, 48 Mohakhali C/A, Dhaka-1212', 'BIN-000112233-0101', '["Enterprise","ERP-Cloud","VIP"]', 500000, 0, 96, 'active', 'Flagship enterprise subscriber on dedicated cloud cluster.', '2026-01-20 10:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO customers (id, tenant_id, branch_id, code, name, company, email, phone, address, tax_id, tags, credit_limit, advance_balance, payment_score, status, notes, created_at) VALUES ('cust_2', 'ten_softshore', 'br_ten_softshore_hq', 'CUST-1002', 'BracNet Digital Services', 'BracNet Ltd.', 'accounts@bracnet.net', '+8801714009988', 'Gulshan-1, Dhaka-1212', 'BIN-000445566-0102', '["Quarterly","SaaS"]', 300000, 25000, 88, 'active', 'Prefers SSLCommerz or Bank EFT.', '2026-02-05 10:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO customers (id, tenant_id, branch_id, code, name, company, email, phone, address, tax_id, tags, credit_limit, advance_balance, payment_score, status, notes, created_at) VALUES ('cust_3', 'ten_softshore', 'br_ten_softshore_ctg', 'CUST-1003', 'Karnafuli Port Logistics Ltd.', 'Karnafuli Port Logistics', 'finance@karnafulilogistics.com', '+8801811334455', 'Agrabad C/A, Chattogram', 'BIN-000778899-0301', '["Chattogram","Overdue-Watch"]', 200000, 0, 64, 'active', 'Follow up 3 days before due via SMS.', '2026-03-10 10:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO customers (id, tenant_id, branch_id, code, name, company, email, phone, address, tax_id, tags, credit_limit, advance_balance, payment_score, status, notes, created_at) VALUES ('cust_4', 'ten_softshore', 'br_ten_softshore_syl', 'CUST-1004', 'Sylhet Tea Valley Exports', 'Sylhet Tea Valley', 'info@sylhetteavalley.com', '+8801912667788', 'Airport Road, Sylhet', 'BIN-000991122-0401', '["SME","Monthly"]', 150000, 0, 92, 'active', 'Uses bKash merchant auto-pay.', '2026-04-12 10:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);
INSERT INTO customers (id, tenant_id, branch_id, code, name, company, email, phone, address, tax_id, tags, credit_limit, advance_balance, payment_score, status, notes, created_at) VALUES ('cust_5', 'ten_softshore', 'br_ten_softshore_hq', 'CUST-1005', 'CWIS-FSM Support Cell, Department of Public Health Engineering', 'Department of Public Health Engineering (DPHE)', 'cwis.fsm@dphe.gov.bd', '+8801710328545', 'DPHE Bhaban, (9th floor), 14 Shaheed Captain Mansur Ali Soroni, Kakrail, Dhaka- 1000', 'BIN-DPHE-GOV-1000', '["Government","Monthly-Maintenance"]', 500000, 0, 98, 'active', 'Monthly Website Development & Maintenance contract.', '2026-05-01 10:00:00') ON DUPLICATE KEY UPDATE name=VALUES(name);

-- 8. Seed Products & Services
INSERT INTO products (id, tenant_id, type, sku, name, category, description, price, cost, tax_rate, unit, track_inventory, stock_qty, low_stock_alert, revenue_account_code, cogs_account_code, status) VALUES ('prod_1', 'ten_softshore', 'service', 'SAAS-ENT-CLOUD', 'Enterprise Cloud ERP & Billing Suite', 'SaaS Subscription', 'Dedicated multi-branch ERP, CRM & Accounting cloud node with 99.9% SLA.', 45000, 0, 15, 'month', 0, 0, 0, '4100', '5000', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name), price=VALUES(price);
INSERT INTO products (id, tenant_id, type, sku, name, category, description, price, cost, tax_rate, unit, track_inventory, stock_qty, low_stock_alert, revenue_account_code, cogs_account_code, status) VALUES ('prod_2', 'ten_softshore', 'service', 'SVC-DED-HOST', 'Managed Kubernetes & DB Cluster', 'Cloud Infrastructure', 'Automated daily backups, SSL, load balancer & 24/7 DevOps monitoring.', 25000, 0, 15, 'month', 0, 0, 0, '4100', '5000', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name), price=VALUES(price);
INSERT INTO products (id, tenant_id, type, sku, name, category, description, price, cost, tax_rate, unit, track_inventory, stock_qty, low_stock_alert, revenue_account_code, cogs_account_code, status) VALUES ('prod_3', 'ten_softshore', 'product', 'HW-POS-TERM', 'Smart Android POS & Barcode Terminal', 'Hardware', 'NFC + Thermal Receipt Printer terminal for retail branch billing.', 18500, 11000, 15, 'device', 1, 24, 10, '4000', '5000', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name), price=VALUES(price);
INSERT INTO products (id, tenant_id, type, sku, name, category, description, price, cost, tax_rate, unit, track_inventory, stock_qty, low_stock_alert, revenue_account_code, cogs_account_code, status) VALUES ('prod_4', 'ten_softshore', 'service', 'SVC-SMS-BUNDLE', 'BGTel Masking SMS Enterprise Pack (50k)', 'Communication Add-on', '50,000 transactional SMS credits with custom Sender ID.', 15000, 9000, 15, 'pack', 0, 0, 0, '4100', '5000', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name), price=VALUES(price);
INSERT INTO products (id, tenant_id, type, sku, name, category, description, price, cost, tax_rate, unit, track_inventory, stock_qty, low_stock_alert, revenue_account_code, cogs_account_code, status) VALUES ('prod_5', 'ten_softshore', 'product', 'HW-BIO-ATT', 'Biometric Cloud Attendance Gateway', 'Hardware', 'Face + Fingerprint cloud device synced with Payroll module.', 12000, 7500, 15, 'unit', 1, 4, 5, '4000', '5000', 'active') ON DUPLICATE KEY UPDATE name=VALUES(name), price=VALUES(price);

-- 9. Seed Customer Subscriptions
INSERT INTO subscriptions (id, tenant_id, branch_id, customer_id, product_id, plan_name, cycle, custom_days, start_date, next_invoice_date, qty, unit_price, discount_type, discount_value, tax_rate, auto_renew, is_deferred_revenue, deferred_months, status, created_at) VALUES ('sub_1', 'ten_softshore', 'br_ten_softshore_hq', 'cust_1', 'prod_1', 'Enterprise Cloud ERP & Billing Suite (Monthly)', 'monthly', NULL, '2026-01-01', '2026-10-05', 1, 45000, 'percent', 0, 15, 1, 0, 1, 'active', '2026-01-01 10:00:00') ON DUPLICATE KEY UPDATE status=VALUES(status), next_invoice_date=VALUES(next_invoice_date);
INSERT INTO subscriptions (id, tenant_id, branch_id, customer_id, product_id, plan_name, cycle, custom_days, start_date, next_invoice_date, qty, unit_price, discount_type, discount_value, tax_rate, auto_renew, is_deferred_revenue, deferred_months, status, created_at) VALUES ('sub_2', 'ten_softshore', 'br_ten_softshore_hq', 'cust_2', 'prod_2', 'Managed Kubernetes & DB Cluster (Quarterly)', 'quarterly', NULL, '2026-02-01', '2026-11-01', 3, 25000, 'percent', 10, 15, 1, 1, 3, 'active', '2026-02-01 10:00:00') ON DUPLICATE KEY UPDATE status=VALUES(status), next_invoice_date=VALUES(next_invoice_date);
INSERT INTO subscriptions (id, tenant_id, branch_id, customer_id, product_id, plan_name, cycle, custom_days, start_date, next_invoice_date, qty, unit_price, discount_type, discount_value, tax_rate, auto_renew, is_deferred_revenue, deferred_months, status, created_at) VALUES ('sub_3', 'ten_softshore', 'br_ten_softshore_ctg', 'cust_3', 'prod_4', 'BGTel Masking SMS Enterprise Pack (Monthly)', 'monthly', NULL, '2026-03-01', '2026-10-04', 2, 15000, 'fixed', 1000, 15, 1, 0, 1, 'active', '2026-03-01 10:00:00') ON DUPLICATE KEY UPDATE status=VALUES(status), next_invoice_date=VALUES(next_invoice_date);
INSERT INTO subscriptions (id, tenant_id, branch_id, customer_id, product_id, plan_name, cycle, custom_days, start_date, next_invoice_date, qty, unit_price, discount_type, discount_value, tax_rate, auto_renew, is_deferred_revenue, deferred_months, status, created_at) VALUES ('sub_4', 'ten_softshore', 'br_ten_softshore_syl', 'cust_4', 'prod_2', 'Managed Cloud Node (Bi-Weekly Sprint Billing)', 'bi_weekly', 14, '2026-05-01', '2026-10-10', 1, 14000, 'percent', 0, 15, 1, 0, 1, 'active', '2026-05-01 10:00:00') ON DUPLICATE KEY UPDATE status=VALUES(status), next_invoice_date=VALUES(next_invoice_date);

-- 10. Seed CRM Leads
INSERT INTO leads (id, tenant_id, branch_id, name, company, email, phone, source, stage, estimated_value, probability, assigned_to, interested_product_id, notes, converted_customer_id, created_at) VALUES ('lead_1', 'ten_softshore', 'br_ten_softshore_hq', 'Tariqul Islam', 'Pran-RFL Agro Supply Chain', 'tariq@pranrfl.com', '+8801713445566', 'Inbound Demo Request', 'Qualified', 180000, 80, 'Rafiq Hasan', 'prod_1', 'Technical evaluation passed. Ready for 1-click Customer + Subscription conversion!', NULL, '2026-09-25 10:00:00') ON DUPLICATE KEY UPDATE stage=VALUES(stage);
INSERT INTO leads (id, tenant_id, branch_id, name, company, email, phone, source, stage, estimated_value, probability, assigned_to, interested_product_id, notes, converted_customer_id, created_at) VALUES ('lead_2', 'ten_softshore', 'br_ten_softshore_hq', 'Samia Karim', 'Chaldal Grocery Fulfillment', 'samia@chaldal.com', '+8801844556677', 'LinkedIn Enterprise', 'Contacted', 95000, 50, 'Nusrat Jahan', 'prod_2', 'Demo scheduled for Thursday with CFO and CTO.', NULL, '2026-09-28 14:00:00') ON DUPLICATE KEY UPDATE stage=VALUES(stage);
INSERT INTO leads (id, tenant_id, branch_id, name, company, email, phone, source, stage, estimated_value, probability, assigned_to, interested_product_id, notes, converted_customer_id, created_at) VALUES ('lead_3', 'ten_softshore', 'br_ten_softshore_ctg', 'Mahbubur Chowdhury', 'BSRM Steel Distribution', 'mahbub@bsrm.com', '+8801711223399', 'Referral', 'New', 240000, 30, 'Rafiq Hasan', 'prod_1', 'Needs 12-branch cost center accounting & custom VAT report.', NULL, '2026-10-02 09:15:00') ON DUPLICATE KEY UPDATE stage=VALUES(stage);
INSERT INTO leads (id, tenant_id, branch_id, name, company, email, phone, source, stage, estimated_value, probability, assigned_to, interested_product_id, notes, converted_customer_id, created_at) VALUES ('lead_4', 'ten_softshore', 'br_ten_softshore_hq', 'Mehedi Alam', 'Square Pharmaceuticals PLC', 'mehedi@squarepharma.com.bd', '+8801710328545', 'Direct Enterprise', 'Won', 540000, 100, 'Nusrat Jahan', 'prod_1', 'Converted to active enterprise subscription.', 'cust_1', '2026-01-15 11:00:00') ON DUPLICATE KEY UPDATE stage=VALUES(stage);

-- 11. Seed Invoices & Multi-Line Invoice Items
INSERT INTO invoices (id, tenant_id, branch_id, customer_id, subscription_id, number, date, due_date, status, currency, exchange_rate, subtotal, discount, tax, rounding_adjustment, total, paid_amount, credited_amount, je_id, notes, terms) VALUES ('inv_cwis', 'ten_softshore', 'br_ten_softshore_hq', 'cust_5', NULL, '26092501510', '2026-09-27', '2026-10-12', 'Sent', 'BDT', 1, 14000, 0, 0, 0, 14000, 0, 0, 'je_ten_softshore_1791213204367_191', '1. All the amounts are in Bangladeshi Taka | 2. The amount is VAT & Tax Included', 'Payment To: Softshore Technology, Acc. No: 2052820500001, BRAC Bank Limited, Gulshan Branch, Dhaka (SWIFT: BRAKBDDH)') ON DUPLICATE KEY UPDATE status=VALUES(status), paid_amount=VALUES(paid_amount);
INSERT INTO invoices (id, tenant_id, branch_id, customer_id, subscription_id, number, date, due_date, status, currency, exchange_rate, subtotal, discount, tax, rounding_adjustment, total, paid_amount, credited_amount, je_id, notes, terms) VALUES ('inv_1001', 'ten_softshore', 'br_ten_softshore_hq', 'cust_1', 'sub_1', 'INV-SS-2026-1001', '2026-09-05', '2026-09-20', 'Paid', 'BDT', 1, 70000, 0, 10500, 0, 80500, 80500, 0, 'je_ten_softshore_1791213204367_426', 'Thank you for your business with SoftShore Cloud Solutions.', 'Net 15 Days. Late payments subject to automated dunning reminders.') ON DUPLICATE KEY UPDATE status=VALUES(status), paid_amount=VALUES(paid_amount);
INSERT INTO invoices (id, tenant_id, branch_id, customer_id, subscription_id, number, date, due_date, status, currency, exchange_rate, subtotal, discount, tax, rounding_adjustment, total, paid_amount, credited_amount, je_id, notes, terms) VALUES ('inv_1002', 'ten_softshore', 'br_ten_softshore_hq', 'cust_2', 'sub_2', 'INV-SS-2026-1002', '2026-09-15', '2026-10-08', 'Partially Paid', 'BDT', 1, 93500, 3500, 13500, 0, 103500, 50000, 0, 'je_ten_softshore_1791213204367_679', 'Partial payment of BDT 50,000 received via SSLCommerz.', 'Balance due by 08 Oct 2026.') ON DUPLICATE KEY UPDATE status=VALUES(status), paid_amount=VALUES(paid_amount);
INSERT INTO invoices (id, tenant_id, branch_id, customer_id, subscription_id, number, date, due_date, status, currency, exchange_rate, subtotal, discount, tax, rounding_adjustment, total, paid_amount, credited_amount, je_id, notes, terms) VALUES ('inv_1003', 'ten_softshore', 'br_ten_softshore_ctg', 'cust_3', 'sub_3', 'INV-SS-2026-1003', '2026-09-01', '2026-09-22', 'Overdue', 'BDT', 1, 30000, 1000, 4350, 0, 33350, 0, 0, 'je_ten_softshore_1791213204367_453', 'Overdue reminder dispatched via BGTel SMS & SMTP.', 'Immediate payment requested.') ON DUPLICATE KEY UPDATE status=VALUES(status), paid_amount=VALUES(paid_amount);
INSERT INTO invoices (id, tenant_id, branch_id, customer_id, subscription_id, number, date, due_date, status, currency, exchange_rate, subtotal, discount, tax, rounding_adjustment, total, paid_amount, credited_amount, je_id, notes, terms) VALUES ('inv_1004', 'ten_softshore', 'br_ten_softshore_syl', 'cust_4', 'sub_4', 'INV-SS-2026-1004', '2026-10-01', '2026-10-07', 'Sent', 'BDT', 1, 26000, 0, 3900, 0, 29900, 0, 0, 'je_ten_softshore_1791213204367_639', 'Due in 3 days — eligible for Pre-Due Reminder Cron.', 'Net 7 Days.') ON DUPLICATE KEY UPDATE status=VALUES(status), paid_amount=VALUES(paid_amount);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_cwis_1', 'inv_cwis', 'prod_1', 'Monthly Website Development & Maintenance (01-August-2026 to 31-August-2026)', 1, 14000, 0, 0, 0, 14000, '4100') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1001_1', 'inv_1001', 'prod_1', 'Enterprise Cloud ERP & Billing Suite - Sep 2026', 1, 45000, 0, 15, 6750, 51750, '4100') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1001_2', 'inv_1001', 'prod_2', 'Managed Kubernetes & DB Cluster - Sep 2026', 1, 25000, 0, 15, 3750, 28750, '4100') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1002_1', 'inv_1002', 'prod_2', 'Managed Kubernetes & DB Cluster (3 Nodes)', 3, 25000, 3500, 15, 10725, 82225, '4100') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1002_2', 'inv_1002', 'prod_3', 'Smart Android POS & Barcode Terminal', 1, 18500, 0, 15, 2775, 21275, '4000') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1003_1', 'inv_1003', 'prod_4', 'BGTel Masking SMS Enterprise Pack (2x 50k)', 2, 15000, 1000, 15, 4350, 33350, '4100') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1004_1', 'inv_1004', 'prod_2', 'Managed Cloud Node (Bi-Weekly Sprint)', 1, 14000, 0, 15, 2100, 16100, '4100') ON DUPLICATE KEY UPDATE total=VALUES(total);
INSERT INTO invoice_items (id, invoice_id, product_id, description, qty, unit_price, discount, tax_rate, tax_amount, total, account_code) VALUES ('item_1004_2', 'inv_1004', 'prod_5', 'Biometric Cloud Attendance Gateway', 1, 12000, 0, 15, 1800, 13800, '4000') ON DUPLICATE KEY UPDATE total=VALUES(total);

-- 12. Seed Payments
INSERT INTO payments (id, tenant_id, branch_id, invoice_id, customer_id, receipt_number, amount, bank_charge, method, deposit_account_code, reference, status, je_id, paid_at) VALUES ('pmt_501', 'ten_softshore', 'br_ten_softshore_hq', 'inv_1001', 'cust_1', 'RCP-SS-2026-501', 80500, 0, 'Bank Transfer', '1010', 'CITY-EFT-9928172', 'Completed', 'je_ten_softshore_1791213204367_953', '2026-09-18 11:20:00') ON DUPLICATE KEY UPDATE amount=VALUES(amount);
INSERT INTO payments (id, tenant_id, branch_id, invoice_id, customer_id, receipt_number, amount, bank_charge, method, deposit_account_code, reference, status, je_id, paid_at) VALUES ('pmt_502', 'ten_softshore', 'br_ten_softshore_hq', 'inv_1002', 'cust_2', 'RCP-SS-2026-502', 50000, 750, 'SSLCommerz', '1010', 'SSLCZ-TXN-884120', 'Completed', 'je_ten_softshore_1791213204367_68', '2026-09-25 15:40:00') ON DUPLICATE KEY UPDATE amount=VALUES(amount);

-- 13. Seed Full Operational Graph Snapshot
INSERT INTO app_state_store (id, state_json) VALUES ('primary_state', '{"master_coa_template":[{"code":"1000","name":"Cash on Hand","type":"asset","subtype":"cash","is_system":true,"control_key":"CASH"},{"code":"1010","name":"Cash at Bank","type":"asset","subtype":"bank","is_system":true,"control_key":"BANK"},{"code":"1020","name":"Mobile Wallet (bKash/Nagad)","type":"asset","subtype":"wallet","is_system":true,"control_key":"WALLET"},{"code":"1100","name":"Accounts Receivable (AR)","type":"asset","subtype":"receivable","is_system":true,"control_key":"AR_CONTROL"},{"code":"1105","name":"AR Control","type":"asset","subtype":"control","is_system":true,"control_key":"AR_SYSTEM_CONTROL"},{"code":"1200","name":"Inventory","type":"asset","subtype":"inventory","is_system":true,"control_key":"INVENTORY"},{"code":"1300","name":"Prepaid Expenses","type":"asset","subtype":"current_asset","is_system":false,"control_key":null},{"code":"1500","name":"Fixed Assets","type":"asset","subtype":"fixed_asset","is_system":true,"control_key":"FIXED_ASSETS"},{"code":"1510","name":"Accumulated Depreciation","type":"asset","subtype":"contra_asset","is_system":true,"control_key":"ACCUM_DEPRECIATION"},{"code":"2000","name":"Accounts Payable (AP)","type":"liability","subtype":"payable","is_system":true,"control_key":"AP_CONTROL"},{"code":"2005","name":"AP Control","type":"liability","subtype":"control","is_system":true,"control_key":"AP_SYSTEM_CONTROL"},{"code":"2100","name":"VAT/Tax Payable","type":"liability","subtype":"tax","is_system":true,"control_key":"TAX_CONTROL"},{"code":"2105","name":"Tax Control","type":"liability","subtype":"control","is_system":true,"control_key":"TAX_SYSTEM_CONTROL"},{"code":"2200","name":"Salaries Payable","type":"liability","subtype":"current_liability","is_system":true,"control_key":"SALARIES_PAYABLE"},{"code":"2300","name":"Deferred Revenue (Advance Billings)","type":"liability","subtype":"deferred","is_system":true,"control_key":"DEFERRED_REVENUE"},{"code":"2400","name":"Loans Payable","type":"liability","subtype":"long_term_liability","is_system":false,"control_key":null},{"code":"3000","name":"Owner\'s Capital","type":"equity","subtype":"capital","is_system":true,"control_key":"OWNERS_CAPITAL"},{"code":"3100","name":"Retained Earnings","type":"equity","subtype":"retained_earnings","is_system":true,"control_key":"RETAINED_EARNINGS"},{"code":"3200","name":"Drawings","type":"equity","subtype":"drawings","is_system":false,"control_key":null},{"code":"3900","name":"Opening Balance Equity","type":"equity","subtype":"system_equity","is_system":true,"control_key":"OPENING_BALANCE_EQUITY"},{"code":"4000","name":"Product Sales Revenue","type":"revenue","subtype":"operating_revenue","is_system":true,"control_key":"PRODUCT_REVENUE"},{"code":"4100","name":"Service Revenue","type":"revenue","subtype":"operating_revenue","is_system":true,"control_key":"SERVICE_REVENUE"},{"code":"4200","name":"Discounts Given","type":"revenue","subtype":"contra_revenue","is_system":true,"control_key":"DISCOUNTS_GIVEN"},{"code":"4300","name":"Other Income","type":"revenue","subtype":"other_income","is_system":false,"control_key":null},{"code":"5000","name":"Cost of Goods Sold (COGS)","type":"expense","subtype":"cogs","is_system":true,"control_key":"COGS"},{"code":"5100","name":"Salaries & Wages","type":"expense","subtype":"operating_expense","is_system":true,"control_key":"SALARIES_EXPENSE"},{"code":"5200","name":"Rent Expense","type":"expense","subtype":"operating_expense","is_system":false,"control_key":null},{"code":"5300","name":"Utilities","type":"expense","subtype":"operating_expense","is_system":false,"control_key":null},{"code":"5400","name":"Marketing","type":"expense","subtype":"operating_expense","is_system":false,"control_key":null},{"code":"5500","name":"Bank Charges","type":"expense","subtype":"financial_expense","is_system":true,"control_key":"BANK_CHARGES"},{"code":"5600","name":"Depreciation","type":"expense","subtype":"non_cash_expense","is_system":true,"control_key":"DEPRECIATION_EXPENSE"},{"code":"5700","name":"Miscellaneous Expense","type":"expense","subtype":"operating_expense","is_system":false,"control_key":null},{"code":"5900","name":"Rounding Adjustment","type":"expense","subtype":"system_adjustment","is_system":true,"control_key":"ROUNDING_ADJUSTMENT"}],"plans":[{"id":"plan_trial","name":"Starter Trial (14 Days)","price_monthly":0,"price_yearly":0,"currency":"BDT","max_users":3,"max_branches":1,"max_invoices_month":50,"features":["Auto-Seeded COA & GL","CRM Pipeline","Multi-line Invoicing","Email Notifications"],"status":"active"},{"id":"plan_basic","name":"Basic Growth","price_monthly":2500,"price_yearly":25000,"currency":"BDT","max_users":10,"max_branches":2,"max_invoices_month":1000,"features":["Auto-Seeded COA & GL","CRM & Lead Conversion","Recurring Subscriptions","BGTel SMS + SMTP Alerts","6 Core Reports"],"status":"active"},{"id":"plan_pro","name":"Business Pro","price_monthly":6500,"price_yearly":65000,"currency":"BDT","max_users":35,"max_branches":10,"max_invoices_month":10000,"features":["Full Double-Entry GL Engine","All 12 Financial Reports","Multi-Branch Cost Centers","bKash / SSLCommerz / Stripe","AI Cash-Flow Predictor","Fixed Assets & Depreciation"],"status":"active"},{"id":"plan_enterprise","name":"Enterprise Unlimited","price_monthly":15000,"price_yearly":150000,"currency":"BDT","max_users":999,"max_branches":100,"max_invoices_month":500000,"features":["Unlimited Multi-Branch & Users","Custom Domain Mapping","Maker-Checker GL Posting Queue","Dedicated SLA & Audit Exports","Multi-Currency FX Engine","Full REST API + Webhooks"],"status":"active"}],"tenants":[{"id":"ten_softshore","name":"Demo Company","subdomain":"demo","custom_domain":"billing.softshore.tech","plan_id":"plan_enterprise","status":"active","currency":"BDT","timezone":"Asia/Dhaka","tax_id":"BIN-004928172-0101","vat_rate":15,"email":"info@softshore.tech","phone":"+8801710328545","address":"House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh","logo_url":"","onboarding_completed":true,"notification_types":["email","sms"],"settings":{"notification_types":["email","sms"],"invoice_prefix":"INV-SS","quote_prefix":"QT-SS","brand_color":"#156a83","smtp_host":"mail.softshore.tech","smtp_port":587,"smtp_from":"no-reply@softshore.tech","sms_gateway_url":"https://apipro.bgtelsms.com/onetomany","sms_acode":"30000075","sms_api_key":"00694cc4892224ee3eefffed2330becadcb8cade","sms_sender_id":"KidLand","gateways":{"bkash":{"enabled":true,"merchant_no":"01710328545"},"sslcommerz":{"enabled":true,"store_id":"softshore_live"},"stripe":{"enabled":true,"pub_key":"pk_live_softshore"},"paypal":{"enabled":false}},"dnd_enabled":false,"dnd_start_hour":22,"dnd_end_hour":7,"require_gl_queue_approval":false,"reminder_days_before":[7,3,1],"overdue_days_after":[1,3,7],"invoice_template":{"layout_style":"softshore_official","document_title":"INVOICE","company_display_name":"Demo Company","logo_url":"","show_logo":true,"header_address":"House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh","header_email":"info@softshore.tech","header_website":"www.softshore.tech","header_phone":"+880 1710328545","primary_color":"#156a83","secondary_bg_color":"#dbf1f8","border_accent_color":"#219fc4","bill_to_heading":"BILL TO:","table_column_mode":"description_amount","col_description_label":"DESCRIPTION","col_amount_label":"AMOUNT","min_table_rows":6,"show_previous_due":true,"previous_due_label":"PREVIOUS DUE","total_label":"TOTAL","show_discount_row":true,"discount_label":"DISCOUNT","show_vat_row":false,"vat_label":"VAT / TAX","total_pay_label":"TOTAL PAY AMOUNT","note_heading":"Note:","notes_list":["All the amounts are in Bangladeshi Taka","The amount is VAT & Tax Included"],"show_payment_to":true,"payment_to_heading":"Payment To","bank_account_name":"Softshore Technology","bank_account_no":"2052820500001","bank_name":"BRAC Bank Limited","bank_branch":"Gulshan Branch, Dhaka","bank_swift_code":"BRAKBDDH","payment_mode_note":"Suitable transaction mode could be possible.","show_prepared_by":true,"prepared_by_heading":"Prepared By","prepared_by_name":"Zulfiker Ahmed","prepared_by_designation":"Manager, Account Operations","prepared_by_company":"SoftShore Technology","prepared_by_email":"zulfiker@softshore.tech","prepared_by_website":"www.softshore.tech","footer_disclaimer":"This is a computer-generated invoice and doesn\'t require any signature","footer_underline":true}},"created_at":"2026-01-10T08:00:00.000Z","invoice_template":{"layout_style":"softshore_official","document_title":"INVOICE","company_display_name":"Demo Company","logo_url":"","show_logo":true,"header_address":"House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh","header_email":"info@softshore.tech","header_website":"www.softshore.tech","header_phone":"+880 1710328545","primary_color":"#156a83","secondary_bg_color":"#dbf1f8","border_accent_color":"#219fc4","bill_to_heading":"BILL TO:","table_column_mode":"description_amount","col_description_label":"DESCRIPTION","col_amount_label":"AMOUNT","min_table_rows":6,"show_previous_due":true,"previous_due_label":"PREVIOUS DUE","total_label":"TOTAL","show_discount_row":true,"discount_label":"DISCOUNT","show_vat_row":false,"vat_label":"VAT / TAX","total_pay_label":"TOTAL PAY AMOUNT","note_heading":"Note:","notes_list":["All the amounts are in Bangladeshi Taka","The amount is VAT & Tax Included"],"show_payment_to":true,"payment_to_heading":"Payment To","bank_account_name":"Softshore Technology","bank_account_no":"2052820500001","bank_name":"BRAC Bank Limited","bank_branch":"Gulshan Branch, Dhaka","bank_swift_code":"BRAKBDDH","payment_mode_note":"Suitable transaction mode could be possible.","show_prepared_by":true,"prepared_by_heading":"Prepared By","prepared_by_name":"Zulfiker Ahmed","prepared_by_designation":"Manager, Account Operations","prepared_by_company":"SoftShore Technology","prepared_by_email":"zulfiker@softshore.tech","prepared_by_website":"www.softshore.tech","footer_disclaimer":"This is a computer-generated invoice and doesn\'t require any signature","footer_underline":true}}],"branches":[{"id":"br_ten_softshore_hq","tenant_id":"ten_softshore","code":"HQ-01","name":"Demo Company - Head Office","address":"House: 336, Road: Afroza Begum Sorok, Block: G, Bashundhora R/A, Dhaka, Bangladesh","phone":"+8801710328545","manager_id":"Company Admin","is_main":true,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"br_ten_softshore_ctg","tenant_id":"ten_softshore","code":"CTG-02","name":"Chattogram Regional Branch","address":"WTC Tower, Agrabad C/A, Chattogram","phone":"+8801711998877","manager_id":"Nusrat Jahan","is_main":false,"status":"active","created_at":"2026-01-15T09:00:00.000Z"},{"id":"br_ten_softshore_syl","tenant_id":"ten_softshore","code":"SYL-03","name":"Sylhet Tech Park Hub","address":"Zindabazar Commercial Center, Sylhet","phone":"+8801711554433","manager_id":"Rafiq Hasan","is_main":false,"status":"active","created_at":"2026-02-01T09:00:00.000Z"}],"roles":[{"id":"role_super_admin","tenant_id":null,"name":"Super Admin","scope":"platform","permissions":["platform.all","tenants.manage","plans.manage","coa_template.manage","cron.run"]},{"id":"role_company_admin","tenant_id":"ten_softshore","name":"Company Admin","scope":"tenant","permissions":["tenant.all","users.manage","branches.manage","coa.manage","invoices.all","payments.all","crm.all","reports.all","settings.manage"]},{"id":"role_company_manager","tenant_id":"ten_softshore","name":"Company Manager","scope":"branch","permissions":["branches.view","invoices.all","subscriptions.all","customers.all","crm.all","reports.operational"]},{"id":"role_company_executive","tenant_id":"ten_softshore","name":"Company Executive","scope":"branch","permissions":["invoices.create","payments.record","customers.assigned","crm.pipeline","tasks.manage"]},{"id":"role_accountant","tenant_id":"ten_softshore","name":"Accountant","scope":"tenant","permissions":["accounting.all","journal.create","journal.approve","reconciliation.manage","periods.close","reports.financial"]},{"id":"role_customer","tenant_id":"ten_softshore","name":"Customer","scope":"self","permissions":["portal.view_invoices","portal.pay_online","portal.download_receipts","portal.statement"]}],"users":[{"id":"usr_super","tenant_id":"ten_softshore","branch_id":null,"role_id":"role_super_admin","role_name":"Super Admin","name":"Kayser Ahmed (Super Admin)","email":"superadmin@softshore.tech","alt_email":"kayser@softshore.tech","password_hash":"admin123","two_factor_enabled":true,"status":"active","last_login_at":"2026-10-04T16:45:00.000Z"},{"id":"usr_admin","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","role_id":"role_company_admin","role_name":"Company Admin","name":"Tanvir Rahman (Company Admin)","email":"admin@democompany.com","alt_email":"admin@softshore.tech","password_hash":"demo123","two_factor_enabled":true,"status":"active","last_login_at":"2026-10-04T17:00:00.000Z"},{"id":"usr_manager","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","role_id":"role_company_manager","role_name":"Company Manager","name":"Nusrat Jahan (Branch Manager)","email":"manager@democompany.com","alt_email":"manager@softshore.tech","password_hash":"demo123","two_factor_enabled":false,"status":"active","last_login_at":"2026-10-04T15:20:00.000Z"},{"id":"usr_accountant","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","role_id":"role_accountant","role_name":"Accountant","name":"Farhana Akter FCA (Chief Accountant)","email":"accountant@democompany.com","alt_email":"accountant@softshore.tech","password_hash":"demo123","two_factor_enabled":true,"status":"active","last_login_at":"2026-10-04T16:50:00.000Z"},{"id":"usr_exec","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_ctg","role_id":"role_company_executive","role_name":"Company Executive","name":"Rafiq Hasan (Sales Executive)","email":"executive@democompany.com","alt_email":"executive@softshore.tech","password_hash":"demo123","two_factor_enabled":false,"status":"active","last_login_at":"2026-10-04T14:10:00.000Z"},{"id":"usr_cs_exec","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","role_id":"role_company_executive","role_name":"Company Executive","name":"Sadia Islam (Customer Success Lead)","email":"sadia@democompany.com","alt_email":"sadia@softshore.tech","password_hash":"demo123","two_factor_enabled":false,"status":"active","last_login_at":"2026-10-04T15:10:00.000Z"},{"id":"usr_support_eng","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_syl","role_id":"role_company_executive","role_name":"Company Executive","name":"Kamrul Hasan (Cloud Support Engineer)","email":"kamrul@democompany.com","alt_email":"kamrul@softshore.tech","password_hash":"demo123","two_factor_enabled":false,"status":"active","last_login_at":"2026-10-04T13:40:00.000Z"},{"id":"usr_customer","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","role_id":"role_customer","role_name":"Customer","name":"Mehedi Alam (Square Pharma IT)","email":"customer@democompany.com","alt_email":"mehedi@squarepharma.com.bd","customer_id":"cust_1","password_hash":"demo123","two_factor_enabled":false,"status":"active","last_login_at":"2026-10-04T12:00:00.000Z"}],"accounts":[{"id":"acc_ten_softshore_1000","tenant_id":"ten_softshore","code":"1000","name":"Cash on Hand","type":"asset","subtype":"cash","parent_id":null,"is_system":true,"control_key":"CASH","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1010","tenant_id":"ten_softshore","code":"1010","name":"Cash at Bank","type":"asset","subtype":"bank","parent_id":null,"is_system":true,"control_key":"BANK","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1020","tenant_id":"ten_softshore","code":"1020","name":"Mobile Wallet (bKash/Nagad)","type":"asset","subtype":"wallet","parent_id":null,"is_system":true,"control_key":"WALLET","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1100","tenant_id":"ten_softshore","code":"1100","name":"Accounts Receivable (AR)","type":"asset","subtype":"receivable","parent_id":null,"is_system":true,"control_key":"AR_CONTROL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1105","tenant_id":"ten_softshore","code":"1105","name":"AR Control","type":"asset","subtype":"control","parent_id":null,"is_system":true,"control_key":"AR_SYSTEM_CONTROL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1200","tenant_id":"ten_softshore","code":"1200","name":"Inventory","type":"asset","subtype":"inventory","parent_id":null,"is_system":true,"control_key":"INVENTORY","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1300","tenant_id":"ten_softshore","code":"1300","name":"Prepaid Expenses","type":"asset","subtype":"current_asset","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1500","tenant_id":"ten_softshore","code":"1500","name":"Fixed Assets","type":"asset","subtype":"fixed_asset","parent_id":null,"is_system":true,"control_key":"FIXED_ASSETS","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_1510","tenant_id":"ten_softshore","code":"1510","name":"Accumulated Depreciation","type":"asset","subtype":"contra_asset","parent_id":null,"is_system":true,"control_key":"ACCUM_DEPRECIATION","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2000","tenant_id":"ten_softshore","code":"2000","name":"Accounts Payable (AP)","type":"liability","subtype":"payable","parent_id":null,"is_system":true,"control_key":"AP_CONTROL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2005","tenant_id":"ten_softshore","code":"2005","name":"AP Control","type":"liability","subtype":"control","parent_id":null,"is_system":true,"control_key":"AP_SYSTEM_CONTROL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2100","tenant_id":"ten_softshore","code":"2100","name":"VAT/Tax Payable","type":"liability","subtype":"tax","parent_id":null,"is_system":true,"control_key":"TAX_CONTROL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2105","tenant_id":"ten_softshore","code":"2105","name":"Tax Control","type":"liability","subtype":"control","parent_id":null,"is_system":true,"control_key":"TAX_SYSTEM_CONTROL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2200","tenant_id":"ten_softshore","code":"2200","name":"Salaries Payable","type":"liability","subtype":"current_liability","parent_id":null,"is_system":true,"control_key":"SALARIES_PAYABLE","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2300","tenant_id":"ten_softshore","code":"2300","name":"Deferred Revenue (Advance Billings)","type":"liability","subtype":"deferred","parent_id":null,"is_system":true,"control_key":"DEFERRED_REVENUE","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_2400","tenant_id":"ten_softshore","code":"2400","name":"Loans Payable","type":"liability","subtype":"long_term_liability","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_3000","tenant_id":"ten_softshore","code":"3000","name":"Owner\'s Capital","type":"equity","subtype":"capital","parent_id":null,"is_system":true,"control_key":"OWNERS_CAPITAL","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_3100","tenant_id":"ten_softshore","code":"3100","name":"Retained Earnings","type":"equity","subtype":"retained_earnings","parent_id":null,"is_system":true,"control_key":"RETAINED_EARNINGS","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_3200","tenant_id":"ten_softshore","code":"3200","name":"Drawings","type":"equity","subtype":"drawings","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_3900","tenant_id":"ten_softshore","code":"3900","name":"Opening Balance Equity","type":"equity","subtype":"system_equity","parent_id":null,"is_system":true,"control_key":"OPENING_BALANCE_EQUITY","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_4000","tenant_id":"ten_softshore","code":"4000","name":"Product Sales Revenue","type":"revenue","subtype":"operating_revenue","parent_id":null,"is_system":true,"control_key":"PRODUCT_REVENUE","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_4100","tenant_id":"ten_softshore","code":"4100","name":"Service Revenue","type":"revenue","subtype":"operating_revenue","parent_id":null,"is_system":true,"control_key":"SERVICE_REVENUE","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_4200","tenant_id":"ten_softshore","code":"4200","name":"Discounts Given","type":"revenue","subtype":"contra_revenue","parent_id":null,"is_system":true,"control_key":"DISCOUNTS_GIVEN","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_4300","tenant_id":"ten_softshore","code":"4300","name":"Other Income","type":"revenue","subtype":"other_income","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5000","tenant_id":"ten_softshore","code":"5000","name":"Cost of Goods Sold (COGS)","type":"expense","subtype":"cogs","parent_id":null,"is_system":true,"control_key":"COGS","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5100","tenant_id":"ten_softshore","code":"5100","name":"Salaries & Wages","type":"expense","subtype":"operating_expense","parent_id":null,"is_system":true,"control_key":"SALARIES_EXPENSE","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5200","tenant_id":"ten_softshore","code":"5200","name":"Rent Expense","type":"expense","subtype":"operating_expense","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5300","tenant_id":"ten_softshore","code":"5300","name":"Utilities","type":"expense","subtype":"operating_expense","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5400","tenant_id":"ten_softshore","code":"5400","name":"Marketing","type":"expense","subtype":"operating_expense","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5500","tenant_id":"ten_softshore","code":"5500","name":"Bank Charges","type":"expense","subtype":"financial_expense","parent_id":null,"is_system":true,"control_key":"BANK_CHARGES","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5600","tenant_id":"ten_softshore","code":"5600","name":"Depreciation","type":"expense","subtype":"non_cash_expense","parent_id":null,"is_system":true,"control_key":"DEPRECIATION_EXPENSE","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5700","tenant_id":"ten_softshore","code":"5700","name":"Miscellaneous Expense","type":"expense","subtype":"operating_expense","parent_id":null,"is_system":false,"control_key":null,"opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"},{"id":"acc_ten_softshore_5900","tenant_id":"ten_softshore","code":"5900","name":"Rounding Adjustment","type":"expense","subtype":"system_adjustment","parent_id":null,"is_system":true,"control_key":"ROUNDING_ADJUSTMENT","opening_debit":0,"opening_credit":0,"status":"active","created_at":"2026-10-05T15:13:24.367Z"}],"fiscal_years":[{"id":"fy_ten_softshore_2026","tenant_id":"ten_softshore","name":"FY 2026 (Jan - Dec)","start_date":"2026-01-01","end_date":"2026-12-31","status":"open","closed_at":null}],"accounting_periods":[{"id":"prd_ten_softshore_2026_01","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":1,"year":2026,"name":"Jan 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_02","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":2,"year":2026,"name":"Feb 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_03","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":3,"year":2026,"name":"Mar 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_04","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":4,"year":2026,"name":"Apr 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_05","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":5,"year":2026,"name":"May 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_06","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":6,"year":2026,"name":"Jun 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_07","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":7,"year":2026,"name":"Jul 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_08","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":8,"year":2026,"name":"Aug 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_09","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":9,"year":2026,"name":"Sep 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_10","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":10,"year":2026,"name":"Oct 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_11","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":11,"year":2026,"name":"Nov 2026","status":"open","unlock_audit_note":null},{"id":"prd_ten_softshore_2026_12","tenant_id":"ten_softshore","fiscal_year_id":"fy_ten_softshore_2026","month":12,"year":2026,"name":"Dec 2026","status":"open","unlock_audit_note":null}],"customers":[{"id":"cust_1","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","code":"CUST-1001","name":"Square Pharmaceuticals PLC","company":"Square Pharmaceuticals PLC","email":"mehedi@squarepharma.com.bd","phone":"+8801710328545","address":"Square Centre, 48 Mohakhali C/A, Dhaka-1212","tax_id":"BIN-000112233-0101","tags":["Enterprise","ERP-Cloud","VIP"],"credit_limit":500000,"advance_balance":0,"payment_score":96,"status":"active","notes":"Flagship enterprise subscriber on dedicated cloud cluster.","created_at":"2026-01-20T10:00:00.000Z"},{"id":"cust_2","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","code":"CUST-1002","name":"BracNet Digital Services","company":"BracNet Ltd.","email":"accounts@bracnet.net","phone":"+8801714009988","address":"Gulshan-1, Dhaka-1212","tax_id":"BIN-000445566-0102","tags":["Quarterly","SaaS"],"credit_limit":300000,"advance_balance":25000,"payment_score":88,"status":"active","notes":"Prefers SSLCommerz or Bank EFT.","created_at":"2026-02-05T10:00:00.000Z"},{"id":"cust_3","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_ctg","code":"CUST-1003","name":"Karnafuli Port Logistics Ltd.","company":"Karnafuli Port Logistics","email":"finance@karnafulilogistics.com","phone":"+8801811334455","address":"Agrabad C/A, Chattogram","tax_id":"BIN-000778899-0301","tags":["Chattogram","Overdue-Watch"],"credit_limit":200000,"advance_balance":0,"payment_score":64,"status":"active","notes":"Follow up 3 days before due via SMS.","created_at":"2026-03-10T10:00:00.000Z"},{"id":"cust_4","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_syl","code":"CUST-1004","name":"Sylhet Tea Valley Exports","company":"Sylhet Tea Valley","email":"info@sylhetteavalley.com","phone":"+8801912667788","address":"Airport Road, Sylhet","tax_id":"BIN-000991122-0401","tags":["SME","Monthly"],"credit_limit":150000,"advance_balance":0,"payment_score":92,"status":"active","notes":"Uses bKash merchant auto-pay.","created_at":"2026-04-12T10:00:00.000Z"},{"id":"cust_5","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","code":"CUST-1005","name":"CWIS-FSM Support Cell, Department of Public Health Engineering","company":"Department of Public Health Engineering (DPHE)","email":"cwis.fsm@dphe.gov.bd","phone":"+8801710328545","address":"DPHE Bhaban, (9th floor), 14 Shaheed Captain Mansur Ali Soroni, Kakrail, Dhaka- 1000","tax_id":"BIN-DPHE-GOV-1000","tags":["Government","Monthly-Maintenance"],"credit_limit":500000,"advance_balance":0,"payment_score":98,"status":"active","notes":"Monthly Website Development & Maintenance contract.","created_at":"2026-05-01T10:00:00.000Z"}],"leads":[{"id":"lead_1","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","name":"Tariqul Islam","company":"Pran-RFL Agro Supply Chain","email":"tariq@pranrfl.com","phone":"+8801713445566","source":"Inbound Demo Request","stage":"Qualified","estimated_value":180000,"probability":80,"assigned_to":"Rafiq Hasan","interested_product_id":"prod_1","interested_product_ids":["prod_1","prod_2"],"notes":"Technical evaluation passed. Ready for 1-click Customer + Subscription conversion!","converted_customer_id":null,"created_at":"2026-09-25T10:00:00.000Z"},{"id":"lead_2","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","name":"Samia Karim","company":"Chaldal Grocery Fulfillment","email":"samia@chaldal.com","phone":"+8801844556677","source":"LinkedIn Enterprise","stage":"Contacted","estimated_value":95000,"probability":50,"assigned_to":"Nusrat Jahan","interested_product_id":"prod_2","interested_product_ids":["prod_2","prod_4"],"notes":"Demo scheduled for Thursday with CFO and CTO.","converted_customer_id":null,"created_at":"2026-09-28T14:00:00.000Z"},{"id":"lead_3","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_ctg","name":"Mahbubur Chowdhury","company":"BSRM Steel Distribution","email":"mahbub@bsrm.com","phone":"+8801711223399","source":"Referral","stage":"New","estimated_value":240000,"probability":30,"assigned_to":"Rafiq Hasan","interested_product_id":"prod_1","interested_product_ids":["prod_1","prod_3"],"notes":"Needs 12-branch cost center accounting & custom VAT report.","converted_customer_id":null,"created_at":"2026-10-02T09:15:00.000Z"},{"id":"lead_4","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","name":"Mehedi Alam","company":"Square Pharmaceuticals PLC","email":"mehedi@squarepharma.com.bd","phone":"+8801710328545","source":"Direct Enterprise","stage":"Won","estimated_value":540000,"probability":100,"assigned_to":"Nusrat Jahan","interested_product_id":"prod_1","interested_product_ids":["prod_1","prod_2"],"notes":"Converted to active enterprise subscription.","converted_customer_id":"cust_1","created_at":"2026-01-15T11:00:00.000Z"}],"crm_activities":[{"id":"act_4","tenant_id":"ten_softshore","entity_type":"customer","entity_id":"cust_1","customer_ids":["cust_1","cust_2"],"customer_names":["Square Pharmaceuticals PLC","BracNet Digital Services"],"activity_type":"support_request","priority":"Urgent","source":"Customer Support Request","subject":"Dedicated Kubernetes SSL Renewal & Multi-Branch API Webhook Sync Request","details":"Customer support request raised for Square Pharmaceuticals PLC & BracNet Digital Services: Need SSL certificate rotation and webhook payload verification before Monday.","due_date":"2026-10-06","is_completed":false,"assigned_to_all_employees":true,"assigned_employee_ids":["usr_admin","usr_manager","usr_exec","usr_accountant","usr_cs_exec","usr_support_eng"],"assigned_employees":["Tanvir Rahman (Company Admin)","Nusrat Jahan (Branch Manager)","Rafiq Hasan (Sales Executive)","Farhana Akter FCA (Chief Accountant)","Sadia Islam (Customer Success Lead)","Kamrul Hasan (Cloud Support Engineer)"],"assigned_to":"All Company Employees (6): Tanvir Rahman, Nusrat Jahan, Rafiq Hasan, Farhana Akter FCA, Sadia Islam, Kamrul Hasan","created_by":"Mehedi Alam (Customer Portal)","created_at":"2026-10-05T08:30:00.000Z"},{"id":"act_1","tenant_id":"ten_softshore","entity_type":"customer","entity_id":"cust_1","customer_ids":["cust_1"],"customer_names":["Square Pharmaceuticals PLC"],"activity_type":"meeting","priority":"High","source":"Internal CRM","subject":"Architecture & GL Integration Walkthrough with CFO","details":"Demonstrated automatic double-entry GL posting and BGTel SMS alerts. CFO approved budget.","due_date":"2026-10-05","is_completed":true,"assigned_to_all_employees":false,"assigned_employee_ids":["usr_exec","usr_cs_exec"],"assigned_employees":["Rafiq Hasan (Sales Executive)","Sadia Islam (Customer Success Lead)"],"assigned_to":"Rafiq Hasan (Sales Executive), Sadia Islam (Customer Success Lead)","created_by":"Rafiq Hasan","created_at":"2026-10-01T11:30:00.000Z"},{"id":"act_2","tenant_id":"ten_softshore","entity_type":"customer","entity_id":"cust_3","customer_ids":["cust_3","cust_4"],"customer_names":["Karnafuli Port Logistics Ltd.","Sylhet Tea Valley Exports"],"activity_type":"task","priority":"High","source":"Internal CRM","subject":"Follow up with regional accounts regarding October subscription invoices","details":"Confirm bank wire remittance reference numbers and bKash auto-debit settlement.","due_date":"2026-10-06","is_completed":false,"assigned_to_all_employees":false,"assigned_employee_ids":["usr_exec","usr_manager","usr_accountant"],"assigned_employees":["Rafiq Hasan (Sales Executive)","Nusrat Jahan (Branch Manager)","Farhana Akter FCA (Chief Accountant)"],"assigned_to":"Rafiq Hasan (Sales Executive), Nusrat Jahan (Branch Manager), Farhana Akter FCA (Chief Accountant)","created_by":"Nusrat Jahan","created_at":"2026-10-03T09:00:00.000Z"},{"id":"act_3","tenant_id":"ten_softshore","entity_type":"customer","entity_id":"cust_2","customer_ids":["cust_2"],"customer_names":["BracNet Digital Services"],"activity_type":"call","priority":"Normal","source":"Internal CRM","subject":"Follow-up call on Quotation QT-SS-2026-101 & Quarterly Renewal","details":"Sent multi-branch SLA terms and Musak-6.3 VAT schedule.","due_date":"2026-10-07","is_completed":false,"assigned_to_all_employees":false,"assigned_employee_ids":["usr_manager","usr_support_eng"],"assigned_employees":["Nusrat Jahan (Branch Manager)","Kamrul Hasan (Cloud Support Engineer)"],"assigned_to":"Nusrat Jahan (Branch Manager), Kamrul Hasan (Cloud Support Engineer)","created_by":"Nusrat Jahan","created_at":"2026-10-04T10:00:00.000Z"}],"products":[{"id":"prod_1","tenant_id":"ten_softshore","type":"service","sku":"SAAS-ENT-CLOUD","name":"Enterprise Cloud ERP & Billing Suite","category":"SaaS Subscription","description":"Dedicated multi-branch ERP, CRM & Accounting cloud node with 99.9% SLA.","price":45000,"cost":0,"tax_rate":15,"unit":"month","track_inventory":false,"stock_qty":0,"low_stock_alert":0,"revenue_account_code":"4100","cogs_account_code":"5000","status":"active"},{"id":"prod_2","tenant_id":"ten_softshore","type":"service","sku":"SVC-DED-HOST","name":"Managed Kubernetes & DB Cluster","category":"Cloud Infrastructure","description":"Automated daily backups, SSL, load balancer & 24/7 DevOps monitoring.","price":25000,"cost":0,"tax_rate":15,"unit":"month","track_inventory":false,"stock_qty":0,"low_stock_alert":0,"revenue_account_code":"4100","cogs_account_code":"5000","status":"active"},{"id":"prod_3","tenant_id":"ten_softshore","type":"product","sku":"HW-POS-TERM","name":"Smart Android POS & Barcode Terminal","category":"Hardware","description":"NFC + Thermal Receipt Printer terminal for retail branch billing.","price":18500,"cost":11000,"tax_rate":15,"unit":"device","track_inventory":true,"stock_qty":24,"low_stock_alert":10,"revenue_account_code":"4000","cogs_account_code":"5000","status":"active"},{"id":"prod_4","tenant_id":"ten_softshore","type":"service","sku":"SVC-SMS-BUNDLE","name":"BGTel Masking SMS Enterprise Pack (50k)","category":"Communication Add-on","description":"50,000 transactional SMS credits with custom Sender ID.","price":15000,"cost":9000,"tax_rate":15,"unit":"pack","track_inventory":false,"stock_qty":0,"low_stock_alert":0,"revenue_account_code":"4100","cogs_account_code":"5000","status":"active"},{"id":"prod_5","tenant_id":"ten_softshore","type":"product","sku":"HW-BIO-ATT","name":"Biometric Cloud Attendance Gateway","category":"Hardware","description":"Face + Fingerprint cloud device synced with Payroll module.","price":12000,"cost":7500,"tax_rate":15,"unit":"unit","track_inventory":true,"stock_qty":4,"low_stock_alert":5,"revenue_account_code":"4000","cogs_account_code":"5000","status":"active"}],"subscriptions":[{"id":"sub_1","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","customer_id":"cust_1","product_id":"prod_1","plan_name":"Enterprise Cloud ERP & Billing Suite (Monthly)","cycle":"monthly","custom_days":null,"start_date":"2026-01-01","next_invoice_date":"2026-10-05","qty":1,"unit_price":45000,"discount_type":"percent","discount_value":0,"tax_rate":15,"auto_renew":true,"is_deferred_revenue":false,"deferred_months":1,"status":"active","created_at":"2026-01-01T10:00:00.000Z"},{"id":"sub_2","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","customer_id":"cust_2","product_id":"prod_2","plan_name":"Managed Kubernetes & DB Cluster (Quarterly)","cycle":"quarterly","custom_days":null,"start_date":"2026-02-01","next_invoice_date":"2026-11-01","qty":3,"unit_price":25000,"discount_type":"percent","discount_value":10,"tax_rate":15,"auto_renew":true,"is_deferred_revenue":true,"deferred_months":3,"status":"active","created_at":"2026-02-01T10:00:00.000Z"},{"id":"sub_3","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","product_id":"prod_4","plan_name":"BGTel Masking SMS Enterprise Pack (Monthly)","cycle":"monthly","custom_days":null,"start_date":"2026-03-01","next_invoice_date":"2026-10-04","qty":2,"unit_price":15000,"discount_type":"fixed","discount_value":1000,"tax_rate":15,"auto_renew":true,"is_deferred_revenue":false,"deferred_months":1,"status":"active","created_at":"2026-03-01T10:00:00.000Z"},{"id":"sub_4","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_syl","customer_id":"cust_4","product_id":"prod_2","plan_name":"Managed Cloud Node (Bi-Weekly Sprint Billing)","cycle":"bi_weekly","custom_days":14,"start_date":"2026-05-01","next_invoice_date":"2026-10-10","qty":1,"unit_price":14000,"discount_type":"percent","discount_value":0,"tax_rate":15,"auto_renew":true,"is_deferred_revenue":false,"deferred_months":1,"status":"active","created_at":"2026-05-01T10:00:00.000Z"}],"quotations":[{"id":"qt_1","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","customer_id":"cust_1","lead_id":"lead_1","quote_number":"QT-SS-2026-101","issue_date":"2026-10-01","expiry_date":"2026-10-15","currency":"BDT","items":[{"product_id":"prod_1","description":"Enterprise Cloud ERP & Billing Suite (Annual License)","qty":1,"unit_price":45000,"tax_rate":15,"account_code":"4100"},{"product_id":"prod_3","description":"Smart Android POS & Barcode Terminal (5 Devices)","qty":5,"unit_price":18500,"tax_rate":15,"account_code":"4000"}],"subtotal":137500,"discount":5000,"tax":19875,"total":152375,"status":"Sent","converted_invoice_id":null,"notes":"Includes free on-site branch setup and COA migration.","created_at":"2026-10-01T10:00:00.000Z"}],"invoices":[{"id":"inv_cwis","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","customer_id":"cust_5","subscription_id":null,"number":"26092501510","date":"2026-09-27","due_date":"2026-10-12","status":"Sent","currency":"BDT","exchange_rate":1,"previous_due":0,"subtotal":14000,"discount":0,"tax":0,"rounding_adjustment":0,"total":14000,"paid_amount":0,"credited_amount":0,"notes":"1. All the amounts are in Bangladeshi Taka | 2. The amount is VAT & Tax Included","terms":"Payment To: Softshore Technology, Acc. No: 2052820500001, BRAC Bank Limited, Gulshan Branch, Dhaka (SWIFT: BRAKBDDH)","je_id":"je_ten_softshore_1791213204367_191"},{"id":"inv_1001","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","customer_id":"cust_1","subscription_id":"sub_1","number":"INV-SS-2026-1001","date":"2026-09-05","due_date":"2026-09-20","status":"Paid","currency":"BDT","exchange_rate":1,"subtotal":70000,"discount":0,"tax":10500,"rounding_adjustment":0,"total":80500,"paid_amount":80500,"credited_amount":0,"notes":"Thank you for your business with SoftShore Cloud Solutions.","terms":"Net 15 Days. Late payments subject to automated dunning reminders.","je_id":"je_ten_softshore_1791213204367_426"},{"id":"inv_1002","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","customer_id":"cust_2","subscription_id":"sub_2","number":"INV-SS-2026-1002","date":"2026-09-15","due_date":"2026-10-08","status":"Partially Paid","currency":"BDT","exchange_rate":1,"subtotal":93500,"discount":3500,"tax":13500,"rounding_adjustment":0,"total":103500,"paid_amount":50000,"credited_amount":0,"notes":"Partial payment of BDT 50,000 received via SSLCommerz.","terms":"Balance due by 08 Oct 2026.","je_id":"je_ten_softshore_1791213204367_679"},{"id":"inv_1003","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","subscription_id":"sub_3","number":"INV-SS-2026-1003","date":"2026-09-01","due_date":"2026-09-22","status":"Overdue","currency":"BDT","exchange_rate":1,"subtotal":30000,"discount":1000,"tax":4350,"rounding_adjustment":0,"total":33350,"paid_amount":0,"credited_amount":0,"notes":"Overdue reminder dispatched via BGTel SMS & SMTP.","terms":"Immediate payment requested.","je_id":"je_ten_softshore_1791213204367_453"},{"id":"inv_1004","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_syl","customer_id":"cust_4","subscription_id":"sub_4","number":"INV-SS-2026-1004","date":"2026-10-01","due_date":"2026-10-07","status":"Sent","currency":"BDT","exchange_rate":1,"subtotal":26000,"discount":0,"tax":3900,"rounding_adjustment":0,"total":29900,"paid_amount":0,"credited_amount":0,"notes":"Due in 3 days — eligible for Pre-Due Reminder Cron.","terms":"Net 7 Days.","je_id":"je_ten_softshore_1791213204367_639"}],"invoice_items":[{"id":"item_cwis_1","invoice_id":"inv_cwis","product_id":"prod_1","description":"Monthly Website Development & Maintenance (01-August-2026 to 31-August-2026)","qty":1,"unit_price":14000,"discount":0,"tax_rate":0,"tax_amount":0,"total":14000,"account_code":"4100"},{"id":"item_1001_1","invoice_id":"inv_1001","product_id":"prod_1","description":"Enterprise Cloud ERP & Billing Suite - Sep 2026","qty":1,"unit_price":45000,"discount":0,"tax_rate":15,"tax_amount":6750,"total":51750,"account_code":"4100"},{"id":"item_1001_2","invoice_id":"inv_1001","product_id":"prod_2","description":"Managed Kubernetes & DB Cluster - Sep 2026","qty":1,"unit_price":25000,"discount":0,"tax_rate":15,"tax_amount":3750,"total":28750,"account_code":"4100"},{"id":"item_1002_1","invoice_id":"inv_1002","product_id":"prod_2","description":"Managed Kubernetes & DB Cluster (3 Nodes)","qty":3,"unit_price":25000,"discount":3500,"tax_rate":15,"tax_amount":10725,"total":82225,"account_code":"4100"},{"id":"item_1002_2","invoice_id":"inv_1002","product_id":"prod_3","description":"Smart Android POS & Barcode Terminal","qty":1,"unit_price":18500,"discount":0,"tax_rate":15,"tax_amount":2775,"total":21275,"account_code":"4000"},{"id":"item_1003_1","invoice_id":"inv_1003","product_id":"prod_4","description":"BGTel Masking SMS Enterprise Pack (2x 50k)","qty":2,"unit_price":15000,"discount":1000,"tax_rate":15,"tax_amount":4350,"total":33350,"account_code":"4100"},{"id":"item_1004_1","invoice_id":"inv_1004","product_id":"prod_2","description":"Managed Cloud Node (Bi-Weekly Sprint)","qty":1,"unit_price":14000,"discount":0,"tax_rate":15,"tax_amount":2100,"total":16100,"account_code":"4100"},{"id":"item_1004_2","invoice_id":"inv_1004","product_id":"prod_5","description":"Biometric Cloud Attendance Gateway","qty":1,"unit_price":12000,"discount":0,"tax_rate":15,"tax_amount":1800,"total":13800,"account_code":"4000"}],"payments":[{"id":"pmt_501","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","invoice_id":"inv_1001","customer_id":"cust_1","receipt_number":"RCP-SS-2026-501","amount":80500,"bank_charge":0,"method":"Bank Transfer","deposit_account_code":"1010","reference":"CITY-EFT-9928172","is_advance":false,"paid_at":"2026-09-18T11:20:00.000Z","status":"Completed","je_id":"je_ten_softshore_1791213204367_953"},{"id":"pmt_502","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","invoice_id":"inv_1002","customer_id":"cust_2","receipt_number":"RCP-SS-2026-502","amount":50000,"bank_charge":750,"method":"SSLCommerz","deposit_account_code":"1010","reference":"SSLCZ-TXN-884120","is_advance":false,"paid_at":"2026-09-25T15:40:00.000Z","status":"Completed","je_id":"je_ten_softshore_1791213204367_68"}],"credit_notes":[],"vendors":[{"id":"vnd_1","tenant_id":"ten_softshore","name":"BDCom Data Center & Colocation PLC","email":"billing@bdcom.com","phone":"+8801711002233","tax_id":"BIN-00551122-0101","category":"Cloud & Bandwidth","balance_payable":35000},{"id":"vnd_2","tenant_id":"ten_softshore","name":"Ventura Properties Ltd.","email":"rent@venturabd.com","phone":"+8801711004455","tax_id":"BIN-00667788-0101","category":"Office Rent","balance_payable":0}],"expenses_bills":[{"id":"bill_1","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","vendor_id":"vnd_2","voucher_number":"EXP-2026-001","category":"expense","expense_account_code":"5200","payment_account_code":"1010","date":"2026-09-05","due_date":"2026-09-05","amount":45000,"tax_amount":0,"paid_amount":45000,"status":"Paid","description":"September 2026 Head Office Rent (Banani-11)","je_id":"je_ten_softshore_1791213204367_567"},{"id":"bill_2","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","vendor_id":"vnd_1","voucher_number":"BILL-2026-002","category":"expense","expense_account_code":"5300","payment_account_code":"2000","date":"2026-09-10","due_date":"2026-09-25","amount":35000,"tax_amount":0,"paid_amount":0,"status":"Unpaid","description":"Dedicated Fiber & BGP Upstream Bill - Sep 2026","je_id":"je_ten_softshore_1791213204367_46"}],"fixed_assets":[{"id":"fa_1","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","asset_code":"FA-SRV-001","name":"Dell PowerEdge R750 Cloud Server Rack","purchase_date":"2026-01-05","purchase_cost":300000,"salvage_value":30000,"useful_life_months":60,"accumulated_depreciation":4500,"last_depreciation_date":"2026-09-30","status":"Active"},{"id":"fa_2","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","asset_code":"FA-MAC-002","name":"Apple MacBook Pro M3 Fleet (Engineering)","purchase_date":"2026-01-10","purchase_cost":150000,"salvage_value":15000,"useful_life_months":36,"accumulated_depreciation":3750,"last_depreciation_date":"2026-09-30","status":"Active"}],"bank_statements":[{"id":"bs_1","tenant_id":"ten_softshore","date":"2026-09-18","description":"CITY EFT INWARD - SQUARE PHARMA (INV-SS-2026-1001)","reference":"CITY-EFT-9928172","amount":80500,"type":"credit","matched_je_number":"JE-2026-1007","status":"Matched"},{"id":"bs_2","tenant_id":"ten_softshore","date":"2026-09-25","description":"SSLCOMMERZ SETTLEMENT NET OF MDR (INV-SS-2026-1002)","reference":"SSLCZ-TXN-884120","amount":49250,"type":"credit","matched_je_number":"JE-2026-1008","status":"Matched"},{"id":"bs_3","tenant_id":"ten_softshore","date":"2026-10-03","description":"CITY BANK QUARTERLY ACCOUNT MAINTENANCE & EXCISE DUTY","reference":"BNK-CHG-OCT26","amount":1150,"type":"debit","matched_je_number":null,"status":"Unreconciled"}],"recurring_journals":[{"id":"rje_1","tenant_id":"ten_softshore","name":"Monthly Office Rent Accrual","frequency":"Monthly","next_run_date":"2026-11-01","debit_account_code":"5200","credit_account_code":"1010","amount":45000,"narration":"Automated Monthly Office Rent Posting","status":"active"},{"id":"rje_2","tenant_id":"ten_softshore","name":"Monthly Fixed Asset Depreciation","frequency":"Monthly","next_run_date":"2026-10-31","debit_account_code":"5600","credit_account_code":"1510","amount":8250,"narration":"Automated Monthly Straight-Line Depreciation","status":"active"}],"journal_entries":[{"id":"je_ten_softshore_1791213204367_477","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1001","date":"2026-01-01","narration":"Opening Balance Equity & Capital Injection (FY 2026)","source_module":"Onboarding","event_type":"OPENING_BALANCE","reference_id":"OB-2026-001","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":2185000,"total_credit":2185000,"created_by":"Farhana Akter FCA","approved_by":"Farhana Akter FCA","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_612","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1002","date":"2026-09-01","narration":"Purchase of 30 Smart POS Terminals & Biometric Gateways for Inventory","source_module":"Inventory & Purchasing","event_type":"INVENTORY_PURCHASE","reference_id":"PO-2026-001","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":330000,"total_credit":330000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_191","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1003","date":"2026-09-27","narration":"Invoice 26092501510 issued (Credit Sale)","source_module":"Invoicing","event_type":"INVOICE_ISSUED","reference_id":"26092501510","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":14000,"total_credit":14000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_426","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1004","date":"2026-09-05","narration":"Invoice INV-SS-2026-1001 issued (Credit Sale)","source_module":"Invoicing","event_type":"INVOICE_ISSUED","reference_id":"INV-SS-2026-1001","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":80500,"total_credit":80500,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_679","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1005","date":"2026-09-15","narration":"Invoice INV-SS-2026-1002 issued (Credit Sale)","source_module":"Invoicing","event_type":"INVOICE_ISSUED","reference_id":"INV-SS-2026-1002","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":107000,"total_credit":107000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_453","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_ctg","je_number":"JE-2026-1006","date":"2026-09-01","narration":"Invoice INV-SS-2026-1003 issued (Credit Sale)","source_module":"Invoicing","event_type":"INVOICE_ISSUED","reference_id":"INV-SS-2026-1003","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":34350,"total_credit":34350,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_639","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_syl","je_number":"JE-2026-1007","date":"2026-10-01","narration":"Invoice INV-SS-2026-1004 issued (Credit Sale)","source_module":"Invoicing","event_type":"INVOICE_ISSUED","reference_id":"INV-SS-2026-1004","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":29900,"total_credit":29900,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_253","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1008","date":"2026-09-15","narration":"COGS recognition for Invoice INV-SS-2026-1002","source_module":"Inventory & COGS","event_type":"COGS_ON_SALE","reference_id":"INV-SS-2026-1002","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":11000,"total_credit":11000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_953","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1009","date":"2026-09-18","narration":"Payment received (Bank Transfer) - Ref RCP-SS-2026-501","source_module":"Payments","event_type":"CUSTOMER_PAYMENT","reference_id":"RCP-SS-2026-501","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":80500,"total_credit":80500,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_68","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1010","date":"2026-09-25","narration":"Payment received (SSLCommerz) - Ref RCP-SS-2026-502","source_module":"Payments","event_type":"PARTIAL_PAYMENT","reference_id":"RCP-SS-2026-502","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":50000,"total_credit":50000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_567","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1011","date":"2026-09-05","narration":"September 2026 Head Office Rent (Banani-11)","source_module":"Expenses & AP","event_type":"EXPENSE_ENTRY","reference_id":"EXP-2026-001","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":45000,"total_credit":45000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_46","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1012","date":"2026-09-10","narration":"Dedicated Fiber & BGP Upstream Bill - Sep 2026","source_module":"Expenses & AP","event_type":"EXPENSE_ENTRY","reference_id":"BILL-2026-002","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":35000,"total_credit":35000,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"je_ten_softshore_1791213204367_561","tenant_id":"ten_softshore","branch_id":"br_ten_softshore_hq","je_number":"JE-2026-1013","date":"2026-09-30","narration":"Monthly Straight-Line Depreciation (Server Rack & MacBooks)","source_module":"Fixed Assets","event_type":"DEPRECIATION","reference_id":"DEP-2026-09","status":"Posted","reversal_of_je_id":null,"reversed_by_je_id":null,"total_debit":8250,"total_credit":8250,"created_by":"Silent Auto-GL Engine","approved_by":"Silent Auto-GL Engine","posted_at":"2026-10-05T15:13:24.367Z"}],"journal_lines":[{"id":"jl_je_ten_softshore_1791213204367_477_1","je_id":"je_ten_softshore_1791213204367_477","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","account_name":"Cash at Bank","debit":1500000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Opening Cash at Bank (City Bank PLC)"},{"id":"jl_je_ten_softshore_1791213204367_477_2","je_id":"je_ten_softshore_1791213204367_477","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1000","account_code":"1000","account_name":"Cash on Hand","debit":150000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Opening Petty Cash on Hand"},{"id":"jl_je_ten_softshore_1791213204367_477_3","je_id":"je_ten_softshore_1791213204367_477","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1020","account_code":"1020","account_name":"Mobile Wallet (bKash/Nagad)","debit":85000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Opening bKash Merchant Wallet Balance"},{"id":"jl_je_ten_softshore_1791213204367_477_4","je_id":"je_ten_softshore_1791213204367_477","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1500","account_code":"1500","account_name":"Fixed Assets","debit":450000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Server Racks & Office MacBooks"},{"id":"jl_je_ten_softshore_1791213204367_477_5","je_id":"je_ten_softshore_1791213204367_477","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_3000","account_code":"3000","account_name":"Owner\'s Capital","debit":0,"credit":2185000,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Owner\'s Capital Seed Investment"},{"id":"jl_je_ten_softshore_1791213204367_612_1","je_id":"je_ten_softshore_1791213204367_612","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1200","account_code":"1200","account_name":"Inventory","debit":330000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Purchase of 30 Smart POS Terminals & Biometric Gateways for Inventory"},{"id":"jl_je_ten_softshore_1791213204367_612_2","je_id":"je_ten_softshore_1791213204367_612","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","account_name":"Cash at Bank","debit":0,"credit":330000,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Purchase of 30 Smart POS Terminals & Biometric Gateways for Inventory"},{"id":"jl_je_ten_softshore_1791213204367_191_1","je_id":"je_ten_softshore_1791213204367_191","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":14000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_5","vendor_id":null,"tax_code":null,"memo":"AR for Invoice 26092501510"},{"id":"jl_je_ten_softshore_1791213204367_191_2","je_id":"je_ten_softshore_1791213204367_191","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","account_name":"Service Revenue","debit":0,"credit":14000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_5","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice 26092501510"},{"id":"jl_je_ten_softshore_1791213204367_426_1","je_id":"je_ten_softshore_1791213204367_426","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":80500,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","vendor_id":null,"tax_code":null,"memo":"AR for Invoice INV-SS-2026-1001"},{"id":"jl_je_ten_softshore_1791213204367_426_2","je_id":"je_ten_softshore_1791213204367_426","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","account_name":"Service Revenue","debit":0,"credit":70000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice INV-SS-2026-1001"},{"id":"jl_je_ten_softshore_1791213204367_426_3","je_id":"je_ten_softshore_1791213204367_426","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","account_name":"VAT/Tax Payable","debit":0,"credit":10500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","vendor_id":null,"tax_code":"VAT-OUTPUT","memo":"Output VAT collected on Invoice INV-SS-2026-1001"},{"id":"jl_je_ten_softshore_1791213204367_679_1","je_id":"je_ten_softshore_1791213204367_679","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":103500,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"AR for Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_679_2","je_id":"je_ten_softshore_1791213204367_679","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4200","account_code":"4200","account_name":"Discounts Given","debit":3500,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"Discount given on Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_679_3","je_id":"je_ten_softshore_1791213204367_679","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4000","account_code":"4000","account_name":"Product Sales Revenue","debit":0,"credit":18500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_679_4","je_id":"je_ten_softshore_1791213204367_679","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","account_name":"Service Revenue","debit":0,"credit":75000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_679_5","je_id":"je_ten_softshore_1791213204367_679","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","account_name":"VAT/Tax Payable","debit":0,"credit":13500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":"VAT-OUTPUT","memo":"Output VAT collected on Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_453_1","je_id":"je_ten_softshore_1791213204367_453","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":33350,"credit":0,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","vendor_id":null,"tax_code":null,"memo":"AR for Invoice INV-SS-2026-1003"},{"id":"jl_je_ten_softshore_1791213204367_453_2","je_id":"je_ten_softshore_1791213204367_453","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4200","account_code":"4200","account_name":"Discounts Given","debit":1000,"credit":0,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","vendor_id":null,"tax_code":null,"memo":"Discount given on Invoice INV-SS-2026-1003"},{"id":"jl_je_ten_softshore_1791213204367_453_3","je_id":"je_ten_softshore_1791213204367_453","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","account_name":"Service Revenue","debit":0,"credit":30000,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice INV-SS-2026-1003"},{"id":"jl_je_ten_softshore_1791213204367_453_4","je_id":"je_ten_softshore_1791213204367_453","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","account_name":"VAT/Tax Payable","debit":0,"credit":4350,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","vendor_id":null,"tax_code":"VAT-OUTPUT","memo":"Output VAT collected on Invoice INV-SS-2026-1003"},{"id":"jl_je_ten_softshore_1791213204367_639_1","je_id":"je_ten_softshore_1791213204367_639","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":29900,"credit":0,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","vendor_id":null,"tax_code":null,"memo":"AR for Invoice INV-SS-2026-1004"},{"id":"jl_je_ten_softshore_1791213204367_639_2","je_id":"je_ten_softshore_1791213204367_639","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4000","account_code":"4000","account_name":"Product Sales Revenue","debit":0,"credit":12000,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice INV-SS-2026-1004"},{"id":"jl_je_ten_softshore_1791213204367_639_3","je_id":"je_ten_softshore_1791213204367_639","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","account_name":"Service Revenue","debit":0,"credit":14000,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","vendor_id":null,"tax_code":null,"memo":"Revenue for Invoice INV-SS-2026-1004"},{"id":"jl_je_ten_softshore_1791213204367_639_4","je_id":"je_ten_softshore_1791213204367_639","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","account_name":"VAT/Tax Payable","debit":0,"credit":3900,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","vendor_id":null,"tax_code":"VAT-OUTPUT","memo":"Output VAT collected on Invoice INV-SS-2026-1004"},{"id":"jl_je_ten_softshore_1791213204367_253_1","je_id":"je_ten_softshore_1791213204367_253","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5000","account_code":"5000","account_name":"Cost of Goods Sold (COGS)","debit":11000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"COGS recognition for Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_253_2","je_id":"je_ten_softshore_1791213204367_253","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1200","account_code":"1200","account_name":"Inventory","debit":0,"credit":11000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"COGS recognition for Invoice INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_953_1","je_id":"je_ten_softshore_1791213204367_953","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","account_name":"Cash at Bank","debit":80500,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","vendor_id":null,"tax_code":null,"memo":"Deposit to 1010 (Bank Transfer)"},{"id":"jl_je_ten_softshore_1791213204367_953_2","je_id":"je_ten_softshore_1791213204367_953","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":0,"credit":80500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","vendor_id":null,"tax_code":null,"memo":"AR settlement for INV-SS-2026-1001"},{"id":"jl_je_ten_softshore_1791213204367_68_1","je_id":"je_ten_softshore_1791213204367_68","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","account_name":"Cash at Bank","debit":49250,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"Deposit to 1010 (SSLCommerz)"},{"id":"jl_je_ten_softshore_1791213204367_68_2","je_id":"je_ten_softshore_1791213204367_68","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5500","account_code":"5500","account_name":"Bank Charges","debit":750,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"Gateway / Bank fee on RCP-SS-2026-502"},{"id":"jl_je_ten_softshore_1791213204367_68_3","je_id":"je_ten_softshore_1791213204367_68","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","account_name":"Accounts Receivable (AR)","debit":0,"credit":50000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","vendor_id":null,"tax_code":null,"memo":"AR settlement for INV-SS-2026-1002"},{"id":"jl_je_ten_softshore_1791213204367_567_1","je_id":"je_ten_softshore_1791213204367_567","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5200","account_code":"5200","account_name":"Rent Expense","debit":45000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":"vnd_2","tax_code":null,"memo":"September 2026 Head Office Rent (Banani-11)"},{"id":"jl_je_ten_softshore_1791213204367_567_2","je_id":"je_ten_softshore_1791213204367_567","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","account_name":"Cash at Bank","debit":0,"credit":45000,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":"vnd_2","tax_code":null,"memo":"September 2026 Head Office Rent (Banani-11)"},{"id":"jl_je_ten_softshore_1791213204367_46_1","je_id":"je_ten_softshore_1791213204367_46","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5300","account_code":"5300","account_name":"Utilities","debit":35000,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":"vnd_1","tax_code":null,"memo":"Dedicated Fiber & BGP Upstream Bill - Sep 2026"},{"id":"jl_je_ten_softshore_1791213204367_46_2","je_id":"je_ten_softshore_1791213204367_46","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2000","account_code":"2000","account_name":"Accounts Payable (AP)","debit":0,"credit":35000,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":"vnd_1","tax_code":null,"memo":"Dedicated Fiber & BGP Upstream Bill - Sep 2026"},{"id":"jl_je_ten_softshore_1791213204367_561_1","je_id":"je_ten_softshore_1791213204367_561","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5600","account_code":"5600","account_name":"Depreciation","debit":8250,"credit":0,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Monthly Straight-Line Depreciation (Server Rack & MacBooks)"},{"id":"jl_je_ten_softshore_1791213204367_561_2","je_id":"je_ten_softshore_1791213204367_561","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1510","account_code":"1510","account_name":"Accumulated Depreciation","debit":0,"credit":8250,"branch_id":"br_ten_softshore_hq","customer_id":null,"vendor_id":null,"tax_code":null,"memo":"Monthly Straight-Line Depreciation (Server Rack & MacBooks)"}],"ledger_entries":[{"id":"gl_jl_je_ten_softshore_1791213204367_477_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","je_id":"je_ten_softshore_1791213204367_477","je_number":"JE-2026-1001","line_id":"jl_je_ten_softshore_1791213204367_477_1","date":"2026-01-01","narration":"Opening Cash at Bank (City Bank PLC)","debit":1500000,"credit":0,"balance_after":1500000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_477_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1000","account_code":"1000","je_id":"je_ten_softshore_1791213204367_477","je_number":"JE-2026-1001","line_id":"jl_je_ten_softshore_1791213204367_477_2","date":"2026-01-01","narration":"Opening Petty Cash on Hand","debit":150000,"credit":0,"balance_after":150000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_477_3","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1020","account_code":"1020","je_id":"je_ten_softshore_1791213204367_477","je_number":"JE-2026-1001","line_id":"jl_je_ten_softshore_1791213204367_477_3","date":"2026-01-01","narration":"Opening bKash Merchant Wallet Balance","debit":85000,"credit":0,"balance_after":85000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_477_4","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1500","account_code":"1500","je_id":"je_ten_softshore_1791213204367_477","je_number":"JE-2026-1001","line_id":"jl_je_ten_softshore_1791213204367_477_4","date":"2026-01-01","narration":"Server Racks & Office MacBooks","debit":450000,"credit":0,"balance_after":450000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_477_5","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_3000","account_code":"3000","je_id":"je_ten_softshore_1791213204367_477","je_number":"JE-2026-1001","line_id":"jl_je_ten_softshore_1791213204367_477_5","date":"2026-01-01","narration":"Owner\'s Capital Seed Investment","debit":0,"credit":2185000,"balance_after":2185000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_612_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1200","account_code":"1200","je_id":"je_ten_softshore_1791213204367_612","je_number":"JE-2026-1002","line_id":"jl_je_ten_softshore_1791213204367_612_1","date":"2026-09-01","narration":"Purchase of 30 Smart POS Terminals & Biometric Gateways for Inventory","debit":330000,"credit":0,"balance_after":330000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_612_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","je_id":"je_ten_softshore_1791213204367_612","je_number":"JE-2026-1002","line_id":"jl_je_ten_softshore_1791213204367_612_2","date":"2026-09-01","narration":"Purchase of 30 Smart POS Terminals & Biometric Gateways for Inventory","debit":0,"credit":330000,"balance_after":1170000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_191_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_191","je_number":"JE-2026-1003","line_id":"jl_je_ten_softshore_1791213204367_191_1","date":"2026-09-27","narration":"AR for Invoice 26092501510","debit":14000,"credit":0,"balance_after":14000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_5","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_191_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","je_id":"je_ten_softshore_1791213204367_191","je_number":"JE-2026-1003","line_id":"jl_je_ten_softshore_1791213204367_191_2","date":"2026-09-27","narration":"Revenue for Invoice 26092501510","debit":0,"credit":14000,"balance_after":14000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_5","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_426_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_426","je_number":"JE-2026-1004","line_id":"jl_je_ten_softshore_1791213204367_426_1","date":"2026-09-05","narration":"AR for Invoice INV-SS-2026-1001","debit":80500,"credit":0,"balance_after":94500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_426_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","je_id":"je_ten_softshore_1791213204367_426","je_number":"JE-2026-1004","line_id":"jl_je_ten_softshore_1791213204367_426_2","date":"2026-09-05","narration":"Revenue for Invoice INV-SS-2026-1001","debit":0,"credit":70000,"balance_after":84000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_426_3","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","je_id":"je_ten_softshore_1791213204367_426","je_number":"JE-2026-1004","line_id":"jl_je_ten_softshore_1791213204367_426_3","date":"2026-09-05","narration":"Output VAT collected on Invoice INV-SS-2026-1001","debit":0,"credit":10500,"balance_after":10500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_679_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_679","je_number":"JE-2026-1005","line_id":"jl_je_ten_softshore_1791213204367_679_1","date":"2026-09-15","narration":"AR for Invoice INV-SS-2026-1002","debit":103500,"credit":0,"balance_after":198000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_679_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4200","account_code":"4200","je_id":"je_ten_softshore_1791213204367_679","je_number":"JE-2026-1005","line_id":"jl_je_ten_softshore_1791213204367_679_2","date":"2026-09-15","narration":"Discount given on Invoice INV-SS-2026-1002","debit":3500,"credit":0,"balance_after":-3500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_679_3","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4000","account_code":"4000","je_id":"je_ten_softshore_1791213204367_679","je_number":"JE-2026-1005","line_id":"jl_je_ten_softshore_1791213204367_679_3","date":"2026-09-15","narration":"Revenue for Invoice INV-SS-2026-1002","debit":0,"credit":18500,"balance_after":18500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_679_4","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","je_id":"je_ten_softshore_1791213204367_679","je_number":"JE-2026-1005","line_id":"jl_je_ten_softshore_1791213204367_679_4","date":"2026-09-15","narration":"Revenue for Invoice INV-SS-2026-1002","debit":0,"credit":75000,"balance_after":159000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_679_5","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","je_id":"je_ten_softshore_1791213204367_679","je_number":"JE-2026-1005","line_id":"jl_je_ten_softshore_1791213204367_679_5","date":"2026-09-15","narration":"Output VAT collected on Invoice INV-SS-2026-1002","debit":0,"credit":13500,"balance_after":24000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_453_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_453","je_number":"JE-2026-1006","line_id":"jl_je_ten_softshore_1791213204367_453_1","date":"2026-09-01","narration":"AR for Invoice INV-SS-2026-1003","debit":33350,"credit":0,"balance_after":231350,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_453_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4200","account_code":"4200","je_id":"je_ten_softshore_1791213204367_453","je_number":"JE-2026-1006","line_id":"jl_je_ten_softshore_1791213204367_453_2","date":"2026-09-01","narration":"Discount given on Invoice INV-SS-2026-1003","debit":1000,"credit":0,"balance_after":-4500,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_453_3","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","je_id":"je_ten_softshore_1791213204367_453","je_number":"JE-2026-1006","line_id":"jl_je_ten_softshore_1791213204367_453_3","date":"2026-09-01","narration":"Revenue for Invoice INV-SS-2026-1003","debit":0,"credit":30000,"balance_after":189000,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_453_4","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","je_id":"je_ten_softshore_1791213204367_453","je_number":"JE-2026-1006","line_id":"jl_je_ten_softshore_1791213204367_453_4","date":"2026-09-01","narration":"Output VAT collected on Invoice INV-SS-2026-1003","debit":0,"credit":4350,"balance_after":28350,"branch_id":"br_ten_softshore_ctg","customer_id":"cust_3","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_639_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_639","je_number":"JE-2026-1007","line_id":"jl_je_ten_softshore_1791213204367_639_1","date":"2026-10-01","narration":"AR for Invoice INV-SS-2026-1004","debit":29900,"credit":0,"balance_after":261250,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_639_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4000","account_code":"4000","je_id":"je_ten_softshore_1791213204367_639","je_number":"JE-2026-1007","line_id":"jl_je_ten_softshore_1791213204367_639_2","date":"2026-10-01","narration":"Revenue for Invoice INV-SS-2026-1004","debit":0,"credit":12000,"balance_after":30500,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_639_3","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_4100","account_code":"4100","je_id":"je_ten_softshore_1791213204367_639","je_number":"JE-2026-1007","line_id":"jl_je_ten_softshore_1791213204367_639_3","date":"2026-10-01","narration":"Revenue for Invoice INV-SS-2026-1004","debit":0,"credit":14000,"balance_after":203000,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_639_4","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2100","account_code":"2100","je_id":"je_ten_softshore_1791213204367_639","je_number":"JE-2026-1007","line_id":"jl_je_ten_softshore_1791213204367_639_4","date":"2026-10-01","narration":"Output VAT collected on Invoice INV-SS-2026-1004","debit":0,"credit":3900,"balance_after":32250,"branch_id":"br_ten_softshore_syl","customer_id":"cust_4","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_253_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5000","account_code":"5000","je_id":"je_ten_softshore_1791213204367_253","je_number":"JE-2026-1008","line_id":"jl_je_ten_softshore_1791213204367_253_1","date":"2026-09-15","narration":"COGS recognition for Invoice INV-SS-2026-1002","debit":11000,"credit":0,"balance_after":11000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_253_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1200","account_code":"1200","je_id":"je_ten_softshore_1791213204367_253","je_number":"JE-2026-1008","line_id":"jl_je_ten_softshore_1791213204367_253_2","date":"2026-09-15","narration":"COGS recognition for Invoice INV-SS-2026-1002","debit":0,"credit":11000,"balance_after":319000,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_953_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","je_id":"je_ten_softshore_1791213204367_953","je_number":"JE-2026-1009","line_id":"jl_je_ten_softshore_1791213204367_953_1","date":"2026-09-18","narration":"Deposit to 1010 (Bank Transfer)","debit":80500,"credit":0,"balance_after":1250500,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_953_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_953","je_number":"JE-2026-1009","line_id":"jl_je_ten_softshore_1791213204367_953_2","date":"2026-09-18","narration":"AR settlement for INV-SS-2026-1001","debit":0,"credit":80500,"balance_after":180750,"branch_id":"br_ten_softshore_hq","customer_id":"cust_1","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_68_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","je_id":"je_ten_softshore_1791213204367_68","je_number":"JE-2026-1010","line_id":"jl_je_ten_softshore_1791213204367_68_1","date":"2026-09-25","narration":"Deposit to 1010 (SSLCommerz)","debit":49250,"credit":0,"balance_after":1299750,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_68_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5500","account_code":"5500","je_id":"je_ten_softshore_1791213204367_68","je_number":"JE-2026-1010","line_id":"jl_je_ten_softshore_1791213204367_68_2","date":"2026-09-25","narration":"Gateway / Bank fee on RCP-SS-2026-502","debit":750,"credit":0,"balance_after":750,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_68_3","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1100","account_code":"1100","je_id":"je_ten_softshore_1791213204367_68","je_number":"JE-2026-1010","line_id":"jl_je_ten_softshore_1791213204367_68_3","date":"2026-09-25","narration":"AR settlement for INV-SS-2026-1002","debit":0,"credit":50000,"balance_after":130750,"branch_id":"br_ten_softshore_hq","customer_id":"cust_2","posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_567_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5200","account_code":"5200","je_id":"je_ten_softshore_1791213204367_567","je_number":"JE-2026-1011","line_id":"jl_je_ten_softshore_1791213204367_567_1","date":"2026-09-05","narration":"September 2026 Head Office Rent (Banani-11)","debit":45000,"credit":0,"balance_after":45000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_567_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1010","account_code":"1010","je_id":"je_ten_softshore_1791213204367_567","je_number":"JE-2026-1011","line_id":"jl_je_ten_softshore_1791213204367_567_2","date":"2026-09-05","narration":"September 2026 Head Office Rent (Banani-11)","debit":0,"credit":45000,"balance_after":1254750,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_46_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5300","account_code":"5300","je_id":"je_ten_softshore_1791213204367_46","je_number":"JE-2026-1012","line_id":"jl_je_ten_softshore_1791213204367_46_1","date":"2026-09-10","narration":"Dedicated Fiber & BGP Upstream Bill - Sep 2026","debit":35000,"credit":0,"balance_after":35000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_46_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_2000","account_code":"2000","je_id":"je_ten_softshore_1791213204367_46","je_number":"JE-2026-1012","line_id":"jl_je_ten_softshore_1791213204367_46_2","date":"2026-09-10","narration":"Dedicated Fiber & BGP Upstream Bill - Sep 2026","debit":0,"credit":35000,"balance_after":35000,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_561_1","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_5600","account_code":"5600","je_id":"je_ten_softshore_1791213204367_561","je_number":"JE-2026-1013","line_id":"jl_je_ten_softshore_1791213204367_561_1","date":"2026-09-30","narration":"Monthly Straight-Line Depreciation (Server Rack & MacBooks)","debit":8250,"credit":0,"balance_after":8250,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"},{"id":"gl_jl_je_ten_softshore_1791213204367_561_2","tenant_id":"ten_softshore","account_id":"acc_ten_softshore_1510","account_code":"1510","je_id":"je_ten_softshore_1791213204367_561","je_number":"JE-2026-1013","line_id":"jl_je_ten_softshore_1791213204367_561_2","date":"2026-09-30","narration":"Monthly Straight-Line Depreciation (Server Rack & MacBooks)","debit":0,"credit":8250,"balance_after":-8250,"branch_id":"br_ten_softshore_hq","customer_id":null,"posted_at":"2026-10-05T15:13:24.367Z"}],"notification_templates":[{"id":"nt_ten_softshore_invoice_created","tenant_id":"ten_softshore","event":"invoice_created","label":"On Invoice Creation","channel":"both","days_offset":0,"email_subject":"New Invoice {invoice_no} from {company_name}","email_body":"Dear {customer_name},\\n\\nYour invoice {invoice_no} for {amount} has been issued. Due Date: {due_date}.\\nPay securely online: {payment_link}\\n\\nThank you,\\n{company_name}","sms_body":"{company_name}: Invoice {invoice_no} for {amount} issued. Due {due_date}. Pay: {payment_link}","is_enabled":true},{"id":"nt_ten_softshore_before_due_3d","tenant_id":"ten_softshore","event":"before_due_3d","label":"3 Days Before Due Reminder","channel":"both","days_offset":-3,"email_subject":"Friendly Reminder: Invoice {invoice_no} is due in 3 days ({due_date})","email_body":"Dear {customer_name},\\n\\nThis is a reminder that invoice {invoice_no} of {amount} is due on {due_date}. Please complete payment at {payment_link}.","sms_body":"Reminder from {company_name}: Invoice {invoice_no} ({amount}) is due on {due_date}. Pay: {payment_link}","is_enabled":true},{"id":"nt_ten_softshore_on_due_date","tenant_id":"ten_softshore","event":"on_due_date","label":"On Due Date Alert","channel":"both","days_offset":0,"email_subject":"Due Today: Invoice {invoice_no} ({amount})","email_body":"Dear {customer_name},\\n\\nYour invoice {invoice_no} for {amount} is due today ({due_date}). Pay online at {payment_link}.","sms_body":"{company_name}: Invoice {invoice_no} for {amount} is DUE TODAY ({due_date}). Pay now: {payment_link}","is_enabled":true},{"id":"nt_ten_softshore_overdue_3d","tenant_id":"ten_softshore","event":"overdue_3d","label":"Overdue Reminder (3 Days Past Due)","channel":"both","days_offset":3,"email_subject":"OVERDUE Notice: Invoice {invoice_no} ({amount})","email_body":"Dear {customer_name},\\n\\nYour invoice {invoice_no} for {amount} was due on {due_date} and is now overdue. Kindly settle immediately at {payment_link}.","sms_body":"URGENT ({company_name}): Invoice {invoice_no} of {amount} is OVERDUE since {due_date}. Please pay: {payment_link}","is_enabled":true},{"id":"nt_ten_softshore_payment_received","tenant_id":"ten_softshore","event":"payment_received","label":"On Payment Confirmation & Receipt","channel":"both","days_offset":0,"email_subject":"Payment Received for Invoice {invoice_no} - Thank You!","email_body":"Dear {customer_name},\\n\\nWe have received your payment of {amount} for Invoice {invoice_no}. Your official receipt is attached.\\n\\nWarm regards,\\n{company_name}","sms_body":"Thank you {customer_name}! Payment of {amount} received for {invoice_no} ({company_name}).","is_enabled":true},{"id":"nt_ten_softshore_subscription_renewed","tenant_id":"ten_softshore","event":"subscription_renewed","label":"On Subscription Renewal","channel":"both","days_offset":0,"email_subject":"Subscription Renewed & Invoice {invoice_no} Generated","email_body":"Dear {customer_name},\\n\\nYour subscription with {company_name} has been renewed. Invoice {invoice_no} for {amount} is due on {due_date}.","sms_body":"{company_name}: Subscription renewed. Invoice {invoice_no} ({amount}) due {due_date}.","is_enabled":true}],"notification_logs":[{"id":"nl_seed_1","tenant_id":"ten_softshore","channel":"sms","recipient":"+8801710328545","customer_name":"Square Pharmaceuticals PLC","event":"payment_received","subject":"SMS [KidLand]","message":"Thank you Square Pharmaceuticals PLC! Payment of BDT 80,500 received for INV-SS-2026-1001 (SoftShore Cloud Solutions Ltd.).","gateway_url":"https://apipro.bgtelsms.com/onetomany?acode=30000075&api_key=00694cc4892224ee3eefffed2330becadcb8cade&senderid=KidLand&type=text&msg=Thank+you&contacts=%2B8801710328545&transactionType=T&contentID=INV-SS-2026-1001","gateway_response":"BGTel HTTP 200: SMS Dispatched [Sender: KidLand, ContentID: INV-SS-2026-1001]","status":"delivered","retry_count":0,"sent_at":"2026-09-18T11:20:05.000Z"},{"id":"nl_seed_2","tenant_id":"ten_softshore","channel":"email","recipient":"mehedi@squarepharma.com.bd","customer_name":"Square Pharmaceuticals PLC","event":"payment_received","subject":"Payment Received for Invoice INV-SS-2026-1001 - Thank You!","message":"Dear Square Pharmaceuticals PLC, We have received your payment of BDT 80,500. Official receipt RCP-SS-2026-501 attached.","gateway_response":"250 2.0.0 OK (SMTP: no-reply@softshore.tech)","status":"delivered","retry_count":0,"sent_at":"2026-09-18T11:20:06.000Z"},{"id":"nl_seed_3","tenant_id":"ten_softshore","channel":"sms","recipient":"+8801811334455","customer_name":"Karnafuli Port Logistics Ltd.","event":"overdue_3d","subject":"SMS [KidLand]","message":"URGENT (SoftShore Cloud Solutions Ltd.): Invoice INV-SS-2026-1003 of BDT 33,350 is OVERDUE since 2026-09-22. Please pay online.","gateway_response":"BGTel HTTP 200: SMS Dispatched [Sender: KidLand]","status":"delivered","retry_count":0,"sent_at":"2026-09-25T09:00:00.000Z"}],"audit_logs":[{"id":"aud_1","tenant_id":"ten_softshore","user_id":"usr_super","user_name":"Kayser Ahmed (Super Admin)","user_role":"Super Admin","action":"TENANT_CREATED_AUTO_SEED_COA","entity":"Tenant","entity_id":"ten_softshore","summary":"Provisioned tenant SoftShore Cloud Solutions Ltd. & auto-seeded 30 COA accounts, FY 2026, and 12 GL periods in 12ms.","ip_address":"103.148.22.10","created_at":"2026-01-10T08:00:01.000Z"},{"id":"aud_2","tenant_id":"ten_softshore","user_id":"usr_accountant","user_name":"Farhana Akter FCA","user_role":"Accountant","action":"GL_AUTO_POSTING_VERIFIED","entity":"JournalEntry","entity_id":"JE-2026-1007","summary":"Verified Trial Balance equilibrium (Total Debits = Total Credits) after Payment RCP-SS-2026-501.","ip_address":"103.148.22.14","created_at":"2026-09-18T11:25:00.000Z"}]}') ON DUPLICATE KEY UPDATE state_json=VALUES(state_json);

SET FOREIGN_KEY_CHECKS = 1;
