Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

29.2 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

// Four opportunities at different completeness levels — this is the acceptance
// test for the whole seed. Every detail page (opportunity, rfq, quote,
// salesOrder, shipment, salesInvoice) must open without a 500 or redirect.

import type {
  ContractSpec,
  PriceBreak,
  SalesData,
  SalesOpportunitySpec,
  SalesReturnSpec,
  SalesStatusOrderSpec,
  StaggeredDeliverySpec
} from "../../types.ts";

// Priced against items.ts: ISR4-AV lists at 195,000 and BAT-700 at 13,500.
export const ISR4_PRICE_BREAKS: readonly PriceBreak[] = [
  { quantity: 1, unitPrice: 195000, leadTime: 90 },
  { quantity: 5, unitPrice: 184000, leadTime: 105, discountPercent: 0.03 },
  { quantity: 10, unitPrice: 172500, leadTime: 120, discountPercent: 0.06 },
  { quantity: 25, unitPrice: 158000, leadTime: 150, discountPercent: 0.1 }
];

export const BAT_PRICE_BREAKS: readonly PriceBreak[] = [
  { quantity: 2, unitPrice: 13500, leadTime: 30 },
  {
    quantity: 10,
    unitPrice: 12800,
    leadTime: 45,
    discountPercent: 0.05,
    shippingCost: 240
  }
];

// The Sent quote is the one the docs screenshot at /share/quote/:externalLinkId.
// The expiration offset must stay positive or the public page renders its
// Expired state instead of the quote.
export const NORTHGATE_QUOTE_EXPIRATION_OFFSET = 321;

// Three deliveries of the same make part, three weeks apart. Gives the docs a
// real delivery schedule, and three Make to Order lines with no job attached is
// what puts the "Jobs Required" / Create Jobs card on the order.
export const STAGGERED_DELIVERIES: StaggeredDeliverySpec[] = [
  { key: "1", promisedDateOffset: 22, sortOrder: 1 },
  { key: "2", promisedDateOffset: 43, sortOrder: 2 },
  { key: "3", promisedDateOffset: 64, sortOrder: 3 }
];

