# Changelog

All notable changes to this project will be documented in this file.

## [0.5.29] - 2025-09-02

### 🔧 **FIXED SKU TRANSFORMATION LOGIC FOR NULL VALUES**
- **Null SKU Preservation**: Fixed transformation logic to preserve null/empty SKU values instead of prematurely replacing with default SKU
- **Proper Fallback Routing**: Now correctly routes null SKUs to the "No SKU provided" logic path instead of the "valid SKU" path
- **Description Priority Fix**: Ensures Shopify descriptions are properly prioritized when SKU is null by preserving the original SKU state during transformation
- **Logic Flow Correction**: Fixed the core issue where null SKUs were being replaced with default SKU during transformation, causing wrong logic path execution

### Fixed
- **SKU Transformation**: Changed from `defaultSku` to `null` when original SKU is null/empty during transformation phase
- **Logic Path Routing**: Null SKUs now correctly go through the "else" branch (No SKU provided) instead of the "if" branch (valid SKU)
- **Description Priority**: Shopify descriptions now properly preserved for null/empty SKU scenarios
- **Fallback Logic**: Default SKU fallback now correctly prioritizes Shopify description over MYOB description

### Technical
- **Transformation Phase Fix**: `const itemSku = (shopifyItem.sku && shopifyItem.sku.trim() !== '') ? shopifyItem.sku.trim() : null;`
- **Processing Phase Logic**: Null SKUs now correctly trigger the "No SKU provided" branch at line 417
- **Description Preservation**: Maintains original null status so description priority logic works correctly
- **Fallback Chain**: Proper execution of Shopify → MYOB description priority for null SKUs

### Root Cause Analysis
```
PREVIOUS LOGIC FLOW (BROKEN):
Shopify SKU: null → Transform to defaultSku → if (defaultSku) branch → Uses MYOB description

NEW LOGIC FLOW (FIXED):
Shopify SKU: null → Transform to null → else branch → Prioritizes Shopify description
```

### Example Behavior
```
Shopify Line Item:
{
  "name": "Replacement Decora Switch Icon House text Room Off",
  "sku": null
}

❌ BEFORE (0.5.28): "New Item" (wrong logic path)
✅ AFTER (0.5.29): "Replacement Decora Switch Icon House text Room Off" (correct path)
```

### Status
- ✅ **Null SKU Logic Path Fixed**
- ✅ **Shopify Description Priority Restored**
- ✅ **Transformation Logic Corrected**
- ✅ **All Previous Features Maintained**

## [0.5.28] - 2025-09-02

### 🔧 **FIXED NULL SKU DESCRIPTION PRIORITY**
- **Null SKU Handling**: Fixed description priority when Shopify SKU is null/empty and falls back to default SKU
- **Shopify Description Preservation**: Now correctly prioritizes Shopify product names over MYOB descriptions when using fallback SKU
- **Logic Reordering**: Changed the condition order to check for Shopify description first, then fall back to MYOB if truly empty
- **Better Product Representation**: Null/empty SKUs now preserve meaningful product names from Shopify instead of generic MYOB descriptions

### Fixed
- **Condition Priority**: Reordered the logic to check `if (itemDescription && itemDescription.trim() !== '')` first
- **Null SKU Behavior**: When SKU is null, the node now uses Shopify product name instead of MYOB default description
- **Description Flow**: Fixed the logical flow to properly preserve external product names for fallback scenarios

### Technical
- **Logic Restructure**: Changed from negative condition checking to positive condition checking
- **Priority Enforcement**: Always check for Shopify description availability before falling back to MYOB
- **Consistent Behavior**: All fallback scenarios now follow the same description priority logic
- **Enhanced Logging**: Improved console messages to show description decision process

### Example Behavior
```
Shopify Line Item:
{
  "name": "Replacement Decora Switch Icon House text Room Off",
  "sku": null
}

MYOB Default SKU: "Misc. Automation" (Description: "New Item")

✅ BEFORE: Used "New Item" (MYOB default description)
✅ AFTER: Uses "Replacement Decora Switch Icon House text Room Off" (Shopify name)
```

### Status
- ✅ **Shopify Description Priority for Null SKUs**
- ✅ **Proper Logic Flow for Fallback Scenarios**
- ✅ **Meaningful Product Names Preserved**
- ✅ **All Previous Features Maintained**

## [0.5.27] - 2025-09-02

### 🔧 **FIXED SHOPIFY NAME FIELD PRIORITY**
- **Shopify Field Priority**: Now prioritizes 'name' field over 'title' field for Shopify line items
- **Correct Data Extraction**: Fixed description extraction to use the correct Shopify field structure
- **Product Name Accuracy**: Line items now use the proper product name from Shopify's 'name' field
- **Enhanced Compatibility**: Better handling of Shopify webhook data structure

### Fixed
- **Field Priority Order**: Changed from `shopifyItem.title || shopifyItem.name` to `shopifyItem.name || shopifyItem.title`
- **Shopify Data Structure**: Now correctly prioritizes the 'name' field which is the primary product name field in Shopify line items
- **Description Building**: Improved description construction using the correct Shopify field hierarchy

### Technical
- **Data Mapping**: Updated Shopify line item mapping to use 'name' as primary field
- **Field Hierarchy**: Now follows correct priority: name → title → description
- **Better Integration**: Improved compatibility with Shopify webhook data format

### Example Behavior
```
Shopify Line Item:
{
  "name": "Replacement Decora Switch Icon House text Room Off",
  "title": "Switch",
  "variant_title": "Black"
}

✅ BEFORE: Used "Switch" (title field)
✅ AFTER: Uses "Replacement Decora Switch Icon House text Room Off" (name field)

Final Description: "Replacement Decora Switch Icon House text Room Off - Black"
```

### Status
- ✅ **Shopify 'name' Field Prioritized**
- ✅ **Correct Product Name Extraction**
- ✅ **Enhanced Shopify Compatibility**
- ✅ **All Previous Features Maintained**

## [0.5.26] - 2025-09-02

### 🔧 **FIXED DESCRIPTION PRIORITY FOR DEFAULT SKU FALLBACKS**
- **Shopify Description Priority**: When falling back to default SKU, now prioritizes Shopify descriptions over MYOB descriptions
- **Consistent Logic**: Exact SKU matches use MYOB descriptions, fallback scenarios preserve original Shopify product descriptions
- **Improved Product Accuracy**: Non-matching SKUs maintain their descriptive product names from Shopify instead of generic default SKU descriptions
- **Enhanced Logging**: Added detailed console logs showing when Shopify vs MYOB descriptions are used for fallback scenarios

### Fixed
- **Default SKU Description Logic**: Fallback scenarios now check if Shopify description exists before using MYOB default SKU description
- **Product Name Preservation**: Items using default SKU now keep meaningful product names from source data
- **Description Override Priority**: Only uses MYOB description for default SKU when Shopify description is empty or missing

### Technical
- **Smart Fallback Logic**: Added condition to check if Shopify description exists before overriding with MYOB description
- **Three-tier Priority**: 1) Shopify description (if present), 2) MYOB Description field, 3) MYOB Name field
- **Consistent Implementation**: Applied same logic to all default SKU fallback scenarios (SKU not found, API errors, empty SKU)
- **Enhanced Debugging**: Console logs clearly indicate which description source is being used and why

### Example Behavior
```
Shopify Item: "Custom Neon Sign - Red", SKU: "CUSTOM-001" (not found in MYOB)
Default SKU: "DEFAULT-ITEM" (MYOB description: "new item")
✅ BEFORE: Used "new item" (MYOB default SKU description)
✅ AFTER: Uses "Custom Neon Sign - Red" (preserves Shopify description)

Shopify Item: No description, SKU: "MISSING-SKU" (not found in MYOB) 
Default SKU: "DEFAULT-ITEM" (MYOB description: "Standard Item")
✅ Uses "Standard Item" (MYOB description as fallback when Shopify empty)
```

