diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1aed258 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Orink Hungary Kft. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 1779ef6..92dc747 100644 --- a/README.md +++ b/README.md @@ -1,256 +1,71 @@ -# ๐Ÿ™ Antares Data Exporter -
+# Antares Data Exporter + ![Octopus ERP Converter](docs/images/Octopus8.ico) -**A powerful Rust utility for fetching Antares B2B product data and exporting to Excel** -[Features](#features) โ€ข [Installation](#installation) โ€ข [Usage](#usage) โ€ข [Configuration](#configuration) โ€ข [Architecture](#architecture) +Rust utility to fetch product data from Antares B2B and export to Excel.
---- - -## Overview - -**Antares Data Exporter** is a high-performance Rust utility that seamlessly integrates with the Antares B2B web service to fetch product catalog data and export it to Excel with intelligent field mapping and business rule validation. Perfect for inventory management, data migration, and supply chain automation. - -## โœจ Features - -- ๐Ÿš€ **Fast & Efficient** - Blocking HTTP client with 300-second timeout for reliable operations -- ๐Ÿ“Š **Excel Export** - Intelligent field mapping with 8 carefully curated columns -- ๐Ÿง  **Smart Row Filtering** - Automatically skips incomplete records based on business rules -- ๐Ÿ“ **Dual Logging** - All events logged to both terminal and daily log files -- ๐ŸŽฏ **Flexible Output** - Support for custom file paths or directory-based exports -- ๐Ÿ” **Secure Credentials** - Environment-based credential management, no hardcoding -- ๐Ÿ—๏ธ **Modular Architecture** - Clean separation of concerns for easy extension -- ๐Ÿ“ฆ **Auto Directory Creation** - Creates necessary directories on first run - -## ๐Ÿ› ๏ธ Technology Stack - -- **Language:** Rust (2024 edition) -- **HTTP Client:** reqwest with blocking mode -- **Excel:** rust_xlsxwriter -- **Environment:** dotenv -- **Date/Time:** chrono - -## ๐Ÿ“‹ Prerequisites - -- Rust 1.70+ (with Cargo) -- Valid Antares B2B API credentials (usercode & password) -- Write access to create `log/`, `out/`, and `antares.json` at repo root - -## ๐Ÿ“ฅ Installation +## Quick Start ```bash -# Clone the repository -git clone https://github.com/yourusername/antares_get_data.git -cd antares_get_data - -# Create .env from template cp .env.example .env - -# Configure your credentials -nano .env # or your favorite editor -``` - -## โš™๏ธ Configuration - -Edit `.env` with your Antares credentials and output preferences: - -```env -# Antares B2B API credentials -ANTARES_USERCODE=your_usercode -ANTARES_PASSWORD=your_password_hash - -# Output path for Excel file -# - Directory: Creates 'antares.xlsx' inside -# - File path (*.xlsx): Creates file at exact location -OUT=out -``` - -### OUT Path Examples - -```env -OUT=out # โ†’ out/antares.xlsx -OUT=exports/data.xlsx # โ†’ exports/data.xlsx -OUT=/tmp/antares/report.xlsx # โ†’ /tmp/antares/report.xlsx -``` - -## ๐Ÿš€ Usage - -```bash -# Build the project +# Edit .env with your credentials and output path cargo build --release - -# Run the data exporter -cargo run - -# Or run the compiled binary directly ./target/release/antares_get_data ``` -### What Happens on Execution +## Configuration -1. โœ… **Initialization** - Logger created, output directory prepared -2. ๐Ÿ” **Credential Loading** - Env vars validated and loaded -3. ๐ŸŒ **API Request** - Fetches product data from Antares B2B (300s timeout) -4. ๐Ÿ“Š **Data Processing** - Deserializes JSON into typed structs -5. ๐Ÿ“ **JSON Export** - Saves raw response to `antares.json` -6. ๐Ÿ“‹ **Excel Export** - Generates filtered, formatted Excel file -7. ๐Ÿ“‹ **Logging** - All events logged to `log/YYYY-MM-DD.log` + terminal - -## ๐Ÿ“‹ Excel Output - -The generated Excel file contains 8 columns of curated product data: - -| Column | Source | Notes | -|--------|--------|-------| -| BESZCIKKSZAM | cikkszam | Product ID (required) | -| GYCIKKSZAM | cikkszam | Duplicate of BESZCIKKSZAM | -| BESZCIKKNEV | cikk_megnevezes_rovid / cikk_megnevezes | Product name (required) | -| GYARTO | Constant: "EGYEB" | Manufacturer code | -| CIKKAZON | vonalkod | Barcode (if available) | -| KESZLET | szabad_keszlet | Available stock | -| ME | mennyisegi_egyseg_kod | Unit of measure | -| EGYSEGAR | netto_kisker_ar / "Alap รกr" | Net unit price | - -**Filtering Rules:** -- Rows are skipped if `BESZCIKKSZAM` is empty -- Rows are skipped if both `BESZCIKKNEV` sources are empty -- Product name prefers short form (`cikk_megnevezes_rovid`), falls back to full form -- Unit price prefers direct field; searches `cikk_jellemzok` for "Alap รกr" if zero - -## ๐Ÿ“ Project Structure - -``` -antares_get_data/ -โ”œโ”€โ”€ src/ -โ”‚ โ”œโ”€โ”€ main.rs # Pipeline orchestration -โ”‚ โ”œโ”€โ”€ api/ -โ”‚ โ”‚ โ”œโ”€โ”€ mod.rs -โ”‚ โ”‚ โ””โ”€โ”€ client.rs # Antares B2B URL builder -โ”‚ โ”œโ”€โ”€ tools/ -โ”‚ โ”‚ โ”œโ”€โ”€ mod.rs -โ”‚ โ”‚ โ”œโ”€โ”€ excel.rs # Excel export with field mapping -โ”‚ โ”‚ โ””โ”€โ”€ logger.rs # Dual-output logging system -โ”‚ โ””โ”€โ”€ template/ -โ”‚ โ”œโ”€โ”€ mod.rs -โ”‚ โ””โ”€โ”€ antares.rs # Serde models for API schema -โ”œโ”€โ”€ .env.example # Configuration template -โ”œโ”€โ”€ Cargo.toml # Rust dependencies -โ””โ”€โ”€ README.md # This file -``` - -## ๐Ÿ—๏ธ Architecture - -### Modular Design - -- **`src/api/client.rs`** - Builds Antares B2B API URLs -- **`src/tools/excel.rs`** - Intelligent Excel export with business rules -- **`src/tools/logger.rs`** - Dual logging (terminal + file) to `log/{YYYY-MM-DD}.log` -- **`src/template/antares.rs`** - Serde models matching Antares B2B schema -- **`src/main.rs`** - Clean orchestration without implementation details - -### Pipeline Flow - -``` -Load Env Vars - โ†“ -Initialize Logger - โ†“ -Build API URL - โ†“ -Fetch from Antares B2B (300s timeout) - โ†“ -Deserialize JSON โ†’ Save to antares.json - โ†“ -Export Filtered Data โ†’ Excel (with logging) - โ†“ -Log Summary + Results -``` - -## ๐Ÿ“ Logging - -All operations are logged to two destinations simultaneously: - -**Terminal Output:** -``` -[2026-04-30 16:30:15] โ„น Starting Antares data export -[2026-04-30 16:30:22] โœ“ API call successful - Fetched 142 items -[2026-04-30 16:30:25] โœ“ Export successful - 142 rows exported to out/antares_export.xlsx -``` - -**Log Files:** `log/2026-04-30.log` (daily rotation) - -## ๐Ÿงช Development - -```bash -# Format code -cargo fmt --all -- --check - -# Lint with Clippy -cargo clippy --all-targets -- -D warnings - -# Run tests -cargo test - -# Build optimized release -cargo build --release -``` - -## ๐Ÿ“ฆ Generated Artifacts - -After running, you'll find: - -- **`antares.json`** - Full, pretty-printed API response -- **`out/antares_export.xlsx`** - Filtered Excel export (or custom path) -- **`log/YYYY-MM-DD.log`** - Daily operation log - -All are automatically created and git-ignored. - -## ๐Ÿ” Security Notes - -- โœ… Credentials stored only in `.env` (git-ignored) -- โœ… `.env.example` documents required variables without secrets -- โœ… No hardcoded credentials in source code -- โœ… API passwords transmitted over HTTPS only - -## ๐Ÿ› Troubleshooting - -**Missing ANTARES_USERCODE error:** -``` -Create .env file in repo root with: -ANTARES_USERCODE=your_code -ANTARES_PASSWORD=your_password +`.env` file: +```env +ANTARES_USERCODE=your_usercode +ANTARES_PASSWORD=your_password_hash OUT=out ``` -**Invalid OUT path error:** -``` -Ensure OUT is either: -- A directory (created if missing): OUT=out -- A .xlsx file: OUT=export/data.xlsx +`OUT` can be: +- Directory: `out` โ†’ creates `out/antares.xlsx` +- File path: `exports/data.xlsx` โ†’ creates file there +- Must be `.xlsx` extension if file path + +## How It Works + +1. Load credentials from `.env` +2. Fetch product data from Antares B2B API (300s timeout) +3. Save raw JSON to `antares.json` +4. Export filtered data to Excel +5. Log all operations to `log/YYYY-MM-DD.log` + +## Excel Output + +8 columns with selective field mapping and row filtering: + +| Column | Source | +|--------|--------| +| BESZCIKKSZAM | [cikkszam](./src/template/antares.rs#L15) (required) | +| GYCIKKSZAM | [cikkszam](./src/template/antares.rs#L15) | +| BESZCIKKNEV | [cikk_megnevezes_rovid](./src/template/antares.rs#L14) or [cikk_megnevezes](./src/template/antares.rs#L13) (required) | +| GYARTO | "EGYEB" | +| CIKKAZON | [vonalkod](./src/template/antares.rs#L26) | +| KESZLET | [szabad_keszlet](./src/template/antares.rs#L22) | +| ME | [mennyisegi_egyseg_kod](./src/template/antares.rs#L17) | +| EGYSEGAR | [netto_kisker_ar](./src/template/antares.rs#L19) or "Alap รกr" [jellemzo](./src/template/antares.rs#L34) | + +Rows skipped if `cikkszam` or product name missing. + +## Development + +```bash +cargo build +cargo fmt --all -- --check +cargo clippy --all-targets -- -D warnings +cargo test ``` -**API timeout:** -- Default timeout is 300 seconds (5 minutes) -- Check your network connection -- Verify Antares B2B service is available +## License -## ๐Ÿ“„ License - -[Add your license here] - -## ๐Ÿค Contributing - -Contributions welcome! Please follow the module structure and keep the architecture clean. - ---- - -
- -**Built with โค๏ธ for Antares B2B integration** - -
\ No newline at end of file +MIT License ยฉ 2026 Orink Hungary Kft.