export const OPPORTUNITIES: SalesOpportunitySpec[] = [
  {
    log: "opportunity 1 — full chain (Army delivery order)",
    ref: "opp:orbsec",
    customer: "Army Small UAS Program Office",
    rfq: {
      ref: "rfq:orbsec",
      status: "Quoted",
      rfqDateOffset: -377,
      expirationOffset: -316,
      externalNotes:
        "Delivery order 0003 under IDIQ W58RGZ-26-D-0117 — 3 air vehicles.",
      lines: [
        {
          item: "ISR4-AV",
          customerPartId: "1550-01-701-2244",
          quantity: [3],
          order: 1
        }
      ]
    },
    quote: {
      ref: "quote:orbsec",
      createdOffset: -330,
      status: "Ordered",
      externalNotes: "Quote for 3× ISR-4 air vehicles, CLIN 0001, FOB Origin.",
      lines: [
        {
          ref: "quoteline:orbsec:sat",
          item: "ISR4-AV",
          status: "Complete",
          sortOrder: 1,
          priceBreaks: [{ quantity: 3, unitPrice: 195000, leadTime: 260 }]
        }
      ]
    },
    order: {
      ref: "so:orbsec",
      status: "In Progress",
      orderDateOffset: -302,
      customerReference: "W58RGZ-26-D-0117 DO 0003",
      lines: [
        {
          ref: "soline:orbsec:sat",
          item: "ISR4-AV",
          saleQuantity: 3,
          unitPrice: 195000,
          status: "In Progress",
          description: "CLIN 0001 — ISR-4 Air Vehicle, NSN 1550-01-701-2244"
        }
      ]
    },
    shipment: {
      ref: "shp:orbsec",
      status: "Draft",
      lines: [
        {
          item: "ISR4-AV",
          orderQuantity: 3,
          outstandingQuantity: 3,
          shippedQuantity: 0,
          unitPrice: 195000
        }
      ]
    },
    invoice: {
      ref: "inv:orbsec",
      status: "Draft",
      subtotal: 585000,
      totalAmount: 585000,
      dateIssuedOffset: -285,
      lines: [{ item: "ISR4-AV", quantity: 3, unitPrice: 195000 }]
    }
  },
  {
    log: "opportunity 2 — quote sent (Northgate subcontract)",
    ref: "opp:novasat",
    customer: "Northgate Defense Systems",
    quote: {
      ref: "quote:novasat",
      createdOffset: -20,
      assignee: "self",
      status: "Sent",
      expirationOffset: NORTHGATE_QUOTE_EXPIRATION_OFFSET,
      lines: [
        {
          ref: "quoteline:novasat:sat",
          item: "ISR4-AV",
          status: "Complete",
          sortOrder: 1,
          priceBreaks: ISR4_PRICE_BREAKS
        },
        {
          ref: "quoteline:novasat:eps",
          item: "BAT-700",
          status: "Complete",
          sortOrder: 2,
          priceBreaks: BAT_PRICE_BREAKS
        }
      ],
      externalLink: {
        ref: "quotelink:novasat",
        expiresOffset: NORTHGATE_QUOTE_EXPIRATION_OFFSET
      }
    }
  },
  {
    log: "opportunity 3 — RFQ only (Special Operations)",
    ref: "opp:apex",
    customer: "Special Operations Aviation Command",
    rfq: {
      ref: "rfq:apex",
      assignee: "self",
      status: "Ready for Quote",
      rfqDateOffset: -285,
      externalNotes:
        "Special Operations test detachment — 1 airframe for a payload integration trial.",
      lines: [
        {
          item: "AFR-100",
          customerPartId: "APX-STR-001",
          quantity: [1],
          order: 1
        }
      ]
    }
  },
  {
    log: "opportunity 4 — confirmed SO (State emergency agency)",
    ref: "opp:polar",
    customer: "State Emergency Response Agency",
    quote: {
      ref: "quote:polar",
      createdOffset: -270,
      status: "Ordered",
      lines: [
        {
          ref: "quoteline:polar:sat",
          item: "ISR4-AV",
          status: "Complete",
          sortOrder: 1,
          priceBreaks: [{ quantity: 1, unitPrice: 195000, leadTime: 240 }]
        }
      ]
    },
    order: {
      ref: "so:polar",
      status: "Confirmed",
      orderDateOffset: -255,
      lines: [
        {
          ref: "soline:polar:sat",
          item: "ISR4-AV",
          saleQuantity: 1,
          unitPrice: 195000,
          status: "Ordered"
        }
      ]
    }
  },

  {
    log: "opportunity 5 — RFQ draft (Special Operations, EMI test airframe)",
    ref: "opp:apex-frame",
    customer: "Special Operations Aviation Command",
    rfq: {
      ref: "rfq:apex-frame",
      assignee: "self",
      status: "Draft",
      rfqDateOffset: -3,
      externalNotes:
        "Inquiry being logged — second airframe for the EMI test rig.",
      lines: [
        {
          item: "AFR-100",
          customerPartId: "APX-STR-002",
          quantity: [1],
          order: 1
        }
      ]
    }
  },
  {
    log: "opportunity 6 — no-quoted RFQ, lost quote (Army armed variant)",
    ref: "opp:orbsec-crewed",
    customer: "Army Small UAS Program Office",
    rfq: {
      ref: "rfq:orbsec-crewed",
      status: "Closed",
      rfqDateOffset: -95,
      expirationOffset: -50,
      noQuoteReason: "Out of Scope",
      externalNotes:
        "Armed-payload variant — outside our product line and our export registration.",
      lines: [
        {
          item: "AVN-500",
          customerPartId: "1550-01-701-3310",
          quantity: [2],
          order: 1
        }
      ]
    },
    quote: {
      ref: "quote:orbsec-crewed",
      createdOffset: -80,
      status: "Lost",
      externalNotes: "Declined to bid the armed-payload line.",
      lines: [
        {
          ref: "quoteline:orbsec-crewed:adcs",
          item: "AVN-500",
          status: "No Quote",
          sortOrder: 1,
          priceBreaks: []
        }
      ]
    }
  },
  {
    log: "opportunity 7 — quote draft (State emergency agency, search-and-rescue configuration)",
    ref: "opp:polar-imager",
    customer: "State Emergency Response Agency",
    quote: {
      ref: "quote:polar-imager",
      createdOffset: -4,
      assignee: "self",
      status: "Draft",
      externalNotes:
        "Working draft — search-and-rescue configuration pricing in progress.",
      lines: [
        {
          ref: "quoteline:polar-imager:sat",
          configuration: {
            endurance_target_min: 55,
            datalink_band: "S-Band",
            eoir_payload: true
          },
          item: "ISR4-AV",
          status: "Not Started",
          sortOrder: 1,
          priceBreaks: [{ quantity: 1, unitPrice: 1850000, leadTime: 250 }]
        }
      ]
    }
  },
  {
    log: "opportunity 8 — partial quote (Northgate integration subsystems)",
    ref: "opp:novasat-gateway",
    customer: "Northgate Defense Systems",
    quote: {
      ref: "quote:novasat-gateway",
      createdOffset: -9,
      status: "Partial",
      expirationOffset: 45,
      externalNotes:
        "Power system line released to the customer; comms line still in engineering review.",
      lines: [
        {
          ref: "quoteline:novasat-gateway:eps",
          item: "BAT-700",
          status: "Complete",
          sortOrder: 1,
          priceBreaks: [{ quantity: 2, unitPrice: 13725, leadTime: 140 }]
        },
        {
          ref: "quoteline:novasat-gateway:comms",
          item: "COM-800",
          status: "In Progress",
          sortOrder: 2,
          priceBreaks: [{ quantity: 2, unitPrice: 144000, leadTime: 160 }]
        }
      ]
    }
  },
  {
    log: "opportunity 9 — cancelled quote (Special Operations pathfinder)",
    ref: "opp:apex-pathfinder",
    customer: "Special Operations Aviation Command",
    quote: {
      ref: "quote:apex-pathfinder",
      createdOffset: -150,
      status: "Cancelled",
      externalNotes:
        "Program funding moved to the next fiscal year before pricing was issued.",
      lines: [
        {
          ref: "quoteline:apex-pathfinder:eps",
          item: "BAT-700",
          status: "Complete",
          sortOrder: 1,
          priceBreaks: [{ quantity: 1, unitPrice: 14175, leadTime: 130 }]
        }
      ]
    }
  },
  {
    log: "opportunity 10 — expired quote (State emergency agency spare trays)",
    ref: "opp:polar-wing",
    customer: "State Emergency Response Agency",
    quote: {
      ref: "quote:polar-wing",
      createdOffset: -44,
      status: "Expired",
      expirationOffset: -14,
      externalNotes: "30-day pricing lapsed without a PO.",
      lines: [
        {
          ref: "quoteline:polar-wing:saw",
          item: "BAT-TRAY-710",
          status: "Complete",
          sortOrder: 1,
          priceBreaks: [{ quantity: 1, unitPrice: 1251, leadTime: 90 }]
        }
      ]
    }
  },
  {
    log: "sales order — Needs Approval (Army arm spares)",
    ref: "opp:orbsec-prop",
    customer: "Army Small UAS Program Office",
    order: {
      ref: "so:orbsec-prop",
      assignee: "self",
      status: "Needs Approval",
      orderDateOffset: -2,
      lines: [
        {
          ref: "soline:orbsec-prop:tank",
          item: "ARM-CF-30",
          saleQuantity: 2,
          unitPrice: 630,
          status: "Ordered"
        }
      ]
    }
  }
];

