Claude-skill-registry create-purchase-invoice
Create purchase invoice in NexERP database
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/create-purchase-invoice" ~/.claude/skills/majiayu000-claude-skill-registry-create-purchase-invoice && rm -rf "$T"
manifest:
skills/data/create-purchase-invoice/SKILL.mdsource content
Create Purchase Invoice Skill
Creates a purchase invoice (PI) record in the NexERP system. A purchase invoice represents goods/services received from a supplier with payment obligations.
Usage
python main.py \ --supplier-name "ACTION BOLT" \ --invoice-date "2025-10-26" \ --items '[{"product_name": "WIRE D1.2", "quantity": 25, "unit_price": 10.50}]' \ --json
Required Fields
: Supplier name (fuzzy match supported)--supplier-name
: Invoice date (YYYY-MM-DD format)--invoice-date
: JSON array of line items--items
Item Fields
Each item must have:
: Product name or SKU (fuzzy match supported)product_name
: Quantity ordered (positive number)quantity
: Price per unitunit_price
Optional item fields:
: Line discount percentage (0-100)discount
: Line item remark/notesremark
Optional Invoice Fields
: Supplier's invoice reference number--supplier-ref
: Tax rate as decimal (default: 0.08 for 8% SST)--tax-rate
: Invoice remark/notes--remark
Output
Returns JSON with invoice details:
{ "success": true, "invoice_number": "PI25100047", "txn_id": 2185, "supplier": "ACTION BOLT & NUTS SDN BHD", "invoice_date": "2025-10-26", "items_count": 1, "subtotal": 262.50, "tax": 21.00, "grand_total": 283.50 }
Error Handling
Returns error JSON if:
- Supplier not found (suggests alternatives)
- Product not found for any item
- Invalid date format
- Invalid amounts or quantities
- Database connection fails
Database Tables
Writes to 3 tables:
- Invoice headertbl_pinvoice_txn
- Line itemstbl_pinvoice_item
- Stock movement audittbl_pinvoice_movement
Document Number Format
Invoice numbers follow pattern:
PI{YY}{MM}{NNNN}
- Example:
= October 2025, invoice #47PI25100047
Business Rules
- Supplier must exist and be active (Status_i = 1)
- Products must exist in tbl_product_code
- Invoice date must be valid date format
- Quantities must be positive
- Amounts rounded to 2 decimal places
- Default tax rate: 8% (Malaysian SST)
- Automatic calculation: SubTotal + Tax = GrandTotal
Integration
This skill is called by the Database Agent after the Document Agent extracts data from uploaded purchase invoice images.
Examples
Single Item Invoice
python main.py \ --supplier-name "ACTION" \ --invoice-date "2025-10-26" \ --items '[{"product_name": "WIRE D1.2-L105.8", "quantity": 25, "unit_price": 10.50}]' \ --json
Multi-Item Invoice
python main.py \ --supplier-name "NINGBO" \ --invoice-date "2025-10-26" \ --supplier-ref "INV-2025-ABC" \ --items '[ {"product_name": "WIRE D1.2", "quantity": 100, "unit_price": 5.00}, {"product_name": "BOLT M10", "quantity": 500, "unit_price": 0.50, "discount": 10} ]' \ --remark "Urgent delivery" \ --json
With Custom Tax Rate
python main.py \ --supplier-name "Dell" \ --invoice-date "2025-10-26" \ --items '[{"product_name": "Laptop", "quantity": 1, "unit_price": 3500.00}]' \ --tax-rate 0.06 \ --json
Testing
# Test with verbose output python main.py --supplier-name "ACTION" --invoice-date "2025-10-26" \ --items '[{"product_name": "WIRE", "quantity": 10, "unit_price": 5.00}]' \ --verbose --json # Test error handling (invalid supplier) python main.py --supplier-name "XYZ_NONEXISTENT" --invoice-date "2025-10-26" \ --items '[{"product_name": "WIRE", "quantity": 10, "unit_price": 5.00}]' \ --json
Exit Codes
: Success0
: Error (invalid input, database error)1
: Not found (supplier/product not found)2