Skip to main content
The Settings module provides centralized configuration management for your MotorDesk installation. This is where business owners and administrators configure company information, manage multiple branches, set up billing document series, and control user access.

Overview

The Settings page is organized into four main configuration areas accessible via a sidebar navigation:

Company Settings

Configure legal business information for SUNAT compliance

Branch Management

Manage multiple business locations and service centers

Billing Series

Configure document series for invoices and receipts

User Management

Control user accounts and role assignments

Company Settings

Configure your business’s legal and contact information used for electronic invoicing and SUNAT compliance.

Required Fields

ruc
string
required
Peruvian tax identification number (RUC). Must be 11 digits.
razonSocial
string
required
Legal business name registered with SUNAT
nombreComercial
string
required
Commercial or trade name displayed to customers
direccion
string
required
Primary business address
telefono
string
Primary contact phone number
email
string
Business email for invoices and notifications
URL or path to company logo (displayed on invoices)
certificadoSunat
string
SUNAT digital certificate for electronic billing authentication

Example Configuration

const companyData = {
  id: "company-001",
  ruc: "20987654321",
  razonSocial: "AUTOMOTRIZ MOTORS S.A.C.",
  nombreComercial: "Motors Express",
  direccion: "Av. Los Olivos 456, Lima",
  telefono: "01-234-5678",
  email: "[email protected]",
  logo: "/assets/logo-empresa.png",
  certificadoSunat: "motors_cert_2024.pfx"
};
Company information is used on all electronic invoices sent to SUNAT. Ensure all details are accurate and match your SUNAT registration.

Branch Management

Manage multiple service locations with independent operations and document numbering.

Branch Structure

Each branch represents a physical location where services are performed and invoices are issued:
interface Branch {
  id: string;
  nombre: string;           // Branch name
  direccion: string;        // Branch address
  telefono?: string;        // Branch phone
  esMatriz: boolean;        // Is main/headquarters location
  activo: boolean;          // Active status
}

Branch Operations

  • Independent Billing: Each branch can have its own document series
  • User Assignment: Staff can be assigned to specific branches
  • Location Tracking: Sales and services are tagged by branch for reporting
src/data/mock/branches.ts
export const branchesData = {
  branches: [
    {
      id: "branch-001",
      nombre: "Sede Principal - Los Olivos",
      direccion: "Av. Los Olivos 456, Los Olivos, Lima",
      telefono: "01-234-5678",
      esMatriz: true,
      activo: true
    },
    {
      id: "branch-002",
      nombre: "Sucursal San Miguel",
      direccion: "Jr. La Marina 789, San Miguel, Lima",
      telefono: "01-345-6789",
      esMatriz: false,
      activo: true
    },
    {
      id: "branch-003",
      nombre: "Sucursal Callao",
      direccion: "Av. Argentina 123, Callao",
      telefono: "01-456-7890",
      esMatriz: false,
      activo: true
    }
  ]
};
Deactivating a branch does not delete historical data. Sales and services from that branch remain in the system for reporting and audit purposes.

Billing Series Configuration

Document series control the numbering sequence for invoices (FACTURA) and receipts (BOLETA) issued at each branch.

Series Structure

interface DocumentSeries {
  id: string;
  branchId: string;         // Branch where series is used
  tipoDocumento: string;    // "FACTURA" or "BOLETA"
  serie: string;            // Series prefix (e.g., "F001", "B001")
  correlativoActual: number; // Current document number
  activo: boolean;          // Active status
}

Document Types

Tax invoices issued to businesses (RUC holders). Required for business-to-business transactions.
  • Series format: F### (e.g., F001, F002)
  • Requires customer RUC
  • Includes full tax breakdown
  • SUNAT validation required
Simplified receipts issued to individuals (DNI holders) or consumers.
  • Series format: B### (e.g., B001, B002)
  • Can use DNI or no document
  • Simplified tax treatment
  • SUNAT validation required for amounts over threshold

Series Assignment

src/data/mock/documentSeries.ts
export const documentSeriesData = {
  documentSeries: [
    {
      id: "series-001",
      branchId: "branch-001",
      tipoDocumento: "FACTURA",
      serie: "F001",
      correlativoActual: 150,
      activo: true
    },
    {
      id: "series-002",
      branchId: "branch-001",
      tipoDocumento: "BOLETA",
      serie: "B001",
      correlativoActual: 320,
      activo: true
    },
    {
      id: "series-003",
      branchId: "branch-002",
      tipoDocumento: "FACTURA",
      serie: "F002",
      correlativoActual: 85,
      activo: true
    }
  ]
};
Each branch should have at least one active series for FACTURA and one for BOLETA to handle all customer types.

