{
 "openapi": "3.0.3",
 "info": {
  "title": "KASTA API",
  "version": "1.0.0",
  "description": "API terbuka KASTA INDONESIA (paket Enterprise). Panduan: https://kastain.com/api. Kunci dibuat pemilik di Backoffice → API & webhook; izin per kelompok data (x-cakupan): baca / tulis."
 },
 "servers": [
  {
   "url": "https://app.kastain.com"
  }
 ],
 "components": {
  "securitySchemes": {
   "kunci": {
    "type": "http",
    "scheme": "bearer",
    "description": "Kunci API dari Backoffice"
   }
  },
  "schemas": {
   "Galat": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     }
    }
   },
   "Produk": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "nama": {
      "type": "string"
     },
     "sku": {
      "type": "string"
     },
     "harga": {
      "type": "integer"
     },
     "kategori": {
      "type": "string"
     },
     "lacakStok": {
      "type": "boolean"
     },
     "stok": {
      "type": "number"
     },
     "habis": {
      "type": "boolean"
     }
    }
   },
   "Pelanggan": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "nama": {
      "type": "string"
     },
     "hp": {
      "type": "string"
     },
     "email": {
      "type": "string"
     },
     "alamat": {
      "type": "string"
     },
     "lahir": {
      "type": "string"
     },
     "catatan": {
      "type": "string"
     },
     "perusahaan": {
      "type": "string"
     },
     "npwp": {
      "type": "string"
     },
     "poin": {
      "type": "number"
     },
     "belanja": {
      "type": "number"
     },
     "kunjungan": {
      "type": "number"
     },
     "dibuat": {
      "type": "integer"
     }
    }
   },
   "Pesanan": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "no": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "tipe": {
      "type": "string"
     },
     "kanal": {
      "type": "string"
     },
     "sumber": {
      "type": "string"
     },
     "dibuat": {
      "type": "integer"
     },
     "dibayar": {
      "type": "integer"
     },
     "total": {
      "type": "integer"
     },
     "terbayar": {
      "type": "integer"
     },
     "kasbon": {
      "type": "boolean"
     },
     "produksi": {
      "type": "boolean"
     },
     "pelanggan": {
      "type": "object",
      "properties": {
       "nama": {
        "type": "string"
       },
       "hp": {
        "type": "string"
       }
      }
     },
     "items": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "itemId": {
         "type": "string"
        },
        "nama": {
         "type": "string"
        },
        "qty": {
         "type": "number"
        },
        "harga": {
         "type": "integer"
        }
       }
      }
     },
     "bayar": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "metode": {
         "type": "string"
        },
        "jumlah": {
         "type": "integer"
        }
       }
      }
     }
    }
   }
  }
 },
 "security": [
  {
   "kunci": []
  }
 ],
 "paths": {
  "/api/v1/saya": {
   "get": {
    "summary": "Nama & izin kunci ini",
    "tags": [
     "umum"
    ],
    "responses": {
     "200": {
      "description": "Kunci & usaha",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "kunci": {
           "type": "object",
           "properties": {
            "id": {
             "type": "string"
            },
            "nama": {
             "type": "string"
            },
            "cakupan": {
             "type": "object",
             "properties": {}
            }
           }
          },
          "usaha": {
           "type": "object",
           "properties": {
            "kode": {
             "type": "string"
            },
            "nama": {
             "type": "string"
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/produk": {
   "get": {
    "summary": "Daftar produk aktif",
    "tags": [
     "produk"
    ],
    "x-cakupan": "produk",
    "responses": {
     "200": {
      "description": "Produk",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "produk": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Produk"
           }
          }
         }
        }
       }
      }
     }
    }
   },
   "post": {
    "summary": "Tambah produk",
    "tags": [
     "produk"
    ],
    "x-cakupan": "produk",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "nama": {
          "type": "string"
         },
         "harga": {
          "type": "integer"
         },
         "sku": {
          "type": "string"
         },
         "kategori": {
          "type": "string"
         },
         "kategoriId": {
          "type": "string"
         },
         "lacakStok": {
          "type": "boolean"
         },
         "hpp": {
          "type": "integer"
         },
         "minStok": {
          "type": "number"
         },
         "aktif": {
          "type": "boolean"
         }
        },
        "required": [
         "nama",
         "harga"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Dibuat",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "id": {
           "type": "string"
          },
          "kategoriBaru": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/produk/ubah": {
   "post": {
    "summary": "Ubah produk (isi yang berubah saja)",
    "tags": [
     "produk"
    ],
    "x-cakupan": "produk",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "nama": {
          "type": "string"
         },
         "harga": {
          "type": "integer"
         },
         "sku": {
          "type": "string"
         },
         "kategori": {
          "type": "string"
         },
         "kategoriId": {
          "type": "string"
         },
         "aktif": {
          "type": "boolean"
         },
         "minStok": {
          "type": "number"
         }
        },
        "required": [
         "id"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Diubah",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "id": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/kategori": {
   "get": {
    "summary": "Daftar kategori",
    "tags": [
     "produk"
    ],
    "x-cakupan": "produk",
    "responses": {
     "200": {
      "description": "Kategori",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "kategori": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "nama": {
              "type": "string"
             },
             "induk": {
              "type": "string"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/stok": {
   "get": {
    "summary": "Stok produk yang dilacak (+ per varian)",
    "tags": [
     "produk"
    ],
    "x-cakupan": "produk",
    "responses": {
     "200": {
      "description": "Stok",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "stok": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "nama": {
              "type": "string"
             },
             "stok": {
              "type": "number"
             },
             "varian": {
              "type": "array",
              "items": {
               "type": "object",
               "properties": {
                "varian": {
                 "type": "string"
                },
                "stok": {
                 "type": "number"
                }
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/stok/sesuaikan": {
   "post": {
    "summary": "Hitung stok / rusak (log stok + jurnal selisih)",
    "tags": [
     "produk"
    ],
    "x-cakupan": "produk",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "itemId": {
          "type": "string"
         },
         "varian": {
          "type": "string"
         },
         "jenis": {
          "type": "string",
          "enum": [
           "hitung",
           "rusak"
          ]
         },
         "q": {
          "type": "number"
         },
         "ref": {
          "type": "string"
         },
         "catatan": {
          "type": "string"
         },
         "awal": {
          "type": "boolean"
         }
        },
        "required": [
         "itemId",
         "jenis",
         "q",
         "ref"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Tercatat",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "no": {
           "type": "string"
          },
          "stok": {
           "type": "number"
          },
          "selisih": {
           "type": "number"
          },
          "nilai": {
           "type": "integer"
          },
          "ulang": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/pesanan": {
   "get": {
    "summary": "Pesanan yang berubah sejak waktu tertentu",
    "tags": [
     "pesanan"
    ],
    "x-cakupan": "pesanan",
    "parameters": [
     {
      "name": "sejak",
      "in": "query",
      "required": false,
      "description": "Milidetik; ambil yang berubah setelah waktu ini (ulang dengan \"berikut\")",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "batas",
      "in": "query",
      "required": false,
      "description": "Jumlah per halaman",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Pesanan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "pesanan": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Pesanan"
           }
          },
          "berikut": {
           "type": "integer"
          }
         }
        }
       }
      }
     }
    }
   },
   "post": {
    "summary": "Buat pesanan (masuk ke kasir untuk diterima)",
    "tags": [
     "pesanan"
    ],
    "x-cakupan": "pesanan",
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "schema": {
       "type": "string"
      },
      "description": "Dipakai sebagai ref bila ref kosong"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "items": {
          "type": "array",
          "items": {
           "type": "object",
           "properties": {
            "itemId": {
             "type": "string"
            },
            "qty": {
             "type": "number"
            },
            "varian": {
             "type": "string"
            }
           }
          }
         },
         "pelanggan": {
          "type": "object",
          "properties": {
           "nama": {
            "type": "string"
           },
           "hp": {
            "type": "string"
           }
          }
         },
         "kanal": {
          "type": "string"
         },
         "catatan": {
          "type": "string"
         },
         "ref": {
          "type": "string"
         }
        },
        "required": [
         "items"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Dibuat / sudah ada",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "no": {
           "type": "string"
          },
          "cek": {
           "type": "string"
          },
          "ulang": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/pesanan/rincian": {
   "get": {
    "summary": "Rincian satu pesanan",
    "tags": [
     "pesanan"
    ],
    "x-cakupan": "pesanan",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": false,
      "description": "Id pesanan",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "no",
      "in": "query",
      "required": false,
      "description": "Nomor nota",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Pesanan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "pesanan": {
           "$ref": "#/components/schemas/Pesanan"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/pelanggan": {
   "get": {
    "summary": "Daftar pelanggan / cari no. HP",
    "tags": [
     "pelanggan"
    ],
    "x-cakupan": "pelanggan",
    "parameters": [
     {
      "name": "sejak",
      "in": "query",
      "required": false,
      "description": "Milidetik; ambil yang berubah setelah waktu ini (ulang dengan \"berikut\")",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "batas",
      "in": "query",
      "required": false,
      "description": "Jumlah per halaman",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "hp",
      "in": "query",
      "required": false,
      "description": "Cari no. HP",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Pelanggan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "pelanggan": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Pelanggan"
           }
          },
          "berikut": {
           "type": "integer"
          }
         }
        }
       }
      }
     }
    }
   },
   "post": {
    "summary": "Tambah pelanggan",
    "tags": [
     "pelanggan"
    ],
    "x-cakupan": "pelanggan",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "nama": {
          "type": "string"
         },
         "hp": {
          "type": "string"
         },
         "email": {
          "type": "string"
         },
         "alamat": {
          "type": "string"
         },
         "lahir": {
          "type": "string"
         },
         "catatan": {
          "type": "string"
         },
         "perusahaan": {
          "type": "string"
         },
         "npwp": {
          "type": "string"
         }
        },
        "required": [
         "nama"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Dibuat",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "id": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/pelanggan/ubah": {
   "post": {
    "summary": "Ubah pelanggan",
    "tags": [
     "pelanggan"
    ],
    "x-cakupan": "pelanggan",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "nama": {
          "type": "string"
         },
         "hp": {
          "type": "string"
         },
         "email": {
          "type": "string"
         },
         "alamat": {
          "type": "string"
         },
         "lahir": {
          "type": "string"
         },
         "catatan": {
          "type": "string"
         },
         "perusahaan": {
          "type": "string"
         },
         "npwp": {
          "type": "string"
         }
        },
        "required": [
         "id"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Diubah",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "id": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/supplier": {
   "get": {
    "summary": "Daftar supplier",
    "tags": [
     "pembelian"
    ],
    "x-cakupan": "pembelian",
    "parameters": [
     {
      "name": "sejak",
      "in": "query",
      "required": false,
      "description": "Milidetik; ambil yang berubah setelah waktu ini (ulang dengan \"berikut\")",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "batas",
      "in": "query",
      "required": false,
      "description": "Jumlah per halaman",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Supplier",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "supplier": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "nama": {
              "type": "string"
             },
             "hp": {
              "type": "string"
             },
             "email": {
              "type": "string"
             },
             "alamat": {
              "type": "string"
             }
            }
           }
          },
          "berikut": {
           "type": "integer"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/pembelian": {
   "get": {
    "summary": "Daftar pembelian",
    "tags": [
     "pembelian"
    ],
    "x-cakupan": "pembelian",
    "parameters": [
     {
      "name": "sejak",
      "in": "query",
      "required": false,
      "description": "Milidetik; ambil yang berubah setelah waktu ini (ulang dengan \"berikut\")",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "batas",
      "in": "query",
      "required": false,
      "description": "Jumlah per halaman",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Pembelian",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "pembelian": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "no": {
              "type": "string"
             },
             "supplier": {
              "type": "string"
             },
             "status": {
              "type": "string"
             },
             "dibuat": {
              "type": "integer"
             },
             "diterima": {
              "type": "integer"
             },
             "jatuhTempo": {
              "type": "integer"
             },
             "total": {
              "type": "integer"
             }
            }
           }
          },
          "berikut": {
           "type": "integer"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/ringkasan": {
   "get": {
    "summary": "Angka Dashboard",
    "tags": [
     "keuangan"
    ],
    "x-cakupan": "keuangan",
    "parameters": [
     {
      "name": "awal",
      "in": "query",
      "required": false,
      "description": "Awal hari ini (milidetik)",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "hari",
      "in": "query",
      "required": false,
      "description": "Jumlah hari (1–31)",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Ringkasan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {}
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/keuangan": {
   "get": {
    "summary": "Laba rugi, neraca, arus kas, saldo akun (buku besar)",
    "tags": [
     "keuangan"
    ],
    "x-cakupan": "keuangan",
    "parameters": [
     {
      "name": "dari",
      "in": "query",
      "required": false,
      "description": "Awal (milidetik). Bawaan: awal bulan ini",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "sampai",
      "in": "query",
      "required": false,
      "description": "Akhir (milidetik). Bawaan: sekarang",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Keuangan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "labaRugi": {
           "type": "object",
           "properties": {
            "pendapatan": {
             "type": "integer"
            },
            "modalBarangTerjual": {
             "type": "integer"
            },
            "labaKotor": {
             "type": "integer"
            },
            "beban": {
             "type": "integer"
            },
            "lainLain": {
             "type": "integer"
            },
            "labaBersih": {
             "type": "integer"
            }
           }
          },
          "neraca": {
           "type": "object",
           "properties": {
            "kasBank": {
             "type": "integer"
            },
            "piutang": {
             "type": "integer"
            },
            "aset": {
             "type": "integer"
            },
            "utangSupplier": {
             "type": "integer"
            },
            "kewajiban": {
             "type": "integer"
            },
            "ekuitas": {
             "type": "integer"
            },
            "seimbang": {
             "type": "boolean"
            }
           }
          },
          "arusKas": {
           "type": "object",
           "properties": {
            "operasi": {
             "type": "integer"
            },
            "investasi": {
             "type": "integer"
            },
            "pendanaan": {
             "type": "integer"
            }
           }
          },
          "akun": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "kode": {
              "type": "string"
             },
             "nama": {
              "type": "string"
             },
             "jenis": {
              "type": "string"
             },
             "awal": {
              "type": "integer"
             },
             "debit": {
              "type": "integer"
             },
             "kredit": {
              "type": "integer"
             },
             "akhir": {
              "type": "integer"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/keuangan/jurnal": {
   "get": {
    "summary": "Daftar jurnal",
    "tags": [
     "keuangan"
    ],
    "x-cakupan": "keuangan",
    "parameters": [
     {
      "name": "dari",
      "in": "query",
      "required": false,
      "description": "Awal (milidetik). Bawaan: awal bulan ini",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "sampai",
      "in": "query",
      "required": false,
      "description": "Akhir (milidetik). Bawaan: sekarang",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "akun",
      "in": "query",
      "required": false,
      "description": "Kode akun, mis. 1-1100",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "halaman",
      "in": "query",
      "required": false,
      "description": "Mulai 0",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Jurnal",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "jurnal": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "t": {
              "type": "integer"
             },
             "jenis": {
              "type": "string"
             },
             "ket": {
              "type": "string"
             },
             "ref": {
              "type": "string"
             },
             "baris": {
              "type": "array",
              "items": {
               "type": "object",
               "properties": {
                "kode": {
                 "type": "string"
                },
                "nama": {
                 "type": "string"
                },
                "debit": {
                 "type": "integer"
                },
                "kredit": {
                 "type": "integer"
                }
               }
              }
             }
            }
           }
          },
          "lagi": {
           "type": "boolean"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/piutang": {
   "get": {
    "summary": "Sisa piutang per nota",
    "tags": [
     "keuangan"
    ],
    "x-cakupan": "keuangan",
    "responses": {
     "200": {
      "description": "Piutang",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "piutang": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "no": {
              "type": "string"
             },
             "pelanggan": {
              "type": "string"
             },
             "t": {
              "type": "integer"
             },
             "jatuhTempo": {
              "type": "integer"
             },
             "sisa": {
              "type": "integer"
             },
             "umurHari": {
              "type": "integer"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/utang": {
   "get": {
    "summary": "Sisa utang per pembelian",
    "tags": [
     "keuangan"
    ],
    "x-cakupan": "keuangan",
    "responses": {
     "200": {
      "description": "Utang",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "utang": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "no": {
              "type": "string"
             },
             "supplier": {
              "type": "string"
             },
             "t": {
              "type": "integer"
             },
             "jatuhTempo": {
              "type": "integer"
             },
             "sisa": {
              "type": "integer"
             },
             "umurHari": {
              "type": "integer"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/bahan": {
   "get": {
    "summary": "Daftar bahan & stok",
    "tags": [
     "bahan"
    ],
    "x-cakupan": "bahan",
    "responses": {
     "200": {
      "description": "Bahan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {}
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/bahan/catat": {
   "post": {
    "summary": "Catat bahan dipakai / buang / masuk / hitung",
    "tags": [
     "bahan"
    ],
    "x-cakupan": "bahan",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "ref": {
          "type": "string"
         },
         "jenis": {
          "type": "string",
          "enum": [
           "pakai",
           "buang",
           "masuk",
           "hitung"
          ]
         },
         "t": {
          "type": "integer"
         },
         "q": {
          "type": "number"
         },
         "h": {
          "type": "number"
         },
         "awal": {
          "type": "boolean"
         },
         "catatan": {
          "type": "string"
         },
         "bahan": {
          "type": "object",
          "properties": {
           "id": {
            "type": "string"
           },
           "nama": {
            "type": "string"
           },
           "satuan": {
            "type": "string"
           }
          }
         }
        },
        "required": [
         "ref",
         "jenis",
         "q",
         "bahan"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Tercatat",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {}
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/bahan/batal": {
   "post": {
    "summary": "Batalkan catatan bahan",
    "tags": [
     "bahan"
    ],
    "x-cakupan": "bahan",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "ref": {
          "type": "string"
         }
        },
        "required": [
         "ref"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Dibatalkan",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {}
        }
       }
      }
     }
    }
   }
  }
 },
 "x-webhook": {
  "header": [
   "X-Webhook-Event",
   "X-Webhook-Id",
   "X-Webhook-Attempt",
   "X-Webhook-Signature (sha256=HMAC-SHA256 isi dengan rahasia)"
  ],
  "isi": {
   "acara": "string",
   "waktu": "milidetik",
   "usaha": "kode usaha",
   "data": "object"
  },
  "acara": [
   "pesanan.baru",
   "pesanan.lunas",
   "pesanan.batal",
   "pesanan.refund",
   "piutang.bayar",
   "pelanggan.baru",
   "produk.diubah",
   "stok.habis",
   "uji"
  ],
  "cobaUlang": "1 menit, 10 menit, 1 jam"
 }
}
