Skip to content

Companies

The Company entity represents the organization that owns the ERP installation. Moon ERP operates as a single-company system -- there is one company record, and all data belongs to it. The company profile stores branding, contact information, fiscal configuration, and regional settings.

Purpose

  • Store the company's identity (name, logo, tax number, commercial register)
  • Configure regional defaults (currency, locale, timezone)
  • Set the fiscal year start month
  • Provide bilingual name and address fields (English and Arabic)

Entity Attributes

FieldTypeDescription
idintegerPrimary key
namestringCompany name (English)
name_arstringCompany name (Arabic)
short_namestring?Abbreviated name
prefixstringUnique tenant prefix (e.g., demo1)
emailstringContact email
phonestringContact phone
faxstring?Fax number
websitestring?Website URL
addressstringAddress (English)
address_arstringAddress (Arabic)
citystring?City
country_codestring?ISO country code (e.g., KW, EG)
postal_codestring?Postal code
tax_numberstringTax identification number
commercial_registerstringCommercial registration number
currencystringDefault currency (KWD or EGP)
localestringDefault locale (ar or en)
timezonestringTimezone (e.g., Asia/Kuwait)
fiscal_year_start_monthintegerMonth number (1-12) the fiscal year starts
logostring?Path to uploaded logo file
is_activebooleanWhether the company is active
settingsjson?Additional settings as JSON
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp

Relationships

API Endpoints

MethodPathDescription
GET/api/core/companyGet the current company profile
PUT/api/core/companyUpdate the company profile

INFO

There is no POST or DELETE for companies. The company record is created during installation. Only the authenticated user's own company is accessible.

Request/Response Examples

GET /api/core/company

Retrieve the authenticated user's company profile.

bash
curl -X GET https://moon-erp.test/api/core/company \
  -H "Accept: application/json" \
  -H "Accept-Language: ar" \
  -H "Authorization: Bearer {token}"
dart
final response = await http.get(
  Uri.parse('https://moon-erp.test/api/core/company'),
  headers: {
    'Accept': 'application/json',
    'Accept-Language': 'ar',
    'Authorization': 'Bearer $token',
  },
);

Response 200 OK

json
{
  "data": {
    "id": 1,
    "name": "شركة القمر للتجارة",
    "name_en": "Moon Trading Company",
    "name_ar": "شركة القمر للتجارة",
    "short_name": "Moon",
    "prefix": "moon1",
    "email": "info@moon-trading.com",
    "phone": "+965-22334455",
    "fax": "+965-22334456",
    "website": "https://moon-trading.com",
    "address": "شارع الخليج، مدينة الكويت",
    "city": "Kuwait City",
    "country_code": "KW",
    "postal_code": "15000",
    "tax_number": "TAX-KW-001",
    "commercial_register": "CR-2024-12345",
    "currency": "KWD",
    "locale": "ar",
    "timezone": "Asia/Kuwait",
    "fiscal_year_start_month": 1,
    "logo": null,
    "is_active": true,
    "created_at": "2026-01-01T00:00:00.000000Z",
    "updated_at": "2026-02-10T08:30:00.000000Z"
  }
}

PUT /api/core/company

Update company profile fields. All fields are optional -- include only the fields you want to change.

bash
curl -X PUT https://moon-erp.test/api/core/company \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer {token}" \
  -d '{
    "name": "Moon Trading Co. Updated",
    "name_ar": "شركة القمر للتجارة المحدثة",
    "fiscal_year_start_month": 4,
    "currency": "KWD"
  }'
dart
final response = await http.put(
  Uri.parse('https://moon-erp.test/api/core/company'),
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer $token',
  },
  body: jsonEncode({
    'name': 'Moon Trading Co. Updated',
    'name_ar': 'شركة القمر للتجارة المحدثة',
    'fiscal_year_start_month': 4,
    'currency': 'KWD',
  }),
);

Response 200 OK

json
{
  "data": {
    "id": 1,
    "name": "Moon Trading Co. Updated",
    "name_en": "Moon Trading Co. Updated",
    "name_ar": "شركة القمر للتجارة المحدثة",
    "short_name": "Moon",
    "prefix": "moon1",
    "email": "info@moon-trading.com",
    "phone": "+965-22334455",
    "fax": "+965-22334456",
    "website": "https://moon-trading.com",
    "address": "Gulf Road, Kuwait City",
    "city": "Kuwait City",
    "country_code": "KW",
    "postal_code": "15000",
    "tax_number": "TAX-KW-001",
    "commercial_register": "CR-2024-12345",
    "currency": "KWD",
    "locale": "ar",
    "timezone": "Asia/Kuwait",
    "fiscal_year_start_month": 4,
    "logo": null,
    "is_active": true,
    "created_at": "2026-01-01T00:00:00.000000Z",
    "updated_at": "2026-02-16T10:00:00.000000Z"
  }
}

Business Rules

  • Single company -- there is exactly one company record per installation. It cannot be created or deleted via the API.
  • Authenticated access only -- the company returned is always derived from auth()->user()->company_id.
  • All fields optional on update -- the PUT request uses sometimes validation. Only provided fields are updated.
  • Currency restricted -- the currency field only accepts KWD or EGP.
  • Locale restricted -- the locale field only accepts ar or en.
  • Fiscal year start -- must be an integer from 1 (January) to 12 (December).
  • Prefix is immutable -- the prefix field cannot be changed via the update endpoint.

Moon ERP API Documentation