// One order per remaining job status. Tier 6 hangs exactly one job on each of
// these, so every jobStatus is reachable from an order of its own. The
// opportunities above already carry the In Progress and Ready jobs.
export const STATUS_ORDERS: SalesStatusOrderSpec[] = [
  {
    key: "planned",
    customer: "Northgate Defense Systems",
    item: "AFR-100",
    status: "Confirmed",
    lineStatus: "Ordered",
    orderDateOffset: -220,
    unitPrice: 11000
  },
  {
    key: "draft",
    customer: "Special Operations Aviation Command",
    item: "BAT-700",
    status: "Draft",
    lineStatus: "Ordered",
    orderDateOffset: -213,
    unitPrice: 13500
  },
  {
    key: "paused",
    customer: "Army Small UAS Program Office",
    item: "AVN-500",
    status: "In Progress",
    lineStatus: "In Progress",
    orderDateOffset: -268,
    unitPrice: 42000
  },
  {
    key: "completed",
    customer: "Defense Innovation Pilot Office",
    item: "COM-800",
    status: "Completed",
    lineStatus: "Completed",
    orderDateOffset: -437,
    unitPrice: 36000
  },
  {
    key: "closed",
    customer: "Northgate Defense Systems",
    item: "ARM-200",
    status: "Closed",
    lineStatus: "Completed",
    orderDateOffset: -456,
    unitPrice: 13800
  },
  {
    key: "cancelled",
    customer: "Special Operations Aviation Command",
    item: "HRN-100",
    status: "Cancelled",
    lineStatus: "Ordered",
    orderDateOffset: -339,
    unitPrice: 3400
  },
  // The foreign buyer's order. Its Norway ship-to is what makes the
  // "ITAR UAS — US ship-to only" rule flag the line: it stays Draft until a
  // DSP-5 export license is approved.
  {
    key: "nordic-export",
    customer: "Nordic Defence Materiel Agency",
    item: "ISR4-SYS",
    status: "Draft",
    lineStatus: "Ordered",
    orderDateOffset: -6,
    unitPrice: 465000,
    customerReference: "NDMA-2026-0412",
    lineDescription: "ISR-4 Tactical UAS System — pending DSP-5 export license"
  }
];