### Status
- ✅ **Shopify Description Priority for Fallbacks**
- ✅ **MYOB Description Only When Shopify Empty**
- ✅ **Consistent Across All Fallback Scenarios**
- ✅ **All Previous Features Maintained**

## [0.5.25] - 2025-08-28

### 📝 **FIXED PRODUCT DESCRIPTION FIELD PRIORITY**
- **Description Field Priority**: Product descriptions now correctly prioritize MYOB `Description` field over `Name` field as requested
- **Line Items Fix**: For exact SKU matches, now uses `Description` first, falls back to `Name` only if Description is empty
- **Shipping Items Fix**: Shipping SKU descriptions also follow the same priority - `Description` field first, then `Name` as fallback
- **Business Logic Alignment**: Now properly uses the official MYOB product description field instead of name field
- **Consistent Behavior**: Both regular items and shipping items follow identical description field priority logic

### Fixed
- **Product Description Source**: Changed from prioritizing `Name` field to prioritizing `Description` field from MYOB API
- **Field Order**: `Description` → `Name` → Shopify description (previously was `Name` → `Description` → Shopify description)
- **Shipping Consistency**: Shipping items now use same description priority as regular line items
- **Console Logging**: Updated debug messages to reflect new field priority order

### Enhanced
- **Business Operations**: Now aligns with how MYOB product descriptions are typically used in business
- **Proper Field Usage**: Uses the intended MYOB field for product descriptions
- **Unified Logic**: All SKU-based lookups follow identical description field priority
- **Clear Fallback**: Name field only used when Description field is genuinely empty

### Technical
- **Field Priority Logic**: Updated both line items and shipping items to check Description field first
- **Fallback Chain**: Description → Name → Source description (Shopify/manual)
- **Debug Enhancement**: Console logs clearly show which MYOB field is being used
- **Consistent Implementation**: Same logic applied to all product lookup scenarios

### Example Behavior
```
MYOB Item: 
- Name: "LED-STRIP"
- Description: "Premium LED Strip Light 4000K Daylight"

✅ OLD: Used "LED-STRIP" (Name field)
✅ NEW: Uses "Premium LED Strip Light 4000K Daylight" (Description field)

MYOB Item:
- Name: "P&P1"
- Description: "" (empty)

✅ Uses "P&P1" (Name field as fallback)
```

### Status
- ✅ **Description Field Takes Priority Over Name Field**
- ✅ **Business Logic Alignment**
- ✅ **Consistent Line Items and Shipping Logic**
- ✅ **All Previous Features Maintained**

## [0.5.22] - 2025-08-26

### 🔧 **FIXED SHIPPING DESCRIPTION LOGIC BUG**
- **Fixed Conditional Logic**: Corrected the shipping description condition that was preventing MYOB descriptions from being used properly
- **Simplified Logic**: Removed complex conditional that was causing fallback to manual description even when MYOB description was available
- **Proper Priority**: Now correctly always uses MYOB description when available, only falls back to manual when MYOB description is empty
- **Enhanced Console Logging**: Better debug messages to show which description source is being used

### Fixed
- **Shipping Description Bug**: Previous logic was not properly overriding manual descriptions with MYOB descriptions
- **Conditional Issue**: Fixed `else if` condition that prevented MYOB descriptions from taking priority
- **Logic Simplification**: Streamlined the description selection logic to work correctly

### Technical
- **Fixed Logic Flow**: Removed problematic `else if` condition that checked if manual description was empty
- **Proper Override**: MYOB description now properly overrides manual description when available
- **Clear Fallback**: Manual description only used when MYOB description is genuinely empty or missing
- **Better Debugging**: Console logs clearly show which description source is selected

### Example Fixed Behavior
```
Shipping SKU: "P&P1" (found in MYOB with description "Express Post")
Manual Description: "Standard Shipping"
✅ NOW USES: "Express Post" (MYOB description takes priority)

Shipping SKU: "P&P2" (found in MYOB with empty description)
Manual Description: "Standard Shipping"  
✅ USES: "Standard Shipping" (fallback to manual when MYOB empty)
```

### Status
- ✅ **MYOB Description Priority Fixed**
- ✅ **Conditional Logic Corrected**
- ✅ **Proper Fallback Behavior**
- ✅ **All Previous Features Maintained**

## [0.5.21] - 2025-08-26

### 🏷️ **CONSISTENT SHIPPING DESCRIPTION LOGIC**
- **Shipping SKU Description Priority**: Shipping lines now follow the same logic as regular items - MYOB description takes priority when SKU is found
- **Consistent Behavior**: All SKU lookups (regular items and shipping) now use MYOB descriptions for exact matches
- **Smart Fallback**: Manual shipping description only used when MYOB description is empty or missing
- **Enhanced Logging**: Added console logs showing when MYOB vs manual descriptions are used for shipping items

### Enhanced
- **Description Logic**: Shipping SKUs now prioritize MYOB item descriptions (same as regular line items)
- **Unified Behavior**: All SKU-based lookups follow the same description priority logic
- **Better Consistency**: Shipping and regular items handled identically for description selection
- **Improved Debugging**: Console logs show description source for shipping line items

### Technical
- **Consistent SKU Processing**: Shipping items use same lookup and description logic as regular items
- **MYOB Description Priority**: When shipping SKU found in MYOB, always use MYOB description first
- **Fallback Logic**: Manual shipping description used only when MYOB description unavailable
- **Enhanced Console Output**: Added logging for shipping description decision process

### Example Behavior
```
Shipping SKU: "P&P1" (found in MYOB with description "Standard Postage")
✅ Uses MYOB description: "Standard Postage"

Shipping SKU: "P&P2" (found in MYOB with empty description)
Manual Description: "Express Shipping"
✅ Uses manual description: "Express Shipping"

Shipping SKU: "CUSTOM-SHIP" (found in MYOB with description "Custom Shipping Service")
Manual Description: "Special Delivery"
✅ Uses MYOB description: "Custom Shipping Service" (MYOB takes priority)
```

### Status
- ✅ **Shipping Description Logic Consistent with Items**
- ✅ **MYOB Description Priority for All SKUs**
- ✅ **Smart Fallback for Empty Descriptions**
- ✅ **All Previous Features Maintained**

## [0.5.20] - 2025-08-24

### 🔧 **FIXED NO-SKU DESCRIPTION LOGIC**
- **Corrected No-SKU Behavior**: When no SKU is provided (empty string), now preserves Shopify description instead of using MYOB default description
- **Consistent Logic**: All fallback scenarios now preserve original Shopify descriptions - only exact SKU matches use MYOB descriptions
- **Better Product Representation**: Line items without SKUs still show meaningful product names from Shopify
- **Unified Behavior**: No-SKU scenario now behaves consistently with other fallback scenarios

### Fixed
- **No-SKU Description**: Empty SKU strings now preserve Shopify product descriptions instead of overriding with default SKU description
- **Consistent Fallback Logic**: All non-exact-match scenarios now consistently preserve source descriptions
- **Product Name Accuracy**: Items without SKUs maintain their descriptive names from Shopify

### Updated Behavior
```
Shopify Item: "Special Order Item", SKU: "" (empty)
✅ BEFORE: Used default SKU description from MYOB
✅ AFTER: Uses Shopify description "Special Order Item" + default SKU for accounting

Shopify Item: "Custom Product", SKU: undefined
✅ Uses Shopify description "Custom Product" + default SKU for accounting
```

### Status
- ✅ **All Fallback Scenarios Use Source Descriptions**
- ✅ **Only Exact SKU Matches Use MYOB Descriptions**
- ✅ **Consistent Logic Across All Scenarios**
- ✅ **All Previous Features Maintained**

## [0.5.19] - 2025-08-24

