UNPKG

n8n-nodes-myob

Version:

Simple n8n node to create sales orders in MYOB Business API with multiple line items

1,020 lines (827 loc) • 66 kB
# 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