// Released order — "To Ship and Invoice". The status is written by the app
// (confirmSalesOrder), not derived by a trigger, but it must still agree with
// what getSalesOrderStatus would compute: nothing sent and nothing invoiced.
export const RELEASED_ORDERS: SalesOpportunitySpec[] = [
  {
    log: "sales order — To Ship and Invoice (Northgate, staggered deliveries)",
    ref: "opp:toshipinvoice",
    customer: "Northgate Defense Systems",
    order: {
      ref: "so:toshipinvoice",
      assignee: "self",
      status: "To Ship and Invoice",
      orderDateOffset: -10,
      lines: STAGGERED_DELIVERIES.map((delivery) => ({
        ref: `soline:toshipinvoice:${delivery.key}`,
        // The tier appends the resolved promised date — it only exists at apply time.
        log: `  delivery ${delivery.key}`,
        item: "BAT-TRAY-710",
        saleQuantity: 30,
        unitPrice: 35000,
        status: "Ordered",
        promisedDateOffset: delivery.promisedDateOffset,
        sortOrder: delivery.sortOrder
      }))
    }
  },

  // Shipped items are well-stocked untracked buy parts (spares sold from the
  // shelf), so the ledger rows never overdraw a bin.
  {
    log: "sales order — To Invoice (Northgate, posted spare-radio shipment)",
    ref: "opp:novasat-spares",
    customer: "Northgate Defense Systems",
    order: {
      ref: "so:novasat-spares",
      status: "To Invoice",
      orderDateOffset: -30,
      lines: [
        {
          ref: "soline:novasat-spares:txrx",
          item: "RDO-MESH-2X2",
          saleQuantity: 2,
          unitPrice: 15900,
          status: "Completed"
        }
      ]
    },
    shipment: {
      ref: "shp:novasat-spares",
      status: "Posted",
      postedOffset: -18,
      lines: [
        {
          item: "RDO-MESH-2X2",
          orderQuantity: 2,
          outstandingQuantity: 0,
          shippedQuantity: 2,
          unitPrice: 15900,
          fromShelf: "A2-L2"
        }
      ]
    }
  },
  {
    log: "sales order — To Ship and Invoice (Army, partial propeller shipment)",
    ref: "opp:orbsec-thrusters",
    customer: "Army Small UAS Program Office",
    order: {
      ref: "so:orbsec-thrusters",
      status: "To Ship and Invoice",
      orderDateOffset: -21,
      lines: [
        {
          ref: "soline:orbsec-thrusters:thr",
          item: "PRP-2270-CF",
          saleQuantity: 4,
          unitPrice: 570,
          status: "In Progress"
        }
      ]
    },
    shipment: {
      ref: "shp:orbsec-thrusters",
      status: "Posted",
      postedOffset: -9,
      lines: [
        {
          item: "PRP-2270-CF",
          orderQuantity: 4,
          outstandingQuantity: 2,
          shippedQuantity: 2,
          unitPrice: 570,
          fromShelf: "A3-L1"
        }
      ]
    }
  },
  {
    log: "sales order — To Ship (Special Operations, voided motor shipment)",
    ref: "opp:apex-valves",
    customer: "Special Operations Aviation Command",
    order: {
      ref: "so:apex-valves",
      status: "To Ship",
      orderDateOffset: -14,
      lines: [
        {
          ref: "soline:apex-valves:vlv",
          item: "MTR-4114-G1",
          saleQuantity: 8,
          unitPrice: 1550,
          status: "Ordered"
        }
      ]
    },
    shipment: {
      ref: "shp:apex-valves",
      status: "Voided",
      lines: [
        {
          item: "MTR-4114-G1",
          orderQuantity: 8,
          outstandingQuantity: 8,
          shippedQuantity: 0,
          unitPrice: 1550
        }
      ]
    }
  },

  // accounting.ts settles "paid" and "partial" by these sinv keys.
  {
    log: "sales invoice — Submitted (State emergency agency isolator spares)",
    ref: "opp:polar-bearings",
    customer: "State Emergency Response Agency",
    order: {
      ref: "so:polar-bearings",
      status: "Invoiced",
      orderDateOffset: -35,
      lines: [
        {
          ref: "soline:polar-bearings:brg",
          item: "ISO-DAMP-M3",
          saleQuantity: 20,
          unitPrice: 27,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:polar-bearings",
      key: "submitted",
      status: "Submitted",
      subtotal: 540,
      totalAmount: 540,
      dateIssuedOffset: -20,
      dueDateOffset: 10,
      lines: [{ item: "ISO-DAMP-M3", quantity: 20, unitPrice: 27 }]
    }
  },
  {
    log: "sales invoice — Overdue (Northgate carbon arm)",
    ref: "opp:novasat-tank",
    customer: "Northgate Defense Systems",
    order: {
      ref: "so:novasat-tank",
      status: "Invoiced",
      orderDateOffset: -60,
      lines: [
        {
          ref: "soline:novasat-tank:tank",
          item: "ARM-CF-30",
          saleQuantity: 1,
          unitPrice: 630,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:novasat-tank",
      key: "overdue",
      status: "Overdue",
      subtotal: 630,
      totalAmount: 630,
      dateIssuedOffset: -45,
      dueDateOffset: -15,
      lines: [{ item: "ARM-CF-30", quantity: 1, unitPrice: 630 }]
    }
  },
  {
    log: "sales invoice — Paid (Army titanium fastener lot)",
    ref: "opp:orbsec-fasteners",
    customer: "Army Small UAS Program Office",
    order: {
      ref: "so:orbsec-fasteners",
      status: "Closed",
      orderDateOffset: -90,
      lines: [
        {
          ref: "soline:orbsec-fasteners:fst",
          item: "FST-M3-TI",
          saleQuantity: 500,
          unitPrice: 4,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:orbsec-fasteners",
      key: "paid",
      status: "Paid",
      subtotal: 2000,
      totalAmount: 2000,
      dateIssuedOffset: -75,
      dueDateOffset: -45,
      lines: [{ item: "FST-M3-TI", quantity: 500, unitPrice: 4 }]
    }
  },
  {
    log: "sales invoice — Partially Paid (Special Operations EO/IR gimbal)",
    ref: "opp:apex-tracker",
    customer: "Special Operations Aviation Command",
    order: {
      ref: "so:apex-tracker",
      status: "Invoiced",
      orderDateOffset: -50,
      lines: [
        {
          ref: "soline:apex-tracker:st",
          item: "GMB-EOIR-640",
          saleQuantity: 1,
          unitPrice: 42000,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:apex-tracker",
      key: "partial",
      status: "Partially Paid",
      subtotal: 42000,
      totalAmount: 42000,
      dateIssuedOffset: -38,
      dueDateOffset: -8,
      lines: [{ item: "GMB-EOIR-640", quantity: 1, unitPrice: 42000 }]
    }
  },
  {
    log: "sales invoice — Voided (State emergency agency A286 fasteners, wrong bill-to)",
    ref: "opp:polar-fasteners",
    customer: "State Emergency Response Agency",
    order: {
      ref: "so:polar-fasteners",
      status: "To Invoice",
      orderDateOffset: -28,
      lines: [
        {
          ref: "soline:polar-fasteners:fst",
          item: "FST-M5-A286",
          saleQuantity: 100,
          unitPrice: 8,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:polar-fasteners",
      key: "voided",
      status: "Voided",
      subtotal: 800,
      totalAmount: 800,
      dateIssuedOffset: -25,
      lines: [{ item: "FST-M5-A286", quantity: 100, unitPrice: 8 }]
    }
  },
  {
    log: "sales invoice — Credit Note Issued (Northgate Gen1 motors)",
    ref: "opp:novasat-valves",
    customer: "Northgate Defense Systems",
    order: {
      ref: "so:novasat-valves",
      status: "Closed",
      orderDateOffset: -70,
      lines: [
        {
          ref: "soline:novasat-valves:vlv",
          item: "MTR-4114-G1",
          saleQuantity: 2,
          unitPrice: 1425,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:novasat-valves",
      key: "credit",
      status: "Credit Note Issued",
      subtotal: 2850,
      totalAmount: 2850,
      dateIssuedOffset: -55,
      dueDateOffset: -25,
      lines: [{ item: "MTR-4114-G1", quantity: 2, unitPrice: 1425 }]
    }
  },

  // Older overdue invoices, so receivables aging fills every bucket to 61–90.
  {
    log: "sales invoice — Overdue 31–60 days (Special Operations motor spares)",
    ref: "opp:apex-valve-spares",
    customer: "Special Operations Aviation Command",
    order: {
      ref: "so:apex-valve-spares",
      status: "Invoiced",
      orderDateOffset: -90,
      lines: [
        {
          ref: "soline:apex-valve-spares:vlv",
          item: "MTR-4114-G1",
          saleQuantity: 4,
          unitPrice: 1425,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:apex-valve-spares",
      status: "Overdue",
      subtotal: 5700,
      totalAmount: 5700,
      dateIssuedOffset: -75,
      dueDateOffset: -45,
      lines: [{ item: "MTR-4114-G1", quantity: 4, unitPrice: 1425 }]
    }
  },
  {
    log: "sales invoice — Overdue 61–90 days (State emergency agency carbon arm)",
    ref: "opp:polar-tank",
    customer: "State Emergency Response Agency",
    order: {
      ref: "so:polar-tank",
      status: "Invoiced",
      orderDateOffset: -120,
      lines: [
        {
          ref: "soline:polar-tank:tank",
          item: "ARM-CF-30",
          saleQuantity: 1,
          unitPrice: 630,
          status: "Completed"
        }
      ]
    },
    invoice: {
      ref: "inv:polar-tank",
      status: "Overdue",
      subtotal: 630,
      totalAmount: 630,
      dateIssuedOffset: -105,
      dueDateOffset: -75,
      lines: [{ item: "ARM-CF-30", quantity: 1, unitPrice: 630 }]
    }
  },

  // Each line has a job of its own in production.ts (open or just completed).
  {
    log: "sales order — In Progress (Northgate subsystem spares, floor load)",
    ref: "opp:floor-novasat",
    customer: "Northgate Defense Systems",
    order: {
      ref: "so:floor-novasat",
      status: "In Progress",
      orderDateOffset: -32,
      lines: [
        {
          ref: "soline:floor-novasat:eps-pcb",
          item: "PCB-PDB-R1",
          saleQuantity: 4,
          unitPrice: 1400,
          status: "In Progress",
          promisedDateOffset: 5
        },
        {
          ref: "soline:floor-novasat:adcs-pcb",
          item: "PCB-FCB-R1",
          saleQuantity: 2,
          unitPrice: 1650,
          status: "In Progress",
          promisedDateOffset: 3
        },
        {
          ref: "soline:floor-novasat:saw",
          item: "BAT-TRAY-710",
          saleQuantity: 1,
          unitPrice: 1200,
          status: "In Progress",
          promisedDateOffset: 3
        },
        {
          ref: "soline:floor-novasat:bus",
          item: "AFR-100",
          saleQuantity: 1,
          unitPrice: 11000,
          status: "In Progress",
          promisedDateOffset: 4
        },
        {
          ref: "soline:floor-novasat:antenna",
          item: "ANT-BLADE-01",
          saleQuantity: 4,
          unitPrice: 780,
          status: "In Progress",
          promisedDateOffset: 2
        }
      ]
    }
  },
  {
    log: "sales order — In Progress (State emergency agency fleet refit, floor load)",
    ref: "opp:floor-polar",
    customer: "State Emergency Response Agency",
    order: {
      ref: "so:floor-polar",
      assignee: "self",
      status: "In Progress",
      orderDateOffset: -14,
      lines: [
        {
          ref: "soline:floor-polar:adcs-pcb",
          item: "PCB-FCB-R1",
          saleQuantity: 3,
          unitPrice: 1650,
          status: "In Progress",
          promisedDateOffset: 8
        },
        {
          ref: "soline:floor-polar:bus",
          item: "AFR-100",
          saleQuantity: 1,
          unitPrice: 11000,
          status: "In Progress",
          promisedDateOffset: 15
        },
        {
          ref: "soline:floor-polar:saw",
          item: "BAT-TRAY-710",
          saleQuantity: 2,
          unitPrice: 1200,
          status: "In Progress",
          promisedDateOffset: 10
        },
        {
          ref: "soline:floor-polar:prop",
          item: "ARM-200",
          saleQuantity: 1,
          unitPrice: 13800,
          status: "In Progress",
          promisedDateOffset: 24
        },
        {
          ref: "soline:floor-polar:comms",
          item: "COM-800",
          saleQuantity: 1,
          unitPrice: 36000,
          status: "In Progress",
          promisedDateOffset: 19
        },
        {
          ref: "soline:floor-polar:harness",
          item: "HRN-100",
          saleQuantity: 2,
          unitPrice: 3400,
          status: "In Progress",
          promisedDateOffset: 30
        }
      ]
    }
  }
];

// Quantities come from the posted shipments above; the Completed RMA books
// stock back into the shelf it shipped from.
export const SALES_RETURNS: SalesReturnSpec[] = [
  {
    key: "transponder",
    credit: {
      status: "Posted",
      dateOffset: -8,
      lines: [{ line: 1, quantity: 1 }]
    },
    status: "Completed",
    customer: "Northgate Defense Systems",
    returnReason: "Defective",
    dateOffset: -12,
    salesOrder: "so:novasat-spares",
    lines: [
      { item: "RDO-MESH-2X2", quantity: 1, unitPrice: 15900, toShelf: "A2-L2" }
    ]
  },
  {
    key: "thruster",
    status: "To Receive",
    customer: "Army Small UAS Program Office",
    returnReason: "Damaged in Transit",
    dateOffset: -5,
    salesOrder: "so:orbsec-thrusters",
    lines: [{ item: "PRP-2270-CF", quantity: 1, unitPrice: 570 }]
  },
  {
    key: "bearings",
    status: "Draft",
    customer: "State Emergency Response Agency",
    returnReason: "No Longer Needed",
    dateOffset: -1,
    salesOrder: "so:polar-bearings",
    lines: [{ item: "ISO-DAMP-M3", quantity: 4, unitPrice: 27 }]
  }
];

// One Active contract: an implementation fee and two subscriptions on Service
// items, two months in. Tier 04 marks every invoice dated up to today Billed
// Externally, so the schedule shows history without drafted invoices.
export const CONTRACTS: ContractSpec[] = [
  {
    key: "novasat-ops",
    name: "Northgate fielding support",
    customer: "Northgate Defense Systems",
    startOffset: -60,
    termMonths: 12,
    renewal: "Renew",
    renewalUpliftPercent: 5,
    billingFrequency: "Month",
    billingAlignment: "Calendar",
    billingTiming: "Advance",
    lines: [
      {
        revenueType: "One-time",
        item: "Operator & Maintainer Training",
        description: "Operator and field-level maintainer course, 8 students",
        quantity: 1,
        rate: 48000,
        startOffset: -60,
        endOffset: -31,
        revenueMethod: "Daily"
      },
      {
        revenueType: "Recurring",
        item: "Field Service Representative Support",
        description: "Field service representative, fielding of two systems",
        quantity: 2,
        rate: 14500,
        rateUnit: "Month",
        startOffset: -60,
        revenueMethod: "Even Period"
      },
      {
        revenueType: "Recurring",
        item: "MIL-STD-810H Environmental Test",
        description:
          "Quarterly environmental requalification of fielded spares",
        quantity: 1,
        rate: 12750,
        rateUnit: "Quarter",
        discountPercent: 10,
        startOffset: -60,
        revenueMethod: "Even Period"
      }
    ]
  }
];

export const defenseSales: SalesData = {
  opportunities: OPPORTUNITIES,
  statusOrders: STATUS_ORDERS,
  releasedOrders: RELEASED_ORDERS,
  salesReturns: SALES_RETURNS,
  contracts: CONTRACTS,
  customerPortals: [
    "Northgate Defense Systems",
    "Army Small UAS Program Office"
  ],
  customerBankAccounts: [
    {
      customer: "Army Small UAS Program Office",
      name: "Army program remittance (DFAS)",
      bankName: "Potomac Federal Trust (demo)",
      accountHolderName: "Army Small UAS Program Office Programs LLC",
      countryCode: "US",
      currencyCode: "USD",
      accountNumber: "DEMO-4410-2291",
      bankCode: "DEMO-054001",
      isPrimary: true
    },
    {
      customer: "Northgate Defense Systems",
      name: "Northgate operating account",
      bankName: "Bay Commerce Bank (demo)",
      accountHolderName: "Northgate Defense Systems Inc.",
      countryCode: "US",
      currencyCode: "USD",
      accountNumber: "DEMO-7730-1184",
      bankCode: "DEMO-121000",
      isPrimary: true
    },
    {
      customer: "Special Operations Aviation Command",
      name: "Special Operations disbursing account",
      bankName: "Commonwealth Scholars Bank (demo)",
      accountHolderName: "Special Operations Aviation Command Foundation",
      countryCode: "US",
      currencyCode: "USD",
      accountNumber: "DEMO-2208-5563",
      isPrimary: true
    },
    {
      customer: "State Emergency Response Agency",
      name: "State agency payables",
      bankName: "Hill Country Bank (demo)",
      accountHolderName: "State Emergency Response Agency Inc.",
      countryCode: "US",
      currencyCode: "USD",
      accountNumber: "DEMO-9051-3370",
      isPrimary: true
    }
  ]
};