Class OmieCategoryProvider
Resolves the category (cCodCateg) a service order carries in Omie. Omie requires the category on
inclusion and every account has its own chart of accounts — which is why it is discovered in the registration
instead of hardcoded: the categories are listed and the first of the configured preferences is picked by name.
Only accounts that can take a revenue entry are considered: conta_receita = "S", active, not a
totalizer (totalizers are just groupings of the chart of accounts) and not a transfer account. Filtering by name
alone could land on an expense account with a similar name.
public class OmieCategoryProvider
- Inheritance
-
OmieCategoryProvider
- Inherited Members
Constructors
OmieCategoryProvider(OmieDirectApiClient, IMemoryCache, ILogger<OmieCategoryProvider>)
Resolves the category (cCodCateg) a service order carries in Omie. Omie requires the category on
inclusion and every account has its own chart of accounts — which is why it is discovered in the registration
instead of hardcoded: the categories are listed and the first of the configured preferences is picked by name.
Only accounts that can take a revenue entry are considered: conta_receita = "S", active, not a
totalizer (totalizers are just groupings of the chart of accounts) and not a transfer account. Filtering by name
alone could land on an expense account with a similar name.
public OmieCategoryProvider(OmieDirectApiClient omie, IMemoryCache cache, ILogger<OmieCategoryProvider> logger)
Parameters
omieOmieDirectApiClientcacheIMemoryCacheloggerILogger<OmieCategoryProvider>
Methods
GetRevenueCategoriesAsync(bool, CancellationToken)
Usable revenue categories of the chart of accounts — the list an application offers for selection.
With forceRefresh the cache is ignored and rewritten with whatever Omie returns, which is
what a "reload from the ERP" action needs: without it the button would serve the cached list for the next
30 minutes and look like it did nothing.
public Task<IResult<IReadOnlyList<OmieCategory>>> GetRevenueCategoriesAsync(bool forceRefresh, CancellationToken cancellationToken)
Parameters
forceRefreshboolcancellationTokenCancellationToken
Returns
ResolveCategoryCodeAsync(string?, IReadOnlyList<string>, CancellationToken)
Category code for the service order. configuredCode wins when informed — whoever
configured it knows which account they want. Without it, the preferences are searched in
order.
public Task<IResult<string>> ResolveCategoryCodeAsync(string? configuredCode, IReadOnlyList<string> preferences, CancellationToken cancellationToken)
Parameters
configuredCodestringpreferencesIReadOnlyList<string>cancellationTokenCancellationToken