User Management

Control user accounts, role assignments, and branch access permissions.

User Roles

MotorDesk supports four user roles with different permission levels:

DUEÑO (Owner)

Full system access, can configure company settings and manage all users

ADMINISTRADOR (Admin)

Manage operations, users, and products. Cannot change company legal settings.

VENDEDOR (Seller)

Issue invoices, manage customers and vehicles. Cannot delete records or manage products.

CAJERO (Cashier)

Issue receipts and basic sales. Limited access to configuration.

User Structure

interface User {
  id: string;
  nombre: string;
  email: string;
  rol: 'DUEÑO' | 'ADMINISTRADOR' | 'VENDEDOR' | 'CAJERO';
  branchIds: string[];      // Branches user can access
}

Permission Matrix

ActionOwnerAdminSellerCashier
Configure company
Manage users
Add/delete products
Edit product prices
Add customers/vehicles
Delete customers/vehicles
Issue invoices
Void invoices
Permissions are enforced via the usePermissions hook which checks the user’s role and returns boolean flags for each operation.

Access Control

Role-Based Access

Only Owners have access to the Settings page and can modify configuration:
src/hooks/usePermissions.ts
const { user } = useAuth();
const canConfigureCompany = user?.rol === UserRole.OWNER;
const canManageUsers = user?.rol === UserRole.OWNER;

Branch-Level Access

Users can be restricted to specific branches:
src/hooks/useMainLayout.ts
const availableBranches = useMemo(() => {
  if (!user) return [];
  
  // Owner and Admin see all branches
  if (user.rol === 'DUEÑO' || user.rol === 'ADMINISTRADOR') {
    return branchesData.branches;
  }
  
  // Sellers and Cashiers only see assigned branches
  return branchesData.branches.filter(b => 
    user.branchIds?.includes(b.id)
  );
}, [user]);

Configuration Workflow

1

Initial Setup

On first login, the Owner configures company information including RUC, legal name, and SUNAT certificate.
2

Add Branches

Create entries for all physical service locations. Mark the main location as esMatriz: true.
3

Configure Series

Set up document series for each branch. Each location needs at least one FACTURA series and one BOLETA series.
4

Create Users

Add user accounts, assign roles, and restrict to specific branches if needed.
5

Test Billing

Issue a test invoice from each branch to verify series configuration and SUNAT connectivity.

Settings Hook

The Settings page uses the useSettings hook to manage state:
src/hooks/useSettings.ts
export const useSettings = () => {
  const [activeTab, setActiveTab] = useState<'empresa' | 'sucursales' | 'series' | 'usuarios'>('empresa');
  const [companyData, setCompanyData] = useState(db.company);
  const [branchesData] = useState(db.branches);
  const [seriesData] = useState(db.documentSeries);
  const [usersData] = useState(db.users);

  const handleCompanyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    setCompanyData({ ...companyData, [e.target.name]: e.target.value });
  };

  const saveCompanySettings = (e: React.FormEvent) => {
    e.preventDefault();
    // Save to backend/localStorage
    alert('¡Configuración guardada con éxito!');
  };

  return {
    activeTab,
    setActiveTab,
    companyData,
    handleCompanyChange,
    saveCompanySettings,
    branchesData,
    seriesData,
    usersData
  };
};

Best Practices

  • Keep company information up to date with SUNAT registration
  • Back up your SUNAT certificate securely
  • Use a dedicated business email for invoice notifications
  • Update certificate before expiration to avoid service interruption
  • Use clear, descriptive branch names (include location)
  • Keep branch contact information current
  • Don’t delete branches with historical data - deactivate instead
  • Assign each employee to their primary working branch
  • Never reuse or modify series numbers once documents are issued
  • Keep separate series for each branch to simplify auditing
  • Monitor series numbers approaching 9999999 (SUNAT limit)
  • Deactivate old series rather than deleting them
  • Follow principle of least privilege (assign minimum required role)
  • Regularly review and update user access
  • Disable accounts for former employees immediately
  • Use strong passwords and consider 2FA for Owners and Admins

Build docs developers (and LLMs) love