// Purchase Order Status Codes
const PurchaseOrderStatus = {
    Canceled: 0,
    Created: 1,
    ElectronicallyReadySend: 10,
    Ordered: 11,
    Preordered: 12,
    ElectronicallySent: 13,
    ReceivingStarted: 15,
    Done: 50
};

// Receiving Status Codes
const ReceivingStatus = {
    Canceled: 0,
    Created: 1,
    PartialReceived: 30,
    FullReceived: 40,
    Paid: 50
};

// Status Code Display Names
const PurchaseOrderStatusLabels = {
    [PurchaseOrderStatus.Canceled]: 'Canceled',
    [PurchaseOrderStatus.Created]: 'Created',
    [PurchaseOrderStatus.ElectronicallyReadySend]: 'Ready to Send',
    [PurchaseOrderStatus.Ordered]: 'Ordered',
    [PurchaseOrderStatus.Preordered]: 'Preordered',
    [PurchaseOrderStatus.ElectronicallySent]: 'Sent',
    [PurchaseOrderStatus.ReceivingStarted]: 'Receiving Started',
    [PurchaseOrderStatus.Done]: 'Done'
};

const ReceivingStatusLabels = {
    [ReceivingStatus.Canceled]: 'Canceled',
    [ReceivingStatus.Created]: 'Created',
    [ReceivingStatus.PartialReceived]: 'Partially Received',
    [ReceivingStatus.FullReceived]: 'Fully Received',
    [ReceivingStatus.Paid]: 'Paid'
};

// Helper functions
function getPurchaseOrderStatusLabel(status) {
    return PurchaseOrderStatusLabels[status] || 'Unknown';
}

function getReceivingStatusLabel(status) {
    return ReceivingStatusLabels[status] || 'Unknown';
}

// Status checks
function isReceivingComplete(status) {
    return status >= ReceivingStatus.PartialReceived;
}

function isPurchaseOrderComplete(status) {
    return status === PurchaseOrderStatus.Done;
}

function isPurchaseOrderCanceled(status) {
    return status === PurchaseOrderStatus.Canceled;
}

function isReceivingCanceled(status) {
    return status === ReceivingStatus.Canceled;
}

module.exports = {
    PurchaseOrderStatus,
    ReceivingStatus,
    PurchaseOrderStatusLabels,
    ReceivingStatusLabels,
    getPurchaseOrderStatusLabel,
    getReceivingStatusLabel,
    isReceivingComplete,
    isPurchaseOrderComplete,
    isPurchaseOrderCanceled,
    isReceivingCanceled
}; 