# CompanyCurrencyService

**Kind:** Class

**Source:** `Frontend/src/app/services/organization/company-currency.service.ts` (line 15)

**Part of:** [Frontend](subsystem-frontend-src-app)

`CompanyCurrencyService` manages company currency data and currency-rate retrieval within the organization area of the frontend. It exposes methods for loading currency records, reading rates, saving or deleting company currency entries, and calculating a currency-rate value.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `retrieveFromCurrencyRateToCurrency` | `retrieveFromCurrencyRateToCurrency(currenciesListWithRates: CurrenciesWithRates[], fromCurrencyCode: string, toCurrencyCode: string)` | `number` |
| `getCompanyCurrencyService` | `getCompanyCurrencyService(id: number)` | `void` |
| `getAllCurrencyWithRates` | `getAllCurrencyWithRates()` | `void` |
| `getCompanyCurrencyByIdService` | `getCompanyCurrencyByIdService(id: number)` | `void` |
| `saveCompanyCurrencyService` | `saveCompanyCurrencyService(entity: CompanyCurrency)` | `void` |
| `deleteCompanyCurrencyService` | `deleteCompanyCurrencyService(id: number)` | `void` |

## Diagram

```mermaid
graph LR
  Component[Organization Component] --> Service[CompanyCurrencyService]
  Service --> Rates[getAllCurrencyWithRates]
  Service --> CompanyCurrency[getCompanyCurrencyService]
  Service --> CurrencyById[getCompanyCurrencyByIdService]
  Service --> Save[saveCompanyCurrencyService]
  Service --> Delete[deleteCompanyCurrencyService]
  Service --> RateValue[retrieveFromCurrencyRateToCurrency]
```

## Usage

```ts
import { Component } from '@angular/core';
import { CompanyCurrencyService } from 'src/app/services/organization/company-currency.service';

@Component({
  selector: 'app-company-currency',
  template: `<!-- currency content -->`,
})
export class CompanyCurrencyComponent {
  constructor(
    private readonly companyCurrencyService: CompanyCurrencyService,
  ) {}

  loadCurrencies(): void {
    const currencies = this.companyCurrencyService.getAllCurrencyWithRates();
    const rateValue: number =
      this.companyCurrencyService.retrieveFromCurrencyRateToCurrency();

    console.log(currencies, rateValue);
  }

  saveCurrency(): void {
    this.companyCurrencyService.saveCompanyCurrencyService();
  }

  removeCurrency(): void {
    this.companyCurrencyService.deleteCompanyCurrencyService();
  }
}
```

## AI Coding Instructions

- Inject `CompanyCurrencyService` through the Angular constructor instead of creating it directly.
- Use `getAllCurrencyWithRates()` when a screen needs currency entries together with their rates.
- Keep currency save and delete actions in component handlers or related state-management flows.
- Treat `retrieveFromCurrencyRateToCurrency()` as a `number` value and avoid changing its return contract.

## Used by

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

### Imported by (15)

- `CompanyCurrencyComponent` — `Frontend/src/app/components/configuration/commercial/company-currency/company-currency.component.ts`:1
- `NewBranchComponent` — `Frontend/src/app/components/configuration/company/main-branch/new.branch.component.ts`:1
- `GenericConfigurationComponent` — `Frontend/src/app/components/configuration/generic-configuration/generic-configuration.component.ts`:1
- `BranchData` — `Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-account-payable/mrm-account-payable.component.ts`:1
- `BranchData` — `Frontend/src/app/components/dashboard/dashboard-libary/widgets/mrm-account-receivable/mrm-account-receivable.component.ts`:1
- `DirectCostTransactionsDetailsComponent` — `Frontend/src/app/components/job-costing/direct-cost-transactions-details/direct-cost-transactions-details.component.ts`:1
- `AccountDetailsComponent` — `Frontend/src/app/components/market/account-details/account-details.component.ts`:1
- `DecreasedTableComponent` — `Frontend/src/app/components/market/account-details/decreased-table/decreased-table.component.ts`:1

…and 7 more.
