# CompanyBranch

**Kind:** Class

**Source:** `Pams/Logic/Pams.Business/Entity/Organization/CompanyBranch.Model.cs` (line 10)

**Part of:** [Pams](subsystem-pams)

`CompanyBranch` represents an organization branch and stores its identity, display names, statement, address reference, branding assets, tax rate, and commercial registration data. It is a business entity model in the PAMS organization domain for passing branch information between application layers.

## Diagram

```mermaid
graph LR
  CompanyBranch[CompanyBranch]
  CompanyBranch --> CompanyBranchID[CompanyBranchID: long]
  CompanyBranch --> BranchName[BranchName: string]
  CompanyBranch --> BranchFullName[BranchFullName: string]
  CompanyBranch --> BranchStatement[BranchStatement: string]
  CompanyBranch --> AddressID[AddressID: long?]
  CompanyBranch --> LogoId[LogoId: string]
  CompanyBranch --> Logo[Logo: string]
  CompanyBranch --> IsoLogo[IsoLogo: string]
  CompanyBranch --> VatRate[VatRate: decimal?]
  CompanyBranch --> CommercialRecord[CommercialRecord: string]
```

## Usage

```ts
type CompanyBranch = {
  CompanyBranchID: bigint;
  LogoId: string;
  BranchName: string;
  BranchFullName: string;
  BranchStatement: string;
  AddressID: bigint | null;
  Logo: string;
  IsoLogo: string;
  VatRate: string | null;
  CommercialRecord: string;
};

async function getCompanyBranch(branchId: string): Promise<CompanyBranch> {
  const response = await fetch(`/api/company-branches/${branchId}`);

  if (!response.ok) {
    throw new Error("Unable to load company branch");
  }

  return response.json();
}

const branch = await getCompanyBranch(selectedBranchId);

document.title = branch.BranchName;
console.log(branch.BranchFullName, branch.CommercialRecord);
```

## AI Coding Instructions

- Keep property names aligned with the C# model, including `CompanyBranchID`, `AddressID`, and `LogoId`.
- Treat `AddressID` and `VatRate` as nullable values when mapping API requests and responses.
- Preserve `VatRate` precision when transferring it through JavaScript clients; avoid converting it to a floating-point value unless required by the API contract.
- Use `Logo`, `IsoLogo`, and `LogoId` consistently with the application's media or asset storage integration.
- Validate branch identity and registration fields before persisting changes through organization-related services.

## Relationships

- IMPORTS → `CompanyBranch`
- IMPORTS → `EntityBase`
- IMPORTS → `Company`
- IMPORTS → `PamsLinqDataContext`

## Used by

13 references from 13 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (13)

- `BaseController` — `Pams/API/Pams.API/Controllers/BaseController.cs`:515
- `CompanyBranchController` — `Pams/API/Pams.API/Controllers/Organization/CompanyBranchController.cs`:21
- `CompanyBranchSettingController` — `Pams/API/Pams.API/Controllers/Organization/CompanyBranchSettingController.cs`:24
- `CompanyController` — `Pams/API/Pams.API/Controllers/Organization/CompanyController.cs`:26
- `EmployeeController` — `Pams/API/Pams.API/Controllers/Person/EmployeeController.cs`:29
- `AccountsController` — `Pams/API/Pams.API/Controllers/Person/AccountsController.cs`:23
- `JobDocumentController` — `Pams/API/Pams.API/Controllers/Sales/JobDocumentController.cs`:19
- `ProjectController` — `Pams/API/Pams.API/Controllers/Sales/ProjectController.cs`:28

…and 5 more.