### 🎯 **SMART DESCRIPTION PRIORITIZATION**
- **MYOB Description Priority**: When SKU matches exactly in MYOB, always use the MYOB item description (official product info)
- **Shopify Description Preserved**: When SKU fails and falls back to default SKU, preserve original Shopify description (actual product info)
- **Smart Logic**: Only override descriptions for exact SKU matches - fallback scenarios keep source descriptions
- **Enhanced User Experience**: Line items show meaningful descriptions - MYOB's for known items, Shopify's for unknown items

### Enhanced
- **Description Logic**: Exact SKU matches → MYOB description, fallback scenarios → preserve Shopify description
- **Better Data Accuracy**: Known products show official MYOB descriptions, unknown products show Shopify titles/variants
- **Intelligent Fallback**: When using default SKU, keeps the actual product description from Shopify
- **Business Logic**: Official catalog items use official descriptions, non-catalog items keep descriptive names

### Technical
- **Conditional Description Override**: Only applies MYOB descriptions for exact SKU matches
- **Fallback Preservation**: Default SKU scenarios preserve original item descriptions
- **Smart Detection**: Distinguishes between exact matches and fallback scenarios
- **Enhanced Logging**: Shows when MYOB vs Shopify descriptions are used

### Example Behavior
```
Shopify Item: "Premium LED Strip - 4000K Daylight", SKU: "LED-4000K"
✅ SKU Found: Uses MYOB description "LED Strip Light 4000K"

Shopify Item: "Custom Neon Sign - Blue", SKU: "CUSTOM-001" (not in MYOB)
✅ SKU Not Found: Uses Shopify description "Custom Neon Sign - Blue" + default SKU for pricing

Shopify Item: "Special Order Item", SKU: "" (empty)
✅ No SKU: Uses Shopify description "Special Order Item" + default SKU for accounting
```

### Use Cases
- ✅ **Catalog Items**: Show official MYOB product descriptions for inventory matches
- ✅ **Special Orders**: Preserve descriptive Shopify names for non-catalog items  
- ✅ **Custom Products**: Keep meaningful product names while using default SKU for accounting
- ✅ **Mixed Orders**: Handle both catalog and non-catalog items intelligently

### Status
- ✅ **Smart Description Logic Active**
- ✅ **MYOB Priority for Exact Matches**
- ✅ **Shopify Preservation for Fallbacks**
- ✅ **All Previous Features Maintained**

## [0.5.18] - 2025-08-24

### 🔧 **FIXED DATE PRESERVATION ISSUE**
- **Fixed UTC Conversion**: Order dates now preserve the local date/time from input instead of converting to UTC
- **Date Preservation Logic**: Input `2025-08-24T04:32:01+10:00` now correctly becomes `2025-08-24T04:32:01.000Z` in MYOB
- **No More Date Shifting**: Eliminates the issue where August 24th became August 23rd due to timezone conversion
- **Enhanced Date Parsing**: Uses regex parsing to extract local date/time components directly from input
- **Fallback Handling**: Maintains robust fallback for various date input formats

### Fixed
- **UTC Date Conversion Issue**: Previously input dates were converted to UTC, causing date shifting
- **Date Component Preservation**: Now preserves the exact date and time values from user input
- **Timezone Handling**: Avoids JavaScript Date object timezone conversion issues

### Technical
- **Regex Date Parsing**: Uses pattern matching to extract date/time components directly
- **Local Date Preservation**: Constructs ISO string using original local date/time values
- **Enhanced Logging**: Console shows "preserved local date/time" for clarity
- **Fallback Logic**: Multiple parsing methods for different input formats

### Example Fix
```
Input: 2025-08-24T04:32:01+10:00
Old Output: 2025-08-23T18:32:01.000Z (UTC conversion)
New Output: 2025-08-24T04:32:01.000Z (preserved local)
```

### Use Cases
- **Multi-timezone Operations**: Date stays correct regardless of user's timezone
- **Historical Data**: Past dates maintain their intended date values
- **Future Scheduling**: Scheduled dates don't shift unexpectedly
- **Data Migration**: Import dates preserve original date intentions

### Status
- ✅ **Local Date/Time Preservation**
- ✅ **No UTC Conversion Issues**
- ✅ **Enhanced Date Parsing Logic**
- ✅ **All Previous Features Maintained**

## [0.5.17] - 2025-08-24

### 📅 **ADDED ORDER DATE INPUT FIELD**
- **Custom Order Date Support**: Added new "Order Date" input field allowing you to specify the exact date for sales orders
- **ISO Date Format Support**: Accepts dates in ISO format with timezone (e.g., `2025-08-24T04:32:01+10:00`)
- **Fallback to Timezone Logic**: If no date provided, falls back to current date in n8n configured timezone
- **Full DateTime Control**: Preserves the exact date and time from your input, including timezone offset
- **Flexible Input**: Optional field - works with existing workflows without changes

### Added
- **Order Date Field**: New optional string field for specifying sales order date
- **Date Validation**: Validates date format and shows clear error messages for invalid dates
- **Console Logging**: Shows which date is being used (provided vs. fallback) for debugging
- **Format Examples**: Placeholder text shows expected date format

### Enhanced
- **Date Control**: Full control over sales order dates instead of relying on automatic date generation
- **Integration Friendly**: Perfect for processing historical orders or scheduling future orders
- **Timezone Preservation**: Maintains timezone information from input date
- **Backward Compatible**: Existing workflows continue to work without modification

### Technical
- **Date Parsing**: Robust date parsing with proper error handling
- **ISO String Conversion**: Converts input dates to proper ISO format for MYOB API
- **Fallback Logic**: Smart fallback to timezone-adjusted current date when no date provided
- **Validation**: Comprehensive date validation with helpful error messages

### Use Cases
- **Historical Orders**: Create sales orders with past dates for data migration
- **Future Orders**: Schedule sales orders for future dates
- **Exact Timing**: Specify precise date and time for order creation
- **Multi-timezone**: Handle orders from different timezones with proper date handling
- **Automated Workflows**: Pass dates from external systems (Shopify, databases, etc.)

### Example Usage
```
Order Date: 2025-08-24T04:32:01+10:00
Result: MYOB receives 2025-08-24T04:32:01.000Z

Order Date: (empty)
Result: Uses current date in n8n timezone
```

### Status
- ✅ **Custom Order Date Input Available**
- ✅ **ISO Format with Timezone Support**
- ✅ **Fallback to Timezone Logic Maintained**
- ✅ **All Previous Features Maintained**

## [0.5.16] - 2025-08-24

### 🌍 **FIXED TIMEZONE HANDLING FOR SALES ORDER DATES**
- **Fixed Date Timezone Issue**: Sales order dates now respect the n8n configured timezone instead of always using UTC
- **Localized Date Creation**: Date field in MYOB sales orders now uses the local date based on n8n timezone configuration
- **Business Logic Improvement**: Ensures sales orders are created with the correct business date regardless of server timezone

### Fixed
- **UTC Date Issue**: Previously all sales orders were created with UTC dates, now uses configured timezone
- **Date Accuracy**: Sales orders now show the correct date in MYOB based on business timezone
- **Timezone Awareness**: Node now properly respects n8n's timezone configuration for date calculations

### Technical
- **Enhanced Date Handling**: Uses `this.getTimezone()` to get n8n's configured timezone
- **Proper Date Conversion**: Converts current date to local timezone before formatting for MYOB API
- **ISO Format Preservation**: Maintains ISO date format required by MYOB while using correct local date

### Use Cases
- **Australian Business**: If n8n is configured for Australian timezone, sales orders created at 9 AM will use the correct Australian date
- **Multi-timezone Operations**: Businesses operating across timezones can ensure consistent date handling
- **Accurate Reporting**: MYOB reports will show correct creation dates matching business operations

### Status
- ✅ **Timezone-Aware Date Creation**
- ✅ **Respects n8n Configuration**
- ✅ **Maintains MYOB API Compatibility**
- ✅ **All Previous Features Maintained**

## [0.5.12] - 2025-08-10

