Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pcr-coding/vba-ufi-generator
UFI (Unique Formula Identifier) generator/decoder
https://github.com/pcr-coding/vba-ufi-generator
Last synced: 9 days ago
JSON representation
UFI (Unique Formula Identifier) generator/decoder
- Host: GitHub
- URL: https://github.com/pcr-coding/vba-ufi-generator
- Owner: pcr-coding
- Created: 2021-03-08T15:45:09.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-15T07:54:51.000Z (over 2 years ago)
- Last Synced: 2024-08-13T07:18:15.553Z (4 months ago)
- Language: VBA
- Size: 37.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- jimsghstars - pcr-coding/vba-ufi-generator - UFI (Unique Formula Identifier) generator/decoder (VBA)
README
# VBA UFI Generator
[![License: MIT](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://opensource.org/licenses/gpl-3.0)VBA Generator/decoder for [ECHA](https://ufi.echa.europa.eu/#/create) UFIs (Unique Formula Identifier)
According :books: [UFI Developer manual](https://poisoncentres.echa.europa.eu/documents/1789887/1803644/ufi_developers_manual_en.pdf) version 1.5 (2022-01).## Syntax
### Generate function
Returns a **String** representing the encoded UFI including dashes.Generate(CountryCode, VAT, FormulationNumber)
| Argument | Type | Description |
| :---------------- | :----- | :------------------------------------------------ |
| CountryCode | String | Country Code of the VAT number eg. `"AT"` |
| VAT | String | VAT number without country code eg. `"U12345678"` |
| FormulationNumber | Long | Numeric formulation number eg. `178956970` |### Decode function
Returns a **DecodedUFI** object of the decoded UFI.Decode(UFI)
| Argument | Type | Description |
| :------- | :----- | :--------------------------------------------------------- |
| UFI | String | UFI (with or without dashes) eg. `"C23S-PQ2V-AMH9-VVRF"` |
### IsValid function
Returns a **True** if the UFI is valid.IsValid(UFI)
| Argument | Type | Description |
| :------- | :----- | :--------------------------------------------------------- |
| UFI | String | UFI (with or without dashes) eg. `"C23S-PQ2V-AMH9-VVRF"` |## Examples
### Generate UFI
```vba
Public Sub ExampleGenerate()
Dim UFIgen As New UFIgenerator
Debug.Print UFIgen.Generate("AT", "U12345678", 178956970) 'C23S-PQ2V-AMH9-VVRF
End Sub
```### Decode UFI
```vba
Public Sub ExampleDecode()
Dim UFIgen As New UFIgenerator
Dim UFI As DecodedUFI
Set UFI = UFIgen.Decode("C23S-PQ2V-AMH9-VVRF")Debug.Print UFI.CountryCode, UFI.VAT, UFI.FormulationNumber 'AT U12345678 178956970
End Sub
```
Decoder includes validation of the UFI and will throw errors if decoding fails or UFI is not valid.### Validate UFI
```vba
Public Sub ExampleValidate()
Dim UFIgen As New UFIgenerator
If UFIgen.IsValid("C23S-PQ2V-AMH9-VVRF") Then
Debug.Print "Valid"
Else
Debug.Print "Invalid"
End If
End Sub
```
Validator will only return `True`/`False` and does not throw errors.## Unit Testing
Includes unit test modules to be used with [RubberDuck](https://rubberduckvba.com/). These 2 test modules are only needed for development.