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

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

export 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',
};

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

export function getPurchaseOrderStatusLabel(status) {
  return PurchaseOrderStatusLabels[status] || 'Unknown';
}

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

export function isReceivingComplete(status) {
  return status >= ReceivingStatus.PartialReceived;
}

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

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

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