### 🔧 **FIXED MYOB API RESPONSE HANDLING**
- **returnFullResponse Implementation**: Added `returnFullResponse: true` to HTTP requests to get complete response data
- **Status Code Handling**: Now properly captures and processes HTTP status codes from MYOB API
- **Response Body Extraction**: Correctly extracts response body from n8n's full response format
- **Success/Failure Detection**: Uses HTTP status codes to determine if sales order creation was successful
- **Enhanced Response Data**: Now returns status codes, status messages, and response headers

### Fixed
- **Missing MYOB Response Data**: MYOB API responses are now properly captured and returned
- **Success Detection**: Uses HTTP status codes (200-299) to determine success instead of relying on response body
- **Empty Response Handling**: Properly handles cases where MYOB returns success with empty body (201 Created)
- **GET Request Compatibility**: SKU lookup requests still work correctly with body extraction

### Added
- **returnFullResponse Flag**: Added to all HTTP requests to get complete response information
- **Status Code Validation**: Checks HTTP status codes to determine request success
- **Response Headers**: Now captures and returns HTTP response headers from MYOB
- **Enhanced Output Format**: Returns statusCode, statusMessage, and response headers

### Enhanced
- **Response Processing Logic**: Smart handling of full response format vs direct response format
- **Debugging Information**: Enhanced logging shows status codes and response structure
- **Success Determination**: More reliable success detection using HTTP standards
- **API Compliance**: Better alignment with REST API response patterns

### Technical
- **Full Response Format**: `{body, headers, statusCode, statusMessage}` handling implemented
- **Method-Specific Processing**: GET requests return body only, POST requests return full response
- **Transport Layer Enhancement**: Smart response format detection and extraction
- **Status Code Ranges**: 200-299 range used for success determination

### Example New Output Format
```json
{
  "success": true,
  "statusCode": 201,
  "statusMessage": "Created",
  "myobResponse": {
    "UID": "12345678-1234-1234-1234-123456789012",
    "Number": "SO-000123",
    "Date": "2025-08-10T10:30:00Z"
  },
  "responseHeaders": {
    "content-type": "application/json",
    "x-myobapi-version": "v2"
  },
  "sentPayload": { /* original payload */ }
}
```

### Status
- ✅ **MYOB API Response Data Now Captured**
- ✅ **HTTP Status Code Based Success Detection**
- ✅ **Complete Response Information Available**
- ✅ **All Previous Features Maintained**

## [0.5.11] - 2025-08-10

### 🔍 **ENHANCED MYOB API RESPONSE DEBUGGING**
- **Comprehensive Request/Response Logging**: Added detailed logging throughout the API request/response cycle
- **Response Analysis**: Enhanced debugging to identify if MYOB API responses are being received but not passed through
- **Transport Layer Debugging**: Added extensive logging to the MyobApi.request.ts transport layer
- **Response Structure Analysis**: Detailed logging of response types, properties, and content
- **Sales Order Response Tracking**: Special logging for sales order creation responses to identify missing data

### Added
- **Detailed API Request Logging**: Logs method, URL, headers, and payload information
- **Response Type Analysis**: Logs response type, null/undefined checks, and object structure
- **Sales Order Specific Debugging**: Special analysis for sales order creation responses
- **Error Response Debugging**: Enhanced error logging with full error object details
- **Response Content Validation**: Checks for expected MYOB fields like UID and Number

### Enhanced
- **Troubleshooting Capabilities**: Much more detailed logging to identify response handling issues
- **n8n OAuth2 Wrapper Analysis**: Debugging to identify if the wrapper is filtering responses
- **Console Log Visibility**: All debugging info visible in n8n console logs
- **Response Comparison**: Analysis of what MYOB should return vs what's actually received

### Technical
- **Transport Layer Enhancement**: MyobApi.request.ts now includes comprehensive debugging
- **Response Processing Analysis**: Detailed logging of how n8n's OAuth2 wrapper handles responses
- **Error Handling Improvement**: Better error logging and analysis for API failures
- **Performance Monitoring**: Tracks request/response timing and data sizes

### Debug Output Examples
```
=== MYOB API REQUEST DEBUG ===
Method: POST
Full URL: https://api.myob.com/accountright/{guid}/Sale/Order/Item
Headers: [sanitized header info]
Body size: 1234 characters

=== SALES ORDER CREATION RESPONSE ANALYSIS ===
Expected MYOB response should contain UID, Number, Date, etc.
Actual response received: [response details]

=== MYOB API RESPONSE DEBUG ===
Response type: object
Response keys: ['UID', 'Number', 'Date', ...]
```

### Status
- ✅ **Comprehensive API Debugging Active**
- ✅ **Response Analysis Enhanced**
- ✅ **Error Tracking Improved**
- ✅ **All Previous Features Maintained**

## [0.5.10] - 2025-08-10

### 🖼️ **FIXED MYOB LOGO IN PACKAGE**
- **Fixed Logo Packaging**: MYOB logo PNG file now correctly included in npm package
- **Updated Build Process**: Build script now copies PNG files from nodes/ to dist/nodes/ directory
- **Resolved Icon Display**: Node icon will now display properly in n8n interface
- **Cross-Platform Build**: Updated build script to work with PowerShell for Windows compatibility

### Fixed
- **Missing Logo File**: PNG file not included in published package tar.gz archive
- **Build Process**: TypeScript compiler wasn't copying non-JS files
- **Icon Display**: Node showed generic icon instead of MYOB logo

### Added
- **Logo Copy Step**: Build script now includes PowerShell command to copy PNG files
- **Asset Pipeline**: Automated copying of image assets during build process

### Enhanced
- **Package Completeness**: All required assets now properly included in published package
- **Professional Appearance**: MYOB logo displays correctly in n8n node interface
- **Build Reliability**: More robust build process that handles all asset types

### Technical
- **Build Script Update**: Added `powershell "Copy-Item 'nodes/*.png' 'dist/nodes/' -ErrorAction SilentlyContinue"`
- **File Structure**: PNG files now properly copied to dist/nodes/ alongside compiled JS
- **Package Contents**: Both source (nodes/) and compiled (dist/) directories include logo file

### Status
- ✅ **MYOB Logo Displays Correctly**
- ✅ **Complete Asset Pipeline**
- ✅ **Professional Node Appearance**
- ✅ **All Previous Features Maintained**

## [0.5.9] - 2025-08-10

### 🛡️ **SKU FALLBACK RESILIENCE**
- **Smart SKU Fallback**: When a SKU lookup fails, node now automatically falls back to the Default SKU instead of stopping execution
- **Improved Error Resilience**: No more workflow failures due to incorrect or missing SKUs from Shopify
- **Seamless Processing**: Orders continue to process even when some products have incorrect SKUs
- **Enhanced Console Logging**: Clear logs show when SKU fallback occurs for better troubleshooting

### Fixed
- **SKU Lookup Failures**: Node no longer fails with "Item with SKU 'WRONG-SKU' not found in MYOB" errors
- **Workflow Continuity**: Orders process successfully even with SKU mismatches
- **Automatic Recovery**: Falls back to default SKU for both missing SKUs and API lookup errors

### Added
- **Automatic SKU Fallback**: When primary SKU fails, automatically uses Default SKU
- **Enhanced Logging**: Console logs show SKU fallback process for debugging
- **Multiple Fallback Scenarios**: Handles empty SKUs, missing SKUs, and lookup failures

### Enhanced
- **Robust Order Processing**: Workflows continue running despite SKU issues
- **Better Error Handling**: Graceful fallback instead of hard failures
- **Updated Field Description**: Default SKU field now mentions fallback functionality

### Console Log Examples
```
✅ Normal: SKU 'VALID-SKU' found and processed
⚠️ Fallback: SKU 'WRONG-SKU' not found in MYOB, falling back to default SKU 'DEFAULT-ITEM'
⚠️ Fallback: No SKU provided for item, using default SKU 'DEFAULT-ITEM'
⚠️ Fallback: Failed to lookup SKU 'NETWORK-ERROR': Connection timeout, falling back to default SKU 'DEFAULT-ITEM'
```

### Use Cases
- **Shopify Integration**: Handle product SKU mismatches without stopping order processing
- **Data Quality Issues**: Continue processing even with incomplete product data
- **API Reliability**: Graceful handling of network/API errors during SKU lookups
- **Development/Testing**: Use default SKU for testing without requiring exact SKU matches

### Technical
- **Fallback Logic**: Automatically tries Default SKU when primary SKU fails
- **Error Classification**: Distinguishes between SKU not found vs API errors
- **Multiple Recovery Paths**: Handles various failure scenarios gracefully
- **Preserved Functionality**: All existing features maintained with added resilience

### Status
- ✅ **Automatic SKU Fallback Active**
- ✅ **Improved Workflow Resilience**
- ✅ **Enhanced Error Recovery**
- ✅ **All Previous Features Maintained**

## [0.5.8] - 2025-08-10

### 📈 **FIXED DISCOUNT CALCULATION + SHIPPING DESCRIPTION**
- **Fixed Discount Percentage Calculation**: Now calculates discount percentage based on total line value (unit price × quantity) instead of just unit price
- **Added Shipping Description Field**: New optional field to set custom description for shipping line items
- **Correct Multi-Quantity Discounts**: Fixes issue where items with quantity > 1 had incorrect discount percentages
- **Enhanced Shipping Control**: Can now override shipping item description or use MYOB defaults

### Fixed
- **Discount Calculation**: For items with quantity > 1, discount percentage now calculated correctly
  - Old: `(discountAmount / unitPrice) * 100` 
  - New: `(discountAmount / (unitPrice × quantity)) * 100`
- **Example**: $4.80 discount on 2×$24.00 items now shows 10% instead of 20%

### Added
- **Shipping Description Field**: Optional field to customize shipping line item description
- **Enhanced Debug Logging**: Shows unit price, quantity, and total line value in discount calculations

### Enhanced
- **Accurate Discount Percentages**: Multi-quantity line items now show correct discount percentages in MYOB
- **Better Shipping Control**: Choose between custom shipping description or MYOB item defaults
- **Improved Calculations**: More detailed logging shows the complete discount calculation process

### Example Fixed Calculation
```
Shopify Data:
- Item: Windscreens, Price: $24.00, Quantity: 2, Discount: $4.80
- Total Line Value: $48.00

Old Calculation: 4.80 / 24.00 * 100 = 20% ❌
New Calculation: 4.80 / 48.00 * 100 = 10% ✅

Console Log: "Converted discount amount 4.80 to percentage: 10% (unit price: 24, quantity: 2, total line value: 48)"
```

### Technical
- **Proper Line Total Calculation**: Discount percentage based on (unit price × quantity)
- **Shipping Description Parameter**: New `shippingDescription` field added to node interface
- **Enhanced Debugging**: More comprehensive logging for discount calculation troubleshooting

### Status
- ✅ **Correct Multi-Quantity Discount Percentages**
- ✅ **Custom Shipping Descriptions Available**
- ✅ **Enhanced Discount Calculation Logging**
- ✅ **All Previous Features Maintained**

## [0.5.7] - 2025-08-10

### 🎯 **CORRECT DISCOUNT FIELD - BUSINESS API V2 COMPLIANT**
- **Fixed Discount Field**: Changed from discount amount to `DiscountPercent` to match MYOB Business API v2 specification
- **Automatic Percentage Conversion**: Now converts Shopify discount amounts to percentages automatically
- **Proper API Compliance**: Uses correct field structure from MYOB Business API v2 documentation
- **Smart Calculation**: Calculates discount percentage as (discountAmount / unitPrice) * 100
- **Enhanced Logging**: Added conversion logging to show discount amount → percentage calculation

### Fixed
- Discount field now uses `DiscountPercent` (percentage) instead of flat discount amount
- Proper API compliance with MYOB Business API v2 Sale/Order/Item endpoint
- Automatic conversion from Shopify discount amounts to MYOB discount percentages

### Added
- Automatic discount amount to percentage conversion
- Enhanced logging showing discount conversion process
- Precision rounding to 2 decimal places for discount percentages
- Safety checks to prevent division by zero

### Enhanced
- **Shopify Compatibility**: Seamlessly converts Shopify flat discount amounts to MYOB percentages
- **API Accuracy**: Now follows exact MYOB Business API v2 field specifications
- **Better Debugging**: Logs show both original amount and calculated percentage

### Example Conversion
```
Shopify: $31.35 discount on $97.00 item
MYOB: 32.32% discount (31.35 / 97.00 * 100)

Console Log: "Converted discount amount 31.35 to percentage: 32.32% (price: 97.00)"
```

### Technical
- Uses MYOB Business API v2 Sale/Order/Item field structure
- Prevents errors by checking unitPrice > 0 before conversion
- Rounds percentages to 2 decimal places for precision
- Maintains backward compatibility with existing workflows

### Status
- ✅ **MYOB Business API v2 Compliant Discount Field**
- ✅ **Automatic Amount-to-Percentage Conversion**
- ✅ **Enhanced Conversion Logging**
- ✅ **All Previous Features Maintained**

## [0.5.6] - 2025-08-10

### 🔧 **DISCOUNT FIELD FIX + PAYLOAD VISIBILITY**
- **Fixed Discount Field Case**: Changed discount field from `"Discount"` to `"discount"` (lowercase) to match MYOB EXO API documentation
- **Added Payload to Output**: Node output now includes the exact payload sent to MYOB for debugging purposes
- **Enhanced Output Structure**: Output now shows both MYOB response and sent payload for complete transparency
- **Better Debugging**: Can now see exactly what data is being sent to MYOB API

### Fixed
- Discount field case sensitivity (`"discount"` instead of `"Discount"`) based on MYOB EXO API docs
- Output structure now includes complete payload information

### Added
- `sentPayload` field in node output showing exact data sent to MYOB
- `myobResponse` field containing the API response from MYOB
- Enhanced output structure for better debugging and transparency

### Enhanced
- **Complete Visibility**: See both what was sent and what was received
- **Better Troubleshooting**: Full payload visibility helps identify API issues
- **API Compliance**: Lowercase field names matching MYOB EXO documentation

### Output Structure Example
```json
{
  "success": true,
  "myobResponse": { /* MYOB API Response */ },
  "sentPayload": {
    "OrderType": "Item",
    "Lines": [
      {
        "discount": 31.35,
        "UnitPrice": 97.00,
        /* ... other fields */
      }
    ]
  }
}
```

### Status
- ✅ **Lowercase Discount Field (EXO API Compliant)**
- ✅ **Complete Payload Visibility in Output**
- ✅ **Enhanced Debugging Capabilities**
- ✅ **All Previous Features Maintained**

## [0.5.5] - 2025-08-10

### 🔍 **DISCOUNT DEBUGGING ENHANCED**
- **Enhanced Discount Debugging**: Added detailed console logs for discount calculation process
- **Improved Discount Tracing**: Better visibility into Shopify discount data processing
- **Debug Logging**: Console logs now show:
  - Item processing details (SKU, price)
  - Discount allocations array content
  - Total discount fallback values
  - Individual discount allocation amounts
  - Final calculated discount amount

### Added
- Comprehensive discount debugging with console.log statements
- Step-by-step discount calculation visibility
- Enhanced troubleshooting capabilities for discount issues

### Enhanced
- **Discount Calculation Transparency**: Full visibility into discount processing logic
- **Better Troubleshooting**: Console logs help identify where discount calculations may fail
- **Debug Information**: All discount-related data logged for analysis

### Technical
- Added console.log statements throughout discount calculation process
- Improved debugging workflow for discount-related issues
- Better error tracing for Shopify discount integration

### Debug Output Example
```
Processing item: LED-FLEX-3K Price: 97.00
Discount allocations: [{"amount": "31.35"}]
Total discount: undefined
Adding discount allocation: 31.35
Final discount amount: 31.35
```

### Status
- ✅ **Enhanced Discount Debugging Active**
- ✅ **Console Logging for Troubleshooting**
- ✅ **All Previous Features Maintained**

## [0.5.4] - 2025-08-10

### 🔧 **DISCOUNT FIELD CORRECTION**
- **Fixed MYOB Discount Field**: Corrected discount field name from `DiscountAmount` to `Discount` for proper MYOB API compatibility
- **Verified Output**: Confirmed JSON output display in n8n interface shows complete MYOB API response
- **Discount Integration**: Now properly applies Shopify discount amounts using correct MYOB field name

### Fixed
- MYOB API discount field name (`Discount` instead of `DiscountAmount`)
- Discount amounts now properly applied to MYOB sales order line items
- JSON output correctly displays MYOB API response in n8n interface

### Technical
- Corrected field mapping for MYOB Business API discount structure
- Maintained all existing discount calculation logic
- Output handling confirmed working for JSON display

### Status
- ✅ **Correct MYOB Discount Field Name**
- ✅ **Shopify Discounts Applied to MYOB**
- ✅ **JSON Output Display Working**
- ✅ **All Previous Features Maintained**

## [0.5.3] - 2025-08-10

### 💰 **SHOPIFY DISCOUNT SUPPORT & IMPROVEMENTS**
- **Shopify Discount Integration**: Automatically extracts and applies Shopify discount amounts to MYOB line items
- **Smart Discount Detection**: Supports both `discount_allocations` array and `total_discount` fallback
- **MYOB Discount Field**: Adds `DiscountAmount` field to line items when discounts are present
- **Clean Shipping Items**: Shipping line items no longer include blank descriptions (uses MYOB inventory default)
- **Enhanced JSON Output**: Node now returns the complete MYOB API response as JSON for better integration

### Added
- **Discount Amount Processing**: Calculates total discount per line item from Shopify data
- **DiscountAmount Field**: Adds discount amounts directly to MYOB sales order line items
- **Shopify discount_allocations Support**: Handles multiple discount applications per line item
- **Complete API Response**: Returns full MYOB API response for downstream processing

### Enhanced
- **Discount Calculation**: Automatically sums all discount allocations per line item
- **Fallback Logic**: Uses `total_discount` if `discount_allocations` not available
- **Clean Integration**: Shipping items use MYOB inventory descriptions (no blank overrides)
- **Better Output**: Full JSON response from MYOB API for better workflow integration

### Technical
- **Discount Processing**: Robust parsing of Shopify discount structures
- **Error Handling**: Graceful handling of missing discount data
- **API Response**: Complete MYOB response preserved in node output
- **Performance**: Efficient discount calculation with reduce operations

### Example Discount Processing
```
Shopify Line Item:
- Price: $33.00
- Discount Allocations: [{"amount": "31.35"}]
- Result: MYOB Line Item with $31.35 discount

Multiple Discounts:
- discount_allocations: [{"amount": "10.00"}, {"amount": "5.50"}]
- Result: Total discount of $15.50 applied to MYOB
```

### Status
- ✅ **Shopify Discount Support Working**
- ✅ **MYOB Discount Field Integration** 
- ✅ **Clean Shipping Line Items**
- ✅ **Complete JSON Output Response**
- ✅ **Multiple Discount Types Supported**

## [0.5.2] - 2025-08-10

### 🛠️ **FINAL BUG FIXES & API CORRECTION**
- **Fixed MYOB API Field**: Corrected Purchase Order field from `CustomerPO` and `PurchaseOrderNumber` to the correct `CustomerPurchaseOrderNumber`
- **Removed Duplicate Field**: Eliminated redundant "Customer PO Number" field - now only one "Purchase Order Number" field
- **Enhanced Execution Control**: Improved handling of multiple input items to prevent duplicate sales order creation
- **Single Sales Order Guarantee**: Node now processes all input data as a single sales order execution

### Fixed
- Correct MYOB API field mapping for Purchase Order Number (`CustomerPurchaseOrderNumber`)
- Removed duplicate purchase order fields causing confusion
- Multiple sales order creation issue (final fix)
- Input data processing to handle single execution properly

### Changed
- **Purchase Order Field**: Now uses correct MYOB API field `CustomerPurchaseOrderNumber`
- **Cleaner UI**: Removed redundant "Customer PO Number" field
- **Better Documentation**: Field descriptions updated for clarity

### Technical
- Improved input data validation and processing
- Enhanced error handling for edge cases
- Better execution flow control

### Status
- ✅ **Correct Purchase Order Field Working**
- ✅ **Single Sales Order Creation Guaranteed** 
- ✅ **Hash Symbol Auto-Removal Working**
- ✅ **Multiple Line Items Per Order Working**
- ✅ **Clean UI with Single Purchase Order Field**

## [0.5.1] - 2025-08-09

### 🐛 **CRITICAL BUG FIXES**
- **Fixed Multiple Sales Orders**: Node was creating 3 sales orders instead of 1 - now creates exactly one per execution
- **Fixed Purchase Order Number**: Purchase Order Number was missing from MYOB payload - now properly included
- **Added # Symbol Removal**: Automatically removes # symbol from Purchase Order Number (e.g., "#831811-HAS" becomes "831811-HAS")
- **Fixed Execution Loop**: Removed unnecessary loop that was processing each line item as separate sales order

### Fixed
- Multiple sales order creation issue (was creating one per line item)
- Purchase Order Number field not being sent to MYOB API
- Hash (#) symbol handling in Purchase Order Number
- Node execution structure to process single sales order with multiple line items

### Technical
- Simplified execution to process only first input item
- Fixed payload construction to include cleanedPurchaseOrderNumber
- Improved field processing and validation
- Better error handling for edge cases

### Status
- ✅ **Single Sales Order Creation Working**
- ✅ **Purchase Order Number Field Working**
- ✅ **Hash Symbol Auto-Removal Working**
- ✅ **Multiple Line Items Per Order Working**

## [0.5.0] - 2025-08-09

### 🚀 **MAJOR FEATURE UPDATE: SHIPPING & ORDER ENHANCEMENTS!**
- **Shipping Address Support**: Added 5 separate shipping address line fields that combine with newlines
- **Automatic Shipping Line Item**: Added shipping SKU and price fields - automatically added as last line item
- **Enhanced Order Fields**: Added Journal Memo, Comment, and Purchase Order Number fields
- **Complete Order Management**: Full support for comprehensive sales order creation
- **Shopify Shipping Ready**: Perfect for processing Shopify orders with shipping costs and addresses

### Added
- **Shipping Address Lines 1-5**: Separate fields that automatically combine with proper newlines (`\r\n`)
- **Shipping SKU Field**: Automatically looks up shipping item (e.g., P&P1, P&P2) and adds as line item
- **Shipping Price Field**: Sets unit price for shipping line item
- **Journal Memo Field**: Internal memo for journal entries
- **Comment Field**: Order comments and notes
- **Purchase Order Number Field**: Additional PO reference field

### Enhanced
- **Smart Shipping Address Building**: Follows your existing logic - only adds non-empty lines with newlines
- **Automatic Shipping Line Item**: If shipping SKU provided, automatically adds as last line item with quantity 1
- **Tax Code Support**: Shipping line items use default tax code UID when provided
- **Complete Order Data**: Supports all essential sales order fields for full integration

### Technical
- **Newline Handling**: Uses proper `\r\n` newline characters for MYOB compatibility
- **SKU Lookup**: Shipping SKUs go through same validation and lookup process as regular items
- **Error Handling**: Clear error messages if shipping SKU not found in MYOB
- **Optional Fields**: All new fields are optional - won't break existing workflows

### Use Cases
- ✅ **Shopify Orders**: Complete order processing including shipping addresses and costs
- ✅ **E-commerce Integration**: Handle shipping, taxes, and order metadata seamlessly
- ✅ **Custom Shipping Items**: Use your existing P&P1, P&P2 SKUs for shipping costs
- ✅ **Complete Order Tracking**: Journal memos, comments, and PO numbers for full audit trail
- ✅ **Address Management**: Multi-line shipping addresses properly formatted

### Field Mapping Example
```
Shipping Line 1: "123 Main Street"
Shipping Line 2: "Unit 5"
Shipping Line 3: "Business Park"
Shipping Line 4: "Sydney NSW 2000"
Shipping Line 5: "Australia"

Result: "123 Main Street\r\nUnit 5\r\nBusiness Park\r\nSydney NSW 2000\r\nAustralia"

Shipping SKU: "P&P1"
Shipping Price: 15.00
→ Adds line item with P&P1 at $15.00 (quantity 1)
```

## [0.4.4] - 2025-08-09

### 🔧 **DATA PARSING FIX**
- **Fixed JSON Parsing Error**: Fixed "Unexpected token 'o', "[object Obj"..." error when receiving already-parsed data
- **Smart Data Detection**: Now handles both JSON strings and already-parsed JavaScript objects/arrays
- **N8N Expression Support**: Works correctly with n8n expressions that return objects (like `{{ $json.line_items }}`)
- **Backward Compatible**: Still supports JSON string input for manual data entry

### Fixed
- JSON parsing error when data comes from n8n expressions as objects instead of strings
- Support for direct object/array input from Shopify webhooks and other data sources
- Improved error handling for different data input formats

### Enhanced
- **Flexible Input**: Automatically detects and handles string, array, or object input data
- **Error Prevention**: Better validation and error messages for invalid data formats
- **Shopify Ready**: Works seamlessly with `{{ $json.line_items }}` expressions

### Technical
- Added type checking for input data (string vs object vs array)
- Improved data parsing logic to handle n8n's dynamic data types
- Enhanced error reporting for debugging data format issues

## [0.4.3] - 2025-08-09

### 🔧 **SHOPIFY EMPTY SKU FIX**
- **Empty SKU Handling**: Fixed handling of empty SKU strings (`sku: ""`) from Shopify
- **Enhanced Data Extraction**: Improved parsing of Shopify line items with better field mapping
- **Variant Title Support**: Now includes variant_title in item description (e.g., "FlexLED 24v - 3000k")
- **Robust Price Parsing**: Better handling of string-to-number conversion for prices
- **Current Quantity Priority**: Uses `current_quantity` when available, falls back to `quantity`

### Fixed
- Empty SKU string detection (now properly uses default SKU for `sku: ""`)
- Price parsing from string values in Shopify data
- Description building with variant titles

### Enhanced
- **Smart SKU Detection**: Handles both missing SKU properties and empty SKU strings
- **Better Descriptions**: Combines title + variant_title for clearer line item descriptions
- **Shopify Field Priority**: Uses the most appropriate Shopify fields for each MYOB field

### Shopify Data Processing
```
Shopify Item 1: {"sku": "LED-FLEX-3K", "quantity": 1, "price": "97.00", "title": "FlexLED", "variant_title": "3000k"}
→ SKU: "LED-FLEX-3K", Quantity: 1, Price: 97.00, Description: "FlexLED - 3000k"

Shopify Item 2: {"sku": "", "quantity": 1, "price": "97.00", "title": "FlexLED", "variant_title": "4000k"}
→ SKU: "DEFAULT-ITEM", Quantity: 1, Price: 97.00, Description: "FlexLED - 4000k"
```

## [0.4.2] - 2025-08-09

### 🛒 **SHOPIFY DIRECT INTEGRATION!**
- **Default SKU Support**: Added default SKU field for items without SKUs
- **Default Tax Code**: Added default Tax Code UID applied to all line items
- **Shopify Data Structure**: Direct support for Shopify webhook line_items array format
- **Smart Data Extraction**: Automatically extracts sku, quantity, price, title from Shopify data
- **Fallback Values**: Uses sensible defaults for missing data (default SKU, quantity 1, price 0)
- **Seamless Integration**: Just paste {{ $json.line_items }} directly from Shopify webhook

### Added
- **Default SKU Field**: Fallback SKU when line items have empty/missing SKU
- **Default Tax Code UID Field**: Applied to all line items automatically
- **Shopify Data Parser**: Understands Shopify line_items structure natively
- **Smart Field Mapping**: Maps title→description, current_quantity→quantity automatically

### Enhanced
- **Zero Configuration**: Works directly with Shopify webhook data out of the box
- **Error Prevention**: Default values prevent failures from missing data
- **Flexible Data Sources**: Works with Shopify, WooCommerce, or any e-commerce platform

### Shopify Integration Example
```
Input Method: JSON Array
Default SKU: MISC-ITEM
Default Tax Code UID: your-gst-tax-code-uid
Line Items Data: {{ $json.line_items }}
```

## [0.4.1] - 2025-08-09

### 🔄 **DYNAMIC LINE ITEMS SUPPORT!**
- **JSON Array Input**: Added JSON input method for dynamic line items of varying sizes
- **Flexible Input Methods**: Choose between UI Form or JSON Array based on your use case
- **Perfect for Integration**: Handle Shopify orders, CSV imports, API data with varying item counts
- **n8n Expression Support**: Full compatibility with n8n expressions and data mapping
- **Comprehensive Documentation**: Added examples and use cases for dynamic data handling

### Added
- **Input Method Selection**: Toggle between "UI Form" and "JSON Array" input methods
- **JSON Line Items Field**: Accept line items as properly formatted JSON array
- **Dynamic Processing**: Handle any number of line items from external data sources
- **Expression Examples**: Provided n8n expression examples for common use cases

### Enhanced
- **User Experience**: Users can now choose the input method that works best for their workflow
- **Integration Flexibility**: Perfect for e-commerce, ERP, and bulk processing scenarios
- **Documentation**: Comprehensive examples for Shopify, CSV, and API integrations

### Use Cases
- ✅ **Shopify Integration**: Process orders with varying product counts
- ✅ **CSV/Excel Processing**: Bulk import sales orders from spreadsheets
- ✅ **API Integration**: Handle dynamic data from external systems
- ✅ **Database Queries**: Create orders from database results with variable line items

## [0.4.0] - 2025-08-09

### 🚀 **MAJOR UPGRADE: SKU AUTO-LOOKUP!**
- **SKU-Based Items**: Changed from Item UID to SKU (Item Number) - much more user-friendly!
- **Automatic Lookup**: Node automatically looks up MYOB Item UID from SKU
- **Smart Description**: Uses MYOB item description if no override provided
- **Better UX**: Users can now use familiar SKU codes instead of obscure UIDs
- **Error Handling**: Clear error messages for SKU lookup failures

### Added
- **SKU Auto-Lookup**: Automatically converts SKU to MYOB Item UID via API call
- **Dynamic Description**: Fetches item description from MYOB when not overridden
- **SKU Validation**: Proper error handling for missing or invalid SKUs

### Changed
- **BREAKING**: Item UID field changed to SKU (Item Number) field
- **Field Name**: "Item UID" → "SKU (Item Number)"
- **Lookup Process**: Node now makes additional API calls to resolve SKUs to UIDs
- **Description Logic**: Now uses MYOB item description by default

### Enhanced
- **User Experience**: Much easier to use - just enter SKU codes
- **Documentation**: Updated examples and troubleshooting for SKU usage
- **Error Messages**: More helpful error messages for SKU-related issues

### Migration Notes
- **Existing Workflows**: Need to update Item UID fields to use SKU values instead
- **Field Mapping**: Replace `itemUid` with `sku` in your workflows
- **Testing**: Verify SKUs exist in MYOB before using

## [0.3.6] - 2025-08-09

### 🏆 **MYOB SALES ORDER CREATION NOW WORKING!**
- **OAuth2 Authentication**: ✅ Successfully working!
- **TaxCode Field Added**: Added optional Tax Code UID field for line items to fix MYOB validation
- **API Integration**: ✅ Successfully creating sales orders in MYOB!
- **Error Handling**: Fixed "TaxCode is required" validation error from MYOB API

### Added
- **Tax Code UID field** for line items (optional - uses item default if not specified)
- Proper TaxCode handling in API payload construction
- Documentation for TaxCode troubleshooting

### Fixed
- MYOB "TaxCode is required" validation error
- Line item structure now includes optional TaxCode when provided

### Documentation
- Added TaxCode field information to README
- Enhanced troubleshooting section with TaxCode guidance
- Updated example with Tax Code UID usage

### Status
- ✅ **OAuth2 Authentication Working**
- ✅ **MYOB API Integration Working**
- ✅ **Sales Order Creation Working**

## [0.3.5] - 2025-08-09

### 🔙 **AUTHENTICATION REVERTED + LOGO KEPT**
- **Authentication Method**: Reverted back to `header` (as requested - this was working)
- **MYOB Logo**: Kept the official MYOB logo for better visual identification
- **Removed**: Experimental POST method configuration that wasn't needed
- **Status**: Back to working OAuth2 configuration with visual improvements

### Changed
- Authentication method reverted from `body` back to `header`
- Removed `accessTokenRequestMethod` configuration

### Kept
- Official MYOB logo (7.3kB) for node branding
- All other working OAuth2 configuration

## [0.3.4] - 2025-08-09

### 🎨 **MYOB ICON ADDED + OAUTH2 CONTENT-TYPE FIX**
- **MYOB Logo**: Added official MYOB logo to node and credentials for better visual identification
- **OAuth2 Content-Type**: Changed authentication method to `body` to fix "Unsupported content type" error
- **Token Request Method**: Explicitly set POST method for token requests
- **Better UX**: Node now displays with proper MYOB branding

### Added
- Official MYOB logo (300x300px) for node and credentials
- Proper OAuth2 token request configuration

### Fixed
- "Unsupported content type: text/plain" error in OAuth2 token exchange
- Content-Type header issue with MYOB's OAuth2 endpoint

### Changed
- Authentication method back to `body` for proper form encoding
- Added explicit POST method configuration for token requests

## [0.3.3] - 2025-08-09

### 🔄 **OAUTH2 CONFIGURATION REVERT**
- **Reverted Token URL**: Back to using `/authorize` endpoint (as this was working in 0.3.0)
- **Kept Authentication Method**: Maintained `header` authentication
- **Focus on OAuth2 Only**: Removed experimental API key authentication
- **Content-Type Issue**: Investigating MYOB's specific OAuth2 requirements

### Changed
- Access Token URL reverted to `https://secure.myob.com/oauth2/v1/authorize`
- Removed alternative API key credential option to focus on OAuth2

### Note
- If you're experiencing content-type errors, this version reverts to the configuration that was showing the MYOB login page properly
- We're working on resolving the token exchange content-type issue

## [0.3.2] - 2025-08-09

### 🔧 **OAUTH2 AUTHENTICATION FIXES**
- **Fixed Token URL**: Corrected OAuth2 token endpoint from `/authorize` to `/token`
- **Fixed Authentication Method**: Changed from `body` to `header` authentication for better MYOB compatibility
- **Enhanced Troubleshooting**: Added specific guidance for "invalid_client" OAuth2 errors
- **Improved Documentation**: Better explanation of required OAuth2 fields and setup process

### Fixed
- OAuth2 "invalid_client" authentication errors
- Incorrect access token URL endpoint
- Authentication method for MYOB OAuth2 flow

### Documentation
- Added detailed OAuth2 troubleshooting section
- Clarified all required OAuth2 credential fields
- Enhanced error resolution guidance

## [0.3.1] - 2025-08-09

### 🎯 **SIMPLIFIED USER EXPERIENCE**
- **Automatic Base URL**: No longer need to manually enter base URL - it's automatically constructed from your OAuth2 credentials
- **One less field**: Removed Base URL parameter from node configuration
- **Easier setup**: Just add your customer UID and line items, the node handles the rest
- **Better user flow**: Base URL is built internally using the company file GUID from credentials

### Changed
- Removed `baseUrl` parameter from node interface
- Base URL now automatically constructed as `https://api.myob.com/accountright/{companyFileGuid}`
- Updated documentation to reflect simplified setup process
- Updated example workflow to match new structure

### Fixed
- Eliminated potential user errors from incorrect base URL format
- Reduced configuration complexity for end users

## [0.3.0] - 2025-08-09

### 🔐 **OAUTH2 AUTHENTICATION FIXED**
- **Proper OAuth2 implementation**: Fixed OAuth2 flow to match MYOB's specific requirements
- **Correct endpoints**: Updated to use proper MYOB OAuth2 URLs
- **Better credentials**: Added detailed descriptions and proper scopes
- **Cloud API support**: Now properly handles MYOB cloud authentication
- **Troubleshooting guide**: Added common issues and solutions to README

### Added
- Detailed OAuth2 setup instructions in README
- Troubleshooting section with common issues
- Better credential field descriptions
- Proper MYOB-specific OAuth2 scopes
- Instructions for getting UIDs from MYOB

### Fixed
- OAuth2 token URL (was `/token`, now `/authorize`)
- OAuth2 authentication flow for MYOB cloud
- API key header handling for cloud requests
- Credential configuration for proper MYOB integration

### Technical
- Updated OAuth2 credentials to extend N8N's oAuth2Api properly
- Improved API request function with better header handling
- Added proper content-type and accept headers
- Enhanced error handling for authentication issues

## [0.2.0] - 2025-08-09

### ✨ **SIMPLIFIED VERSION**
- **Removed complexity**: No more confusing operations and conditionals
- **One purpose**: Create sales orders in MYOB with multiple line items
- **Easier setup**: Just 4 required fields (Base URL, Customer UID, Line Items)
- **Better UX**: Clear field names and descriptions
- **Faster**: Streamlined execution without unnecessary operations
- **Focused**: Built specifically for sales order creation - does one thing well

### Changed
- Simplified node interface to focus only on sales order creation
- Removed get/getAll operations to reduce complexity
- Improved field names and descriptions for clarity
- Moved from 'transform' to 'output' category in N8N
- Updated package description to reflect simplified functionality

### Technical
- Reduced bundle size from 24.4kB to 16.4kB
- Removed unused conditional fields and operations
- Cleaner, more maintainable code structure

## [0.1.0] - 2025-08-09

### Added
- Initial release of MYOB AccountRight node for n8n
- Sales Order resource with three operations:
  - Create (Item): Create a new sales order with item lines
  - Get All: Retrieve all sales orders with optional pagination
  - Get by ID: Retrieve a specific sales order by UID
- Support for both local and cloud MYOB AccountRight instances
- Comprehensive field support for sales orders:
  - Customer UID (required)
  - Multiple line items with quantities and prices
  - Optional fields: dates, customer PO, freight, tax codes, locations
  - Description overrides, discounts (percentage and fixed amount)
- Dual authentication support:
  - Company File credentials (required for both local and cloud)
  - OAuth2 credentials (optional, for cloud API only)
- Robust error handling with "Continue on Fail" support
- Input validation for required fields
- Automatic date handling (defaults to current date)
- TypeScript implementation with full type safety
- Comprehensive documentation and examples

### Features
- Handles both tax-inclusive and tax-exclusive pricing
- Supports multiple inventory locations
- Line-level tax code overrides
- Freight and freight tax calculation
- Journal memo support for internal tracking
- Customer purchase order reference tracking

### Technical
- Built with TypeScript 5.0+
- Follows n8n community node standards
- Proper error handling and user feedback
- Extensible architecture for future enhancements
