@tocca-systems/twp-cli 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.public.md +22 -0
- package/README.md +213 -3
- package/dist/{api-command-BZVUZIOB.js → api-command-7PZCMQO5.js} +4 -4
- package/dist/{app-SNRFIHTQ.js → app-PNHDMD3V.js} +4 -4
- package/dist/{backlog-33ELMSV6.js → backlog-ISEIWKMQ.js} +1 -1
- package/dist/chunk-43OMEGNH.js +94 -0
- package/dist/{chunk-HAIZHSNZ.js → chunk-6ZUVESMI.js} +1 -1
- package/dist/chunk-7ACENLLZ.js +147 -0
- package/dist/{chunk-QBA6THJ5.js → chunk-B7YCG2T7.js} +1 -1
- package/dist/{chunk-IRT7VFG4.js → chunk-BPCK5RAB.js} +1 -1
- package/dist/{chunk-ADQD5OPN.js → chunk-BZ7ULFR3.js} +15 -14
- package/dist/{chunk-ZST7XESB.js → chunk-BZAXQOLB.js} +54 -43
- package/dist/chunk-EOSSFTNG.js +4 -0
- package/dist/chunk-FKS2Z34P.js +70 -0
- package/dist/{chunk-57HDZYSN.js → chunk-H54MGGHB.js} +1 -1
- package/dist/{chunk-TAN5I2DP.js → chunk-I4ARX6NM.js} +1 -1
- package/dist/chunk-L6AHCTQZ.js +8 -0
- package/dist/chunk-PEM3HR7L.js +58 -0
- package/dist/{chunk-VECUCVIY.js → chunk-PKWMJIBM.js} +1 -1
- package/dist/{chunk-BUZKNZ45.js → chunk-UT4FACHN.js} +5 -3
- package/dist/chunk-V3GQEUYI.js +16 -0
- package/dist/{chunk-FEOST3GF.js → chunk-VK5T7ULK.js} +1 -1
- package/dist/{chunk-LS7P3IWP.js → chunk-WV3ZKUF4.js} +25 -23
- package/dist/{chunk-OHIERIBW.js → chunk-X5IVIOGL.js} +1 -1
- package/dist/chunk-XN5TUZOT.js +48 -0
- package/dist/cli.js +247 -8
- package/dist/{commands-7PGS2PTH.js → commands-PG5VVBKO.js} +1 -1
- package/dist/company-4Z4JJVA7.js +71 -0
- package/dist/{completion-3X7HPIPM.js → completion-EFGQJDIU.js} +1 -1
- package/dist/contract-BQ76SGWV.js +86 -0
- package/dist/{department-PVUB3ZPI.js → department-YHZRSWLB.js} +1 -1
- package/dist/deposit-U4AVQH5O.js +4 -0
- package/dist/estimate-U2K7DPGH.js +173 -0
- package/dist/{inquiry-CUK2LWQK.js → inquiry-5D4U6CLU.js} +1 -1
- package/dist/invoice-2VLK2BFV.js +210 -0
- package/dist/{job-title-CZRZFVUU.js → job-title-G7MIYWVA.js} +1 -1
- package/dist/{knowledge-XYLG42MB.js → knowledge-7QDC775Q.js} +1 -1
- package/dist/{leave-DL3JPO5I.js → leave-GHFJOGNC.js} +1 -1
- package/dist/{media-CMNIZUPY.js → media-XO6X3UQT.js} +1 -1
- package/dist/{notification-ULATH7AC.js → notification-SUSR5NGQ.js} +1 -1
- package/dist/{oneshot-RYWJ6ECA.js → oneshot-UGYF2PLB.js} +1 -1
- package/dist/{position-ICOGEMRG.js → position-UY33ETLX.js} +1 -1
- package/dist/{prospect-MB2OP7L2.js → prospect-G426O6XL.js} +1 -1
- package/dist/purchase-3GGAQRE6.js +214 -0
- package/dist/receivable-TNH4KCUO.js +4 -0
- package/dist/{registry-XBYUPKQQ.js → registry-ODJB7AS3.js} +1 -1
- package/dist/{render-MTSSHDAZ.js → render-F4MRN2FQ.js} +1 -1
- package/dist/{report-JL7UJB4G.js → report-UC2PCK7B.js} +1 -1
- package/dist/run-GDYEOQQK.js +4 -0
- package/dist/sales-master-ORLR5VK4.js +71 -0
- package/dist/sales-numbering-MBFKVR2C.js +4 -0
- package/dist/supplier-payment-AFJ7G6AP.js +110 -0
- package/dist/{task-CMCHUX2D.js → task-S3BBBELE.js} +2 -2
- package/dist/{user-5JXFO56G.js → user-O7H5PD4N.js} +1 -1
- package/dist/{workflow-XBUMFS2G.js → workflow-2YL2OF2Y.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-GLBQAXWC.js +0 -6
- package/dist/chunk-O4NSYHR4.js +0 -3
- package/dist/company-GMCHRVHF.js +0 -161
- package/dist/run-6JRHCC67.js +0 -4
- package/dist/sales-GJKW7VVG.js +0 -4
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{readCsvFileText}from"./chunk-I6DWJXPC.js";import{readBody}from"./chunk-HGTG5XQ7.js";import{featureLicenseGuidance,invoiceFilters}from"./chunk-BZ7ULFR3.js";import{repeatedValues}from"./chunk-IOGVQVGD.js";import{boundedText,isoDate}from"./chunk-UDPJ2IGK.js";import{SALES_DEPOSITS_PATH,isExactNumericId,resolveNamed}from"./chunk-BZAXQOLB.js";import{ApiError}from"./chunk-IF2K4PM5.js";import{LIST_PAGING_HELP,PAGE_NUMBER_LIST_FLAGS,PAGE_NUMBER_PAGING_HELP,
|
|
4
|
+
STABLE_PAGE_ORDER,nonEmpty,pageNumberPaging,pageNumberQuery,pageRangeNotes}from"./chunk-5R4SEO3I.js";import{requireResolved,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var PATH=SALES_DEPOSITS_PATH;function salesAdminForbidden(what){return body=>body?.error==="permission_denied"?featureLicenseGuidance("\u8CA9\u58F2\u7BA1\u7406"):`${what}\u306B\u306F\u8CA9\u58F2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u7BA1\u7406\u8005\u300D\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}var FORBIDDEN=salesAdminForbidden("\u5165\u91D1");var ALLOCATION_STATUSES={
|
|
5
|
+
allocated:"\u5F15\u5F53\u6E08",shortage:"\u672A\u5165\u91D1\u6709",excess:"\u5165\u91D1\u8D85\u904E\u6709",transfer_fee_resolved:"\u624B\u6570\u6599\u51E6\u7406\u6E08"};var EXCESS_REASONS={transfer_fee:"\u632F\u8FBC\u624B\u6570\u6599",agency_fee:"\u4EE3\u884C\u624B\u6570\u6599\uFF08\u53E3\u5EA7\u632F\u66FF \u57FA\u672C\u5229\u7528\u6599\uFF09",partial:"\u4E00\u90E8\u5165\u91D1",offset:"\u76F8\u6BBA",overpayment:"\u904E\u5165\u91D1",other:"\u305D\u306E\u4ED6"};var EXCESS_TAX_CATEGORIES={taxable_purchase_10:"\
|
|
6
|
+
\u8AB2\u7A0E\u4ED5\u5165 10%",not_applicable:"\u5BFE\u8C61\u5916"};var BULK_MAX_ROWS=100;var PLAN_MAX_ITEMS=50;var PLAN_MAX_ALLOCATIONS=100;var FILE_MAX_BYTES=1024*1024;var EXCESS_NOTE_MAX_CHARS=255;var PLAN_MEMO_MAX_CHARS=1e3;var CONTENT_MAX_CHARS=1e6;var LIST_COLUMNS=["id","deposit_date","company_name","payee_name","deposit_amount","allocated_amount","unallocated_amount","allocation_status"];var GET_COLUMNS=[...LIST_COLUMNS,"memo","excess_reason","excess_amount","excess_note","excess_tax_categ\
|
|
7
|
+
ory","excess_tax_amount"];var ALLOCATION_COLUMNS=["id","invoice_id","invoice_no","invoice_title","invoice_date","allocated_amount","invoice_remaining_amount"];function labelsHelp(table){return Object.entries(table).map(([code,name])=>`${code}\uFF08${name}\uFF09`).join(" / ")}function refsOf(table){return Object.entries(table).map(([code,name])=>({id:code,name,code}))}function usageOf(op){return`twp deposit ${op} help`}function yen(value){return typeof value==="number"?`${value.toLocaleString("ja\
|
|
8
|
+
-JP")} \u5186`:"\uFF08\u4E0D\u660E\uFF09"}function text(value){return typeof value==="string"||typeof value==="number"?String(value):""}function depositIdArg(input,op,extra=0){const[raw,...rest]=input.args;const id=raw?.trim()??"";if(id==="")throw new UsageError("\u5165\u91D1\u306E ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf(op));if(rest.length>extra)throw new UsageError(`\u4F59\u5206\u306A\u5F15\u6570\u304C\u3042\u308A\u307E\u3059: ${rest.slice(extra).join(" ")}`,usageOf(
|
|
9
|
+
op));if(!isExactNumericId(id))throw new UsageError(`\u5165\u91D1\u306E ID \u306F\u5148\u982D\u306B 0 \u3092\u4ED8\u3051\u306A\u3044\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}`,"ID \u306F twp deposit list \u306E id \u5217\u3067\u3059\u3002");return id}function noArgs(input,op){if(input.args.length>0)throw new UsageError(`${op} \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,usageOf(op))}function envelope(body,what){if(!isRecord(
|
|
10
|
+
body)||body["result"]!==true)throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306E\u5F62\u304C\u60F3\u5B9A\u3068\u9055\u3044\u307E\u3059\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return body}function depositOf(body,what){const data=envelope(body,what)["data"];if(!isRecord(data)||typeof data["id"]!=="string")throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data.id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
11
|
+
return data}function allocationsOf(deposit){const rows=deposit["allocations"];if(!Array.isArray(rows))throw new ApiResponseError("\u5165\u91D1\u306E\u5FDC\u7B54\u306B allocations \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return rows.filter(isRecord)}function serverMessage(body){const message=isRecord(body)?body["message"]:void 0;return typeof message==="string"&&message!==""?[message]:[]}function describeDeposit(deposit){
|
|
12
|
+
const status=text(deposit["allocation_status"]);const parts=[text(deposit["deposit_date"]),text(deposit["company_name"])||"\uFF08\u53D6\u5F15\u5148\u306A\u3057\uFF09",`\u5165\u91D1 ${yen(deposit["deposit_amount"])}\uFF08\u5F15\u5F53\u6E08 ${yen(deposit["allocated_amount"])}${status===""?"":`\u30FB${ALLOCATION_STATUSES[status]??status}`}\uFF09`];return`ID ${text(deposit["id"])}\u30FB${parts.join("\u30FB")}`}function describeAllocation(row){const no=text(row["invoice_no"]);return`\u5F15\u5F53 ${text(
|
|
13
|
+
row["id"])}: \u8ACB\u6C42 ${no===""?`ID ${text(row["invoice_id"])}`:no}\u300C${text(row["invoice_title"])}\u300D\u3078 ${yen(row["allocated_amount"])}`}async function withDeposit(input,ctx,op,extra=0){const deposit=await ctx.resolver.salesRecord("deposit",depositIdArg(input,op,extra),"<\u5165\u91D1ID>");return withResolved(input,{deposit:JSON.stringify(deposit)})}function resolvedDeposit(input){return JSON.parse(requireResolved(input,"deposit"))}var CLOSED_MONTH_HELP="\u7DE0\u3081\u6E08\u307F\u306E\u6708\uFF08twp receivable closi\
|
|
14
|
+
ng list\uFF09\u306E\u5165\u91D1\u306F\u3001\u30B5\u30FC\u30D0\u304C\u767B\u9332\u30FB\u5165\u91D1\u65E5\u306E\u5909\u66F4\u30FB\u524A\u9664\u30FB\u5F15\u5F53\u306E\u5909\u66F4\u3092\u65AD\u308A\u307E\u3059\uFF08\u7FCC\u6708\u4ED8\u3067\u767B\u9332\u3059\u308B\u3088\u3046\u6848\u5185\u3055\u308C\u307E\u3059\uFF09\u3002";var FILTER_FLAGS=[{name:"--keyword",summary:"\u5099\u8003\u306E\u8A9E\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u90E8\u5206\u4E00\u81F4\uFF09",takesValue:true,placeholder:"<\u8A9E>"},{name:"\
|
|
15
|
+
--customer",summary:"\u53D6\u5F15\u5148\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u4F01\u696D\u540D\u30FB\u7565\u79F0\u30FB\u30AB\u30CA\u306E\u5B8C\u5168\u4E00\u81F4\u304B ID\uFF09",takesValue:true,placeholder:"<\u53D6\u5F15\u5148>"},{name:"--allocation",summary:"\u5F15\u5F53\u72B6\u614B\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u72B6\u614B>",repeatable:true},{name:"--from",summary:"\u5165\u91D1\u65E5\u304C\u3053\u306E\u65E5\u4EE5\u964D\uFF08YYYY-MM-DD\uFF09",
|
|
16
|
+
takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--to",summary:"\u5165\u91D1\u65E5\u304C\u3053\u306E\u65E5\u4EE5\u524D\uFF08YYYY-MM-DD\uFF09",takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--invoice-from",summary:"\u5F15\u304D\u5F53\u3066\u305F\u8ACB\u6C42\u306E\u8ACB\u6C42\u65E5\u304C\u3053\u306E\u65E5\u4EE5\u964D\uFF08YYYY-MM-DD\uFF09",takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--invoice-to",summary:"\u5F15\u304D\u5F53\u3066\u305F\u8ACB\u6C42\u306E\u8ACB\u6C42\u65E5\u304C\u3053\u306E\u65E5\u4EE5\u524D\uFF08YYYY-MM-DD\uFF09",
|
|
17
|
+
takesValue:true,placeholder:"<\u65E5\u4ED8>"}];var FILTER_HELP=`--allocation \u306B\u6E21\u305B\u308B\u5024: ${labelsHelp(ALLOCATION_STATUSES)}
|
|
18
|
+
\u30B3\u30FC\u30C9\u3067\u3082\u8868\u793A\u540D\u3067\u3082\u6307\u5B9A\u3067\u304D\u3001\u8907\u6570\u56DE\u6307\u5B9A\u3059\u308B\u3068\u3044\u305A\u308C\u304B\u306B\u5F53\u305F\u308B\u3082\u306E\u3092\u51FA\u3057\u307E\u3059\uFF08\u6253\u3061\u9593\u9055\u3044\u306F\u5168\u4EF6\u3067\u306F\u306A\u304F\u30A8\u30E9\u30FC\u306B\u306A\u308A\u307E\u3059\uFF09\u3002
|
|
19
|
+
--invoice-from / --invoice-to \u306F\u3001\u305D\u306E\u671F\u9593\u306E\u8ACB\u6C42\u304C1\u4EF6\u3067\u3082\u5F15\u304D\u5F53\u305F\u3063\u3066\u3044\u308B\u5165\u91D1\u306B\u7D5E\u308A\u307E\u3059\uFF08\u5F15\u5F53\u306E\u7121\u3044\u5165\u91D1\u306F\u51FA\u307E\u305B\u3093\uFF09\u3002
|
|
20
|
+
--customer \u306F\u4F01\u696D\u540D\u30FB\u7565\u79F0\u30FB\u30AB\u30CA\u306E\u5B8C\u5168\u4E00\u81F4\u304B ID\uFF08\u6570\u5B57\uFF09\u3067\u3059\u3002`;async function prepareFilters(input,ctx,op){noArgs(input,op);filterQuery(input);if(op==="list")pageNumberQuery(input);const codes=[];for(const raw of repeatedValues(input,"--allocation")){const ref=await resolveNamed(raw,refsOf(ALLOCATION_STATUSES),{flag:"--allocation",label:"\u5F15\u5F53\u72B6\u614B",scope:"\u3053\u306E CLI"});if(!codes.includes(
|
|
21
|
+
ref.id))codes.push(ref.id)}const resolved={};if(codes.length>0)resolved["allocation"]=codes.join(",");const customer=nonEmpty(input.flags,"--customer");if(customer!==void 0)resolved["customer"]=(await ctx.resolver.company(customer,{flag:"--customer",source:"sales",mustExist:true})).id;return withResolved(input,resolved)}function filterQuery(input){const resolved=input.resolved??{};return{keyword:nonEmpty(input.flags,"--keyword"),company_id:resolved["customer"],allocation_status_list:resolved["al\
|
|
22
|
+
location"],deposit_date_from:isoDate(input,"--from"),deposit_date_to:isoDate(input,"--to"),invoice_date_from:isoDate(input,"--invoice-from"),invoice_date_to:isoDate(input,"--invoice-to"),...STABLE_PAGE_ORDER}}function withStatusName(row,columns){const picked=pick(row,columns);const status=picked["allocation_status"];return typeof status==="string"?{...picked,allocation_status_name:ALLOCATION_STATUSES[status]??status}:picked}var listPaging=pageNumberPaging({label:"\u5165\u91D1\u4E00\u89A7"});function listRows(body){
|
|
23
|
+
envelope(body,"\u5165\u91D1\u4E00\u89A7");return listPaging.items(body)}var listOperation={name:"list",summary:"\u5165\u91D1\u3092\u4E00\u89A7\u3059\u308B\uFF08\u767B\u9332\u306E\u65B0\u3057\u3044\u9806\u30FB\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\uFF09",usage:"twp deposit list [--keyword <\u8A9E>] [--customer <\u53D6\u5F15\u5148>] [--allocation <\u72B6\u614B>]... [--from <\u65E5\u4ED8>] [--to <\u65E5\u4ED8>] [--invoice-from <\u65E5\u4ED8>] [--invoice-to <\u65E5\u4ED8>] [--all] [--limit <\u4EF6\u6570>]",
|
|
24
|
+
description:"\u8CA9\u58F2\u7BA1\u7406\u306E\u5165\u91D1\u3092\u4E00\u89A7\u3057\u307E\u3059\u3002\u8CA9\u58F2\u7BA1\u7406\u306E\u6A29\u9650\u304C\u300C\u7BA1\u7406\u8005\u300D\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059\u3002\n\n"+FILTER_HELP+`
|
|
25
|
+
\u7D5E\u308A\u8FBC\u307F\u5168\u4F53\u306E\u4EF6\u6570\u306F stderr \u306B\u51FA\u307E\u3059\u3002
|
|
26
|
+
|
|
27
|
+
--output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\uFF08\u5F15\u5F53\u306E\u5185\u8A33\u306F twp deposit get / allocation list \u3067\u898B\u307E\u3059\uFF09\u3002
|
|
28
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${LIST_COLUMNS.join(" / ")} / allocation_status_name\uFF09\u3067\u3059\u3002
|
|
29
|
+
|
|
30
|
+
`+LIST_PAGING_HELP+"\n"+PAGE_NUMBER_PAGING_HELP,flags:[...PAGE_NUMBER_LIST_FLAGS,...FILTER_FLAGS],paging:listPaging,forbidden:FORBIDDEN,prepare:(input,ctx)=>prepareFilters(input,ctx,"list"),plan:input=>{const{page_no,page_limit}=pageNumberQuery(input);return{method:"GET",path:PATH,query:{...filterQuery(input),page_limit,page_no}}},summarize:body=>listRows(body).map(row=>withStatusName(row,LIST_COLUMNS)),raw:listRows,notes:body=>{const sum=isRecord(body)?body["sum"]:void 0;return[...pageRangeNotes(
|
|
31
|
+
body),...typeof sum==="number"?[`\u8A72\u5F53 ${sum} \u4EF6`]:[]]}};var getOperation={name:"get",summary:"\u5165\u91D11\u4EF6\u306E\u8A73\u7D30\u3092\u8868\u793A\u3059\u308B\uFF08\u5F15\u5F53\u306E\u5185\u8A33\u3064\u304D\uFF09",usage:"twp deposit get <\u5165\u91D1ID>",description:`ID \u306F twp deposit list \u306E id \u5217\u306E\u6570\u5B57\u3067\u3059\u3002
|
|
32
|
+
|
|
33
|
+
--output json \u306F\u5165\u91D1\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u5F15\u5F53\u306E\u5185\u8A33 allocations \u3092\u542B\u3080\uFF09\u3092\u51FA\u3057\u307E\u3059\u3002
|
|
34
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${GET_COLUMNS.join(" / ")}\uFF09\u3067\u3001\u5F15\u5F53\u306E\u5185\u8A33\u306F stderr \u306B1\u884C\u305A\u3064\u51FA\u307E\u3059\u3002`,flags:[],forbidden:FORBIDDEN,plan:input=>({method:"GET",path:`${PATH}/${depositIdArg(input,"get")}`}),summarize:body=>withStatusName(depositOf(body,"\u5165\u91D1"),GET_COLUMNS),raw:body=>depositOf(body,"\u5165\u91D1"),notes:body=>{const rows=allocationsOf(depositOf(body,"\u5165\u91D1"));return rows.length===
|
|
35
|
+
0?["\u5F15\u5F53\u306F\u3042\u308A\u307E\u305B\u3093"]:[`\u5F15\u5F53 ${rows.length} \u4EF6:`,...rows.map(row=>` ${describeAllocation(row)}`)]}};var exportOperation={name:"export",summary:"\u5165\u91D1\u3092 CSV \u306B\u66F8\u304D\u51FA\u3059\uFF08--out\u30FB\u5F15\u5F53\u660E\u7D301\u884C\uFF1D1\u30EC\u30B3\u30FC\u30C9\uFF09",usage:"twp deposit export --out <\u30D1\u30B9.csv> [--force] [\u7D5E\u308A\u8FBC\u307F\u2026]",description:"\u7D5E\u308A\u8FBC\u307F\uFF08twp deposit list \u3068\u540C\u3058\uFF09\u306B\u5F53\u305F\u308B\u5165\u91D1\u3092\u3001\u753B\u9762\u306E\u300CCSV\u51FA\u529B\u300D\u3068\u540C\u3058\u5217\u306E CSV\uFF08UTF-8\u30FBBO\
|
|
36
|
+
M \u4ED8\u304D\uFF09\u3067\u66F8\u304D\u51FA\u3057\u307E\u3059\u3002\n1\u884C\u306F\u5F15\u5F53\u660E\u7D301\u4EF6\u3067\u3059\uFF081\u5165\u91D1\u306B\u8907\u6570\u306E\u8ACB\u6C42\u304C\u5F15\u304D\u5F53\u305F\u3063\u3066\u3044\u308C\u3070\u8ACB\u6C42\u3054\u3068\u306B\u884C\u304C\u5206\u304B\u308C\u3001\u5F15\u5F53\u306E\u7121\u3044\u5165\u91D1\u306F\u8ACB\u6C42\u5074\u3092\u7A7A\u6B04\u306B\u3057\u30661\u884C\uFF09\u3002\n\u305D\u306E\u305F\u3081\u884C\u6570\u306F\u5165\u91D1\u306E\u4EF6\u6570\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002--invoice-from / --invoice-to \u3092\u6307\u5B9A\u3059\u308B\u3068\u3001\u305D\u306E\u671F\u9593\u306E\u8ACB\u6C42\u306E\u5F15\u5F53\u660E\u7D30\u3060\u3051\u3092\u51FA\u3057\u307E\u3059\u3002\n\u30DA\u30FC\u30B8\u30F3\u30B0\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u65E2\u5B58\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\uFF08\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 --force\uFF09\u3002\n\n"+
|
|
37
|
+
FILTER_HELP,flags:[{name:"--out",summary:"\u66F8\u304D\u51FA\u3057\u5148\u306E\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\uFF08\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"},{name:"--force",summary:"\u65E2\u5B58\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u4E0A\u66F8\u304D\u3059\u308B",takesValue:false},...FILTER_FLAGS],download:{outFlag:"--out",forceFlag:"--force"},forbidden:FORBIDDEN,prepare:(input,ctx)=>prepareFilters(input,ctx,"export"),plan:input=>({method:"GET",path:`${PATH}/export`,query:filterQuery(
|
|
38
|
+
input)}),summarize:body=>body,raw:body=>body};var FIELD_FLAGS=[{name:"--payee",summary:"\u632F\u8FBC\u5148\uFF08\u632F\u8FBC\u5148\u30DE\u30B9\u30BF\u306E ID\u30FB\u4F5C\u6210\u3067\u306F\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u632F\u8FBC\u5148ID>"},{name:"--customer",summary:"\u53D6\u5F15\u5148\uFF08\u4F01\u696D\u540D\u30FB\u7565\u79F0\u30FB\u30AB\u30CA\u306E\u5B8C\u5168\u4E00\u81F4\u304B ID\uFF09",takesValue:true,placeholder:"<\u53D6\u5F15\u5148>"},{name:"--date",summary:"\u5165\u91D1\u65E5\uFF08YYYY-M\
|
|
39
|
+
M-DD\u30FB\u4F5C\u6210\u3067\u306F\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--amount",summary:"\u5165\u91D1\u984D\uFF08\u5186\u30FB1\u4EE5\u4E0A\u306E\u6574\u6570\u30FB\u4F5C\u6210\u3067\u306F\u5FC5\u9808\uFF09",takesValue:true,placeholder:"<\u5186>"},{name:"--memo",summary:"\u5099\u8003",takesValue:true,placeholder:"<\u5099\u8003>"},{name:"--memo-file",summary:"\u5099\u8003\u3092\u8AAD\u3080\u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,
|
|
40
|
+
placeholder:"<\u30D1\u30B9>"},{name:"--excess-reason",summary:"\u904E\u4E0D\u8DB3\u7406\u7531",takesValue:true,placeholder:"<\u7406\u7531>"},{name:"--excess-amount",summary:"\u904E\u4E0D\u8DB3\u91D1\u984D\uFF08\u5186\u30FB\u6574\u6570\u3002\u8CA0\u306E\u5024\u306F --excess-amount=-500 \u306E\u5F62\u3067\uFF09",takesValue:true,placeholder:"<\u5186>"},{name:"--excess-note",summary:`\u904E\u4E0D\u8DB3\u306E\u88DC\u8DB3\uFF08${EXCESS_NOTE_MAX_CHARS} \u6587\u5B57\u307E\u3067\uFF09`,takesValue:true,placeholder:"\
|
|
41
|
+
<\u88DC\u8DB3>"},{name:"--excess-tax-category",summary:"\u904E\u4E0D\u8DB3\u984D\u306E\u7A0E\u533A\u5206",takesValue:true,placeholder:"<\u7A0E\u533A\u5206>"},{name:"--excess-tax-amount",summary:"\u904E\u4E0D\u8DB3\u984D\u306E\u6D88\u8CBB\u7A0E\u984D\uFF08\u5186\u30FB\u6574\u6570\uFF09",takesValue:true,placeholder:"<\u5186>"}];var CLEARABLE={customer:"company_id",memo:"memo","excess-reason":"excess_reason","excess-amount":"excess_amount","excess-note":"excess_note","excess-tax-category":"excess_t\
|
|
42
|
+
ax_category","excess-tax-amount":"excess_tax_amount"};var CLEAR_FLAG={name:"--clear",summary:`\u9805\u76EE\u3092\u7A7A\u306B\u3059\u308B\uFF08${Object.keys(CLEARABLE).join(" / ")}\u30FB\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09`,takesValue:true,placeholder:"<\u9805\u76EE>",repeatable:true};var FIELD_HELP=`--excess-reason \u306B\u6E21\u305B\u308B\u5024: ${labelsHelp(EXCESS_REASONS)}
|
|
43
|
+
--excess-tax-category \u306B\u6E21\u305B\u308B\u5024: ${labelsHelp(EXCESS_TAX_CATEGORIES)}
|
|
44
|
+
\u3069\u3061\u3089\u3082\u30B3\u30FC\u30C9\u3067\u3082\u8868\u793A\u540D\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
|
|
45
|
+
\u904E\u4E0D\u8DB3\u7406\u7531\u304C\u632F\u8FBC\u624B\u6570\u6599\u30FB\u4EE3\u884C\u624B\u6570\u6599\u3067\u904E\u4E0D\u8DB3\u91D1\u984D\u304C\u6B63\u306A\u3089\u3001\u305D\u306E\u91D1\u984D\u306E\u5206\u3060\u3051\u5165\u91D1\u984D\u3092\u8D85\u3048\u3066\u8ACB\u6C42\u3078\u5F15\u304D\u5F53\u3066\u3089\u308C\u307E\u3059\uFF08\u624B\u6570\u6599\u5DEE\u5F15\uFF09\u3002
|
|
46
|
+
\u6D88\u8CBB\u7A0E\u984D\u3092\u7701\u304F\u3068\u3001\u30B5\u30FC\u30D0\u304C\u7A0E\u533A\u5206\u3068\u904E\u4E0D\u8DB3\u91D1\u984D\u304B\u3089\u88DC\u3044\u307E\u3059\u3002
|
|
47
|
+
\u632F\u8FBC\u5148\u306E ID \u306F twp payee list \u306E id \u5217\u3067\u3059\u3002`;function integerFlag(input,flag,min){const raw=input.flags.get(flag);if(raw===void 0)return void 0;const value=raw.trim();if(!/^-?(0|[1-9]\d*)$/.test(value)||!Number.isSafeInteger(Number(value)))throw new UsageError(`${flag} \u306F\u6574\u6570\uFF08\u5186\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,"\u4F8B: 110000");const n=Number(value);if(min!==void 0&&n<min)throw new UsageError(`${flag}\
|
|
48
|
+
\u306F ${min} \u4EE5\u4E0A\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`);return n}function idFlag(input,flag,label){const raw=input.flags.get(flag);if(raw===void 0)return void 0;if(!isExactNumericId(raw.trim()))throw new UsageError(`${flag} \u306E${label} ID \u306F\u5148\u982D\u306B 0 \u3092\u4ED8\u3051\u306A\u3044\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`);return Number(raw.trim())}async function codeFlag(input,flag,table,label){const raw=nonEmpty(
|
|
49
|
+
input.flags,flag);if(raw===void 0)return void 0;return(await resolveNamed(raw,refsOf(table),{flag,label,scope:"\u3053\u306E CLI"})).id}async function fieldsBody(input,ctx,mode){const body={};const payee=idFlag(input,"--payee","\u632F\u8FBC\u5148");if(payee!==void 0)body["payee_id"]=payee;const date=isoDate(input,"--date");if(date!==void 0)body["deposit_date"]=date;const amount=integerFlag(input,"--amount",1);if(amount!==void 0)body["deposit_amount"]=amount;const memo=await readBody(input,{flag:"\
|
|
50
|
+
--memo",fileFlag:"--memo-file",label:"\u5099\u8003",maxChars:CONTENT_MAX_CHARS,usage:usageOf(mode)});if(memo!==void 0)body["memo"]=memo;const reason=await codeFlag(input,"--excess-reason",EXCESS_REASONS,"\u904E\u4E0D\u8DB3\u7406\u7531");if(reason!==void 0)body["excess_reason"]=reason;const excess=integerFlag(input,"--excess-amount");if(excess!==void 0)body["excess_amount"]=excess;const note=boundedText(input,"--excess-note",{maxChars:EXCESS_NOTE_MAX_CHARS,label:"\u904E\u4E0D\u8DB3\u306E\u88DC\u8DB3"});
|
|
51
|
+
if(note!==void 0)body["excess_note"]=note;const category=await codeFlag(input,"--excess-tax-category",EXCESS_TAX_CATEGORIES,"\u7A0E\u533A\u5206");if(category!==void 0)body["excess_tax_category"]=category;const tax=integerFlag(input,"--excess-tax-amount");if(tax!==void 0)body["excess_tax_amount"]=tax;for(const raw of repeatedValues(input,"--clear")){const key=CLEARABLE[raw.trim()];if(key===void 0)throw new UsageError(`--clear \u306B\u6E21\u305B\u306A\u3044\u9805\u76EE\u3067\u3059: ${raw}`,`\u6E21\u305B\u308B\u9805\u76EE:\
|
|
52
|
+
${Object.keys(CLEARABLE).join(" / ")}`);if(key in body)throw new UsageError(`--clear ${raw} \u3068\u3001\u305D\u306E\u9805\u76EE\u306E\u5024\u306E\u6307\u5B9A\u306F\u540C\u6642\u306B\u3067\u304D\u307E\u305B\u3093`);body[key]=null}const customer=nonEmpty(input.flags,"--customer");if(customer!==void 0){if("company_id"in body)throw new UsageError("--clear customer \u3068 --customer \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");body["company_id"]=Number((await ctx.resolver.company(
|
|
53
|
+
customer,{flag:"--customer",source:"sales",mustExist:true})).id)}return body}async function prepareCreate(input,ctx){noArgs(input,"create");const missing=["--payee","--date","--amount"].filter(flag=>!input.flags.has(flag));if(missing.length>0)throw new UsageError(`\u5165\u91D1\u306E\u4F5C\u6210\u306B\u306F ${missing.join(" / ")} \u304C\u8981\u308A\u307E\u3059`,usageOf("create"));const body=await fieldsBody(input,ctx,"create");return withResolved(input,{body:JSON.stringify(body)})}async function prepareUpdate(input,ctx){
|
|
54
|
+
depositIdArg(input,"update");const body=await fieldsBody(input,ctx,"update");if(Object.keys(body).length===0)throw new UsageError("\u66F8\u304D\u63DB\u3048\u308B\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093",usageOf("update"));return withResolved(await withDeposit(input,ctx,"update"),{body:JSON.stringify(body)})}function bodyOf(input){return JSON.parse(requireResolved(input,"body"))}var createOperation={name:"create",summary:"\u5165\u91D1\u3092\u767B\u9332\u3059\u308B\uFF08--payee\u30FB--date\u30FB--amount\uFF09",
|
|
55
|
+
usage:"twp deposit create --payee <\u632F\u8FBC\u5148ID> --date <\u5165\u91D1\u65E5> --amount <\u5186> [--customer <\u53D6\u5F15\u5148>] [--memo <\u5099\u8003>] [\u904E\u4E0D\u8DB3\u306E\u9805\u76EE\u2026]",description:"POST /api/v2/sales/deposits \u3067\u5165\u91D1\u30921\u4EF6\u767B\u9332\u3057\u307E\u3059\u3002\u5F15\u5F53\u306F\u767B\u9332\u306E\u5F8C\u306B twp deposit allocation add \u3067\u4ED8\u3051\u307E\u3059\u3002\n"+CLOSED_MONTH_HELP+"\n\n"+FIELD_HELP,flags:FIELD_FLAGS,forbidden:FORBIDDEN,
|
|
56
|
+
prepare:prepareCreate,plan:input=>({method:"POST",path:PATH,body:bodyOf(input)}),summarize:body=>withStatusName(depositOf(body,"\u5165\u91D1"),GET_COLUMNS),raw:body=>depositOf(body,"\u5165\u91D1"),notes:serverMessage};var updateOperation={name:"update",summary:"\u5165\u91D1\u3092\u66F8\u304D\u63DB\u3048\u308B\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\uFF09",usage:"twp deposit update <\u5165\u91D1ID> [--date <\u5165\u91D1\u65E5>] [--amount <\u5186>] [--payee <\u632F\u8FBC\u5148ID>] [--customer <\u53D6\u5F15\u5148>] [--memo <\u5099\u8003>] [\u904E\u4E0D\u8DB3\u306E\u9805\u76EE\u2026] [--c\
|
|
57
|
+
lear <\u9805\u76EE>]...",description:"PUT /api/v2/sales/deposits/{id}\u3002\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u3092\u9001\u308A\u307E\u3059\uFF08\u6307\u5B9A\u3057\u306A\u3044\u9805\u76EE\u306F\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002\n\u7DE0\u3081\u6E08\u307F\u306E\u6708\u304C\u6B62\u3081\u308B\u306E\u306F\u5165\u91D1\u65E5\u306E\u5909\u66F4\u3060\u3051\u3067\u3059\uFF08\u5909\u66F4\u524D\u30FB\u5909\u66F4\u5F8C\u306E\u3069\u3061\u3089\u304B\u306E\u6708\u304C\u7DE0\u3081\u6E08\u307F\u306A\u3089\u30B5\u30FC\u30D0\u304C\u65AD\u308A\u307E\u3059\uFF09\u3002\n\u5165\u91D1\u984D\u30FB\u904E\u4E0D\u8DB3\u306E\u5909\u66F4\u3067\u5F15\u5F53\u53EF\u80FD\u306A\u984D\u304C\u5F15\u5F53\u6E08\u984D\u3092\u4E0B\u56DE\u308B\u3068\u30B5\u30FC\u30D0\u304C\u65AD\u308A\u307E\u3059\uFF08\u5148\u306B\u5F15\u5F53\u3092\u6E1B\u3089\u3057\u307E\u3059\uFF09\u3002\n\u9001\u308B\u524D\u306B\u4ECA\u306E\u5165\u91D1\u3092\u8AAD\u3093\u3067 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\uFF09\u3002\n\n"+
|
|
58
|
+
FIELD_HELP,flags:[...FIELD_FLAGS,CLEAR_FLAG],forbidden:FORBIDDEN,prepare:prepareUpdate,plan:input=>({method:"PUT",path:`${PATH}/${depositIdArg(input,"update")}`,body:bodyOf(input)}),plannedNotes:input=>[`\u66F8\u304D\u63DB\u3048\u308B\u5165\u91D1: ${describeDeposit(resolvedDeposit(input))}`],summarize:body=>withStatusName(depositOf(body,"\u5165\u91D1"),GET_COLUMNS),raw:body=>depositOf(body,"\u5165\u91D1"),notes:serverMessage};var deleteOperation={name:"delete",summary:"\u5165\u91D1\u3092\u524A\u9664\u3059\u308B\uFF08\u5F15\u5F53\u3082\u89E3\u9664\u3055\u308C\u308B\u30FB--yes \u304C\u8981\u308B\
|
|
59
|
+
\uFF09",usage:"twp deposit delete <\u5165\u91D1ID> --yes",description:"DELETE /api/v2/sales/deposits/{id}\u3002\u5165\u91D1\u306B\u4ED8\u3044\u3066\u3044\u308B\u5F15\u5F53\u3082\u3059\u3079\u3066\u89E3\u9664\u3055\u308C\u3001\u5F15\u304D\u5F53\u3066\u3066\u3044\u305F\u8ACB\u6C42\u306E\u672A\u5165\u91D1\u984D\u304C\u623B\u308A\u307E\u3059\u3002\n"+CLOSED_MONTH_HELP+"\n\u9001\u308B\u524D\u306B\u5BFE\u8C61\u306E\u5165\u91D1\u3068\u89E3\u9664\u3055\u308C\u308B\u5F15\u5F53\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\uFF09\u3002",
|
|
60
|
+
destructive:true,flags:[],forbidden:FORBIDDEN,prepare:(input,ctx)=>withDeposit(input,ctx,"delete"),plan:input=>({method:"DELETE",path:`${PATH}/${depositIdArg(input,"delete")}`}),plannedNotes(input){const deposit=resolvedDeposit(input);const rows=allocationsOf(deposit);return[`\u524A\u9664\u3059\u308B\u5165\u91D1: ${describeDeposit(deposit)}`,...rows.length===0?[" \u5F15\u5F53\u306F\u3042\u308A\u307E\u305B\u3093"]:[` \u4E00\u7DD2\u306B\u89E3\u9664\u3055\u308C\u308B\u5F15\u5F53 ${rows.length} \u4EF6:`,
|
|
61
|
+
...rows.map(row=>` ${describeAllocation(row)}`)]]},summarize:body=>acknowledgement(body,"\u5165\u91D1\u524A\u9664"),raw:body=>acknowledgement(body,"\u5165\u91D1\u524A\u9664")};async function sendAtomic(plan,ctx,messages){try{return await ctx.send(plan)}catch(err){const refused=err instanceof ApiError&&err.status>=400&&err.status<500;ctx.warn(`${refused?messages.refused:messages.uncertain}
|
|
62
|
+
`);throw err}}var allocationListOperation={name:"list",summary:"\u5165\u91D1\u306E\u5F15\u5F53\u3092\u4E00\u89A7\u3059\u308B",usage:"twp deposit allocation list <\u5165\u91D1ID>",description:`GET /api/v2/sales/deposits/{id} \u306E\u5F15\u5F53\uFF08allocations\uFF09\u3092\u51FA\u3057\u307E\u3059\u3002invoice_remaining_amount \u306F\u5F15\u5F53\u5148\u306E\u8ACB\u6C42\u306B\u307E\u3060\u6B8B\u3063\u3066\u3044\u308B\u672A\u5165\u91D1\u6B8B\u3067\u3059
|
|
63
|
+
\uFF080 \u3088\u308A\u5927\u304D\u3051\u308C\u3070 twp deposit allocation fill \u3067\u5F15\u304D\u4E0A\u3052\u3089\u308C\u307E\u3059\uFF09\u3002
|
|
64
|
+
|
|
65
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${ALLOCATION_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002--output json \u306F\u5F15\u5F53\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002`,flags:[],forbidden:FORBIDDEN,plan:input=>({method:"GET",path:`${PATH}/${depositIdArg(input,"allocation list")}`}),summarize:body=>allocationsOf(depositOf(body,"\u5165\u91D1")).map(row=>pick(row,ALLOCATION_COLUMNS)),raw:body=>allocationsOf(depositOf(body,"\u5165\u91D1")),notes:body=>{
|
|
66
|
+
const deposit=depositOf(body,"\u5165\u91D1");return[describeDeposit(deposit),`\u672A\u5F15\u5F53 ${yen(deposit["unallocated_amount"])}`]}};var FILE_FLAG={name:"--file",summary:`\u5F15\u5F53\u30921\u884C\u306B\u300C\u8ACB\u6C42ID,\u91D1\u984D\u300D\u3067\u66F8\u3044\u305F CSV\uFF08${BULK_MAX_ROWS} \u884C\u307E\u3067\uFF09`,takesValue:true,placeholder:"<\u30D5\u30A1\u30A4\u30EB>"};function excerpt(value,max=20){const chars=[...value];return chars.length<=max?value:`${chars.slice(0,max).join("")}\u2026`}
|
|
67
|
+
var HEADER_ROWS=new Set(["invoice_id,allocated_amount","\u8ACB\u6C42id,\u91D1\u984D","\u8ACB\u6C42id,\u5F15\u5F53\u91D1\u984D"]);function parseAllocationRows(text2){const rows=[];const errors=[];const seen=new Map;text2.split(/\r?\n/).forEach((raw,index)=>{const line=index+1;const value=raw.trim();if(value===""||value.startsWith("#"))return;if(rows.length===0&&errors.length===0&&HEADER_ROWS.has(value.replaceAll(" ","").toLowerCase()))return;const cells=value.split(",").map(cell=>cell.trim());if(cells.
|
|
68
|
+
length!==2){errors.push(`${line} \u884C\u76EE: \u300C\u8ACB\u6C42ID,\u91D1\u984D\u300D\u306E2\u5217\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${cells.length} \u5217: ${excerpt(value)}\uFF09`);return}const[invoiceId,amount]=cells;const problems=[];if(!isExactNumericId(invoiceId))problems.push(`\u8ACB\u6C42 ID \u304C\u5148\u982D\u306B 0 \u3092\u4ED8\u3051\u306A\u3044\u6570\u5B57\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${excerpt(invoiceId)}\uFF09`);if(!/^[1-9]\d*$/.test(amount)||!Number.
|
|
69
|
+
isSafeInteger(Number(amount)))problems.push(`\u91D1\u984D\u304C1\u4EE5\u4E0A\u306E\u6574\u6570\uFF08\u5186\u30FB\u6841\u533A\u5207\u308A\u306A\u3057\uFF09\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${excerpt(amount)}\uFF09`);const first=seen.get(invoiceId);if(first!==void 0)problems.push(`\u8ACB\u6C42 ID ${invoiceId} \u306F ${first} \u884C\u76EE\u3068\u91CD\u8907\u3057\u3066\u3044\u307E\u3059`);if(problems.length>0){errors.push(`${line} \u884C\u76EE: ${problems.join("\u30FB")}`);return}seen.
|
|
70
|
+
set(invoiceId,line);rows.push({line,invoice_id:Number(invoiceId),allocated_amount:Number(amount)})});return{rows,errors}}async function prepareAllocationAdd(input,ctx){const usage=usageOf("allocation add");depositIdArg(input,"allocation add");const file=input.flags.get(FILE_FLAG.name);const single=["--invoice-id","--invoice","--amount"].filter(flag=>input.flags.has(flag));if(file!==void 0){if(single.length>0)throw new UsageError(`--file \u3068 ${single.join(" / ")} \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,
|
|
71
|
+
usage);if(file.trim()==="")throw new UsageError("--file <\u30D5\u30A1\u30A4\u30EB> \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usage);const parsed=parseAllocationRows(readCsvFileText(file,usage,FILE_MAX_BYTES,size=>new UsageError(`--file \u306E\u30D5\u30A1\u30A4\u30EB\u304C\u5927\u304D\u3059\u304E\u307E\u3059\uFF08${size} \u30D0\u30A4\u30C8\uFF09: ${file}`,`1\u56DE\u306B\u9001\u308C\u308B\u306E\u306F ${BULK_MAX_ROWS} \u884C\u307E\u3067\u3067\u3059\u3002`)));const errors=[...parsed.errors];
|
|
72
|
+
if(parsed.rows.length>BULK_MAX_ROWS)errors.push(`\u5F15\u5F53\u304C ${parsed.rows.length} \u884C\u3042\u308A\u307E\u3059\u3002\u30B5\u30FC\u30D0\u304C1\u56DE\u306B\u53D7\u3051\u308B\u306E\u306F ${BULK_MAX_ROWS} \u884C\u307E\u3067\u3067\u3059\uFF08\u5206\u3051\u3066\u9001\u308B\u3068\u3001\u5206\u3051\u305F\u5358\u4F4D\u3067\u767B\u9332\u6E08\u307F\u30FB\u672A\u767B\u9332\u304C\u6DF7\u3056\u308A\u307E\u3059\uFF09`);if(errors.length>0){throw new UsageError(`\u30D5\u30A1\u30A4\u30EB\u306B\u9001\u308C\u306A\u3044\u884C\u304C\u3042\u308B\u305F\u3081\u30011\u4EF6\u3082\u5F15\u304D\u5F53\u3066\u3066\u3044\u307E\u305B\u3093:
|
|
73
|
+
${errors.join("\n ")}`,`\u6B63\u3057\u3044\u884C\u306F ${parsed.rows.length} \u884C\u3067\u3059\u3002\u76F4\u3057\u3066\u304B\u3089\u6253\u3061\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}if(parsed.rows.length===0)throw new UsageError(`\u30D5\u30A1\u30A4\u30EB\u306B\u5F15\u5F53\u306E\u884C\u304C\u3042\u308A\u307E\u305B\u3093: ${file}`,usage);const allocations=parsed.rows.map(({invoice_id,allocated_amount})=>({invoice_id,allocated_amount}));return withResolved(await withDeposit(input,ctx,
|
|
74
|
+
"allocation add"),{body:JSON.stringify({allocations})})}const hasId=input.flags.has("--invoice-id");const hasNo=input.flags.has("--invoice");if(hasId===hasNo)throw new UsageError("\u8ACB\u6C42\u3092 --invoice-id <\u8ACB\u6C42ID> \u304B --invoice <\u8ACB\u6C42\u756A\u53F7> \u306E\u3069\u3061\u3089\u304B\u4E00\u65B9\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4E00\u62EC\u306A\u3089 --file\uFF09",usage);const amount=integerFlag(input,"--amount",1);if(amount===void 0)throw new UsageError(
|
|
75
|
+
"\u5F15\u304D\u5F53\u3066\u308B\u91D1\u984D\u3092 --amount <\u5186> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usage);const body={allocated_amount:amount};if(hasId)body["invoice_id"]=idFlag(input,"--invoice-id","\u8ACB\u6C42");else body["invoice_no"]=nonEmpty(input.flags,"--invoice");return withResolved(await withDeposit(input,ctx,"allocation add"),{body:JSON.stringify(body)})}function isBulk(input){return input.flags.has(FILE_FLAG.name)}function allocationAddPlan(input){const base=`${PATH}\
|
|
76
|
+
/${depositIdArg(input,"allocation add")}/allocations`;return{method:"POST",path:isBulk(input)?`${base}/bulk`:base,body:bodyOf(input)}}var allocationAddOperation={name:"add",summary:"\u5165\u91D1\u3092\u8ACB\u6C42\u3078\u5F15\u304D\u5F53\u3066\u308B\uFF081\u4EF6\u304B --file \u3067\u4E00\u62EC\uFF09",usage:"twp deposit allocation add <\u5165\u91D1ID> (--invoice-id <\u8ACB\u6C42ID> | --invoice <\u8ACB\u6C42\u756A\u53F7>) --amount <\u5186> | twp deposit allocation add <\u5165\u91D1ID> --file <\u30D5\u30A1\u30A4\u30EB>",
|
|
77
|
+
description:`1\u4EF6: POST /api/v2/sales/deposits/{id}/allocations\u3002\u8ACB\u6C42\u306F ID\uFF08--invoice-id\uFF09\u304B\u8ACB\u6C42\u756A\u53F7\uFF08--invoice\uFF09\u3067\u6307\u5B9A\u3057\u307E\u3059
|
|
78
|
+
\uFF08\u6570\u5B57\u3060\u3051\u306E\u8ACB\u6C42\u756A\u53F7\u3092\u63A1\u756A\u3059\u308B\u30C6\u30CA\u30F3\u30C8\u304C\u3042\u308B\u306E\u3067\u3001\u30D5\u30E9\u30B0\u3092\u5206\u3051\u3066\u3044\u307E\u3059\uFF09\u3002
|
|
79
|
+
\u4E00\u62EC\uFF08--file\uFF09: POST \u2026/allocations/bulk\u30021\u884C\u306B\u300C\u8ACB\u6C42ID,\u91D1\u984D\u300D\u3092\u66F8\u304D\u307E\u3059\uFF08${BULK_MAX_ROWS} \u884C\u307E\u3067\u3002\u7A7A\u884C\u30FB# \u3067\u59CB\u307E\u308B\u884C\u30FB\u5148\u982D\u306E\u898B\u51FA\u3057\u884C
|
|
80
|
+
invoice_id,allocated_amount \u306F\u8AAD\u307F\u98DB\u3070\u3057\u307E\u3059\uFF09\u3002\u9001\u308B\u524D\u306B\u5168\u884C\u3092\u691C\u67FB\u3057\u3001\u5F62\u306E\u8AA4\u308A\u30FB\u91CD\u8907\u304C1\u3064\u3067\u3082\u3042\u308C\u30701\u4EF6\u3082\u9001\u308A\u307E\u305B\u3093\u3002
|
|
81
|
+
\u30B5\u30FC\u30D0\u306F\u5168\u4EF6\u6210\u529F\u304B\u5168\u4EF6\u5931\u6557\u3067\u51E6\u7406\u3059\u308B\u306E\u3067\u3001\u9014\u4E2D\u307E\u3067\u5F15\u304D\u5F53\u305F\u3063\u305F\u72B6\u614B\u306B\u306F\u306A\u308A\u307E\u305B\u3093\u3002\u65AD\u3089\u308C\u305F\u3089\u4F55\u3082\u5909\u308F\u3063\u3066\u3044\u306A\u3044\u306E\u3067\u3001
|
|
82
|
+
\u539F\u56E0\u306E\u884C\u3092\u76F4\u3057\u3066\u540C\u3058\u30B3\u30DE\u30F3\u30C9\u3092\u6253\u3061\u76F4\u3057\u307E\u3059\u3002\u5FDC\u7B54\u3092\u53D7\u3051\u53D6\u308C\u306A\u304B\u3063\u305F\u3068\u304D\u306F\u3001\u6253\u3061\u76F4\u3059\u524D\u306B twp deposit allocation list \u3067
|
|
83
|
+
\u5F15\u304D\u5F53\u305F\u3063\u305F\u304B\u3092\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\uFF08\u540C\u3058\u8ACB\u6C42\u3078\u306E\u8FFD\u52A0\u306F\u30B5\u30FC\u30D0\u304C\u8A31\u3059\u306E\u3067\u3001\u4E8C\u91CD\u306B\u5F15\u304D\u5F53\u305F\u308A\u307E\u3059\uFF09\u3002
|
|
84
|
+
|
|
85
|
+
\u5165\u91D1\u306E\u672A\u5F15\u5F53\u984D\uFF08\u624B\u6570\u6599\u5DEE\u5F15\u306A\u3089\u624B\u6570\u6599\u306E\u5206\u3092\u8DB3\u3057\u305F\u984D\uFF09\u30FB\u8ACB\u6C42\u306E\u672A\u5165\u91D1\u984D\u3092\u8D85\u3048\u308B\u91D1\u984D\u3001\u53D6\u6D88\uFF08\u7121\u52B9\uFF09\u30FB\u5931\u6CE8\u306E\u8ACB\u6C42\u306F\u30B5\u30FC\u30D0\u304C\u65AD\u308A\u307E\u3059\u3002
|
|
86
|
+
`+CLOSED_MONTH_HELP,flags:[{name:"--invoice-id",summary:"\u5F15\u304D\u5F53\u3066\u308B\u8ACB\u6C42\u306E ID",takesValue:true,placeholder:"<\u8ACB\u6C42ID>"},{name:"--invoice",summary:"\u5F15\u304D\u5F53\u3066\u308B\u8ACB\u6C42\u306E\u8ACB\u6C42\u756A\u53F7\uFF08INV0000170 \u306A\u3069\uFF09",takesValue:true,placeholder:"<\u8ACB\u6C42\u756A\u53F7>"},{name:"--amount",summary:"\u5F15\u304D\u5F53\u3066\u308B\u91D1\u984D\uFF08\u5186\u30FB1\u4EE5\u4E0A\u306E\u6574\u6570\uFF09",takesValue:true,placeholder:"\
|
|
87
|
+
<\u5186>"},FILE_FLAG],forbidden:FORBIDDEN,prepare:prepareAllocationAdd,plan:allocationAddPlan,plannedNotes(input){const deposit=resolvedDeposit(input);const body=bodyOf(input);const rows=Array.isArray(body["allocations"])?body["allocations"]:[body];const total=rows.reduce((sum,row)=>sum+(typeof row["allocated_amount"]==="number"?row["allocated_amount"]:0),0);return[`\u5F15\u304D\u5F53\u3066\u308B\u5165\u91D1: ${describeDeposit(deposit)}\u30FB\u672A\u5F15\u5F53 ${yen(deposit["unallocated_amount"])}`,
|
|
88
|
+
` \u5F15\u5F53 ${rows.length} \u4EF6\u30FB\u5408\u8A08 ${yen(total)}`]},execute:(input,ctx)=>sendAtomic(allocationAddPlan(input),ctx,{refused:isBulk(input)?"\u30B5\u30FC\u30D0\u304C\u65AD\u3063\u305F\u305F\u3081\u30011\u4EF6\u3082\u5F15\u304D\u5F53\u3066\u3066\u3044\u307E\u305B\u3093\uFF08\u5168\u4EF6\u6210\u529F\u304B\u5168\u4EF6\u5931\u6557\u3067\u3059\uFF09\u3002":"\u30B5\u30FC\u30D0\u304C\u65AD\u3063\u305F\u305F\u3081\u3001\u5F15\u304D\u5F53\u3066\u3066\u3044\u307E\u305B\u3093\u3002",uncertain:"\
|
|
89
|
+
\u5F15\u5F53\u3092\u9001\u308A\u307E\u3057\u305F\u304C\u3001\u7D50\u679C\u3092\u53D7\u3051\u53D6\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u5F15\u304D\u5F53\u305F\u3063\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u6253\u3061\u76F4\u3059\u524D\u306B twp deposit allocation list \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002"}),summarize:body=>allocationsOf(depositOf(body,"\u5165\u91D1")).map(row=>pick(row,ALLOCATION_COLUMNS)),raw:body=>depositOf(body,
|
|
90
|
+
"\u5165\u91D1"),notes:body=>[...serverMessage(body),`\u672A\u5F15\u5F53 ${yen(depositOf(body,"\u5165\u91D1")["unallocated_amount"])}`]};async function prepareAllocationRemove(input,ctx){const allocationId=input.args[1]?.trim()??"";if(allocationId==="")throw new UsageError("\u89E3\u9664\u3059\u308B\u5F15\u5F53\u306E ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044","ID \u306F twp deposit allocation list <\u5165\u91D1ID> \u306E id \u5217\u3067\u3059\u3002");if(!isExactNumericId(allocationId))
|
|
91
|
+
throw new UsageError(`\u5F15\u5F53\u306E ID \u306F\u5148\u982D\u306B 0 \u3092\u4ED8\u3051\u306A\u3044\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${allocationId}`);const prepared=await withDeposit(input,ctx,"allocation remove",1);const rows=allocationsOf(resolvedDeposit(prepared));const target=rows.find(row=>row["id"]===allocationId);if(target===void 0){throw new UsageError(`\u5165\u91D1 ${depositIdArg(input,"allocation remove",1)} \u306B\u5F15\u5F53 ${allocationId} \u306F\u3042\u308A\u307E\u305B\u3093`,
|
|
92
|
+
rows.length===0?"\u3053\u306E\u5165\u91D1\u306B\u306F\u5F15\u5F53\u304C\u3042\u308A\u307E\u305B\u3093\u3002":`\u3053\u306E\u5165\u91D1\u306E\u5F15\u5F53: ${rows.map(row=>text(row["id"])).join(" / ")}`)}return withResolved(prepared,{allocation:JSON.stringify(target)})}var allocationRemoveOperation={name:"remove",summary:"\u5F15\u5F53\u3092\u89E3\u9664\u3059\u308B\uFF08--yes \u304C\u8981\u308B\uFF09",usage:"twp deposit allocation remove <\u5165\u91D1ID> <\u5F15\u5F53ID> --yes",description:"DELETE \
|
|
93
|
+
/api/v2/sales/deposits/{id}/allocations/{allocationId}\u3002\u5F15\u304D\u5F53\u3066\u3066\u3044\u305F\u8ACB\u6C42\u306E\u672A\u5165\u91D1\u984D\u304C\u623B\u308A\u307E\u3059\u3002\n\u624B\u6570\u6599\u5206\u3060\u3051\u3092\u8DB3\u3057\u305F\u3044\u3068\u304D\u306F\u3001\u89E3\u9664\u3057\u3066\u5165\u308C\u76F4\u3055\u305A twp deposit allocation fill \u3092\u4F7F\u3044\u307E\u3059\uFF08\u89E3\u9664\u3057\u305F\u307E\u307E\u5165\u308C\u76F4\u3057\u3092\u5FD8\u308C\u308B\u3068\u5165\u91D1\u304C\u5B99\u306B\u6D6E\u304F\uFF09\u3002\n"+
|
|
94
|
+
CLOSED_MONTH_HELP+"\n\u9001\u308B\u524D\u306B\u89E3\u9664\u3059\u308B\u5F15\u5F53\u3092 stderr \u306B\u51FA\u3057\u307E\u3059\uFF08--dry-run \u3067\u3082\u51FA\u307E\u3059\uFF09\u3002",destructive:true,flags:[],forbidden:FORBIDDEN,prepare:prepareAllocationRemove,plan:input=>{const id=depositIdArg(input,"allocation remove",1);const allocation=JSON.parse(requireResolved(input,"allocation"));return{method:"DELETE",path:`${PATH}/${id}/allocations/${text(allocation["id"])}`}},plannedNotes:input=>[`\u89E3\u9664\
|
|
95
|
+
\u3059\u308B: ${describeAllocation(JSON.parse(requireResolved(input,"allocation")))}`,` \u5165\u91D1: ${describeDeposit(resolvedDeposit(input))}`],summarize:body=>allocationsOf(depositOf(body,"\u5165\u91D1")).map(row=>pick(row,ALLOCATION_COLUMNS)),raw:body=>depositOf(body,"\u5165\u91D1"),notes:serverMessage};function fillCandidates(deposit){const seen=new Set;const out=[];const byId=[...allocationsOf(deposit)].sort((a,b)=>Number(a["id"])-Number(b["id"]));for(const row of byId){const invoiceId=text(
|
|
96
|
+
row["invoice_id"]);if(seen.has(invoiceId))continue;seen.add(invoiceId);const remaining=row["invoice_remaining_amount"];if(row["invoice_is_cancelled"]===true||row["invoice_is_lost"]===true||typeof remaining!=="number"||remaining<=0)continue;out.push(row)}return out}var allocationFillOperation={name:"fill",summary:"\u65E2\u5B58\u306E\u5F15\u5F53\u3092\u8ACB\u6C42\u306E\u672A\u5165\u91D1\u6B8B\u307E\u3067\u5F15\u304D\u4E0A\u3052\u308B\uFF08--yes \u304C\u8981\u308B\uFF09",usage:"twp deposit allocati\
|
|
97
|
+
on fill <\u5165\u91D1ID> --yes",description:"POST /api/v2/sales/deposits/{id}/allocations/fill-invoice-remaining\u3002\u904E\u4E0D\u8DB3\u7406\u7531\uFF08\u632F\u8FBC\u624B\u6570\u6599\u30FB\u4EE3\u884C\u624B\u6570\u6599\uFF09\u3068\u904E\u4E0D\u8DB3\u91D1\u984D\u3092\u5F8C\u304B\u3089\n\u767B\u9332\u3057\u305F\u3068\u304D\u306B\u3001\u624B\u6570\u6599\u306E\u5206\u304C\u58F2\u639B\u91D1\u306B\u6B8B\u308B\u306E\u3092\u3001\u5F15\u5F53\u3092\u6D88\u3055\u305A\u306B\u65E2\u5B58\u306E\u5F15\u5F53\u984D\u3092\u66F8\u304D\u63DB\u3048\u3066\u89E3\u6D88\u3057\u307E\u3059\u3002\n\u5BFE\u8C61\u306F\u3053\u306E\u5165\u91D1\u306E\u5F15\u5F53\u306E\u3046\u3061\u3001\u8ACB\u6C42\u306B\u672A\u5165\u91D1\u6B8B\u304C\u3042\u308B\u3082\u306E\uFF08\u53D6\u6D88\u30FB\u5931\u6CE8\u306E\u8ACB\u6C42\u306F\u9664\u304F\u3002\u540C\u3058\u8ACB\u6C42\u306B\u8907\u6570\u306E\u5F15\u5F53\u304C\u3042\u308C\u3070\u6700\u3082\u53E4\u30441\u884C\uFF09\u3002\n\u5F15\u304D\u4E0A\u3052\u308B\u7DCF\u984D\u306E\u4E0A\u9650\u306F\u5165\u91D1\u306E\u5F15\u5F53\u53EF\u80FD\u6B8B\uFF08\u672A\u5F15\u5F53\u984D\uFF0B\u624B\u6570\u6599\u984D\uFF09\u3067\u3001\u8DB3\u308A\u306A\u3051\u308C\u3070\u8ACB\u6C42\u65E5\u306E\u53E4\u3044\u9806\u306B\u914D\u5206\u3057\u3066\u9014\u4E2D\u3067\u6253\u3061\u5207\u308A\u307E\u3059\n\uFF08\u914D\u5206\u306F\u30B5\u30FC\u30D0\u304C\u6C7A\u3081\u307E\u3059\u3002\u7D50\u679C\u306F stderr \u306B\u300C\u524D \u2192 \u5F8C\u300D\u3067\u51FA\u307E\u3059\uFF09\u3002\u65E2\u5B58\u306E\u5F15\u5F53\u984D\u3092\u66F8\u304D\u63DB\u3048\u308B\u306E\u3067 --yes \u304C\u8981\u308A\u307E\u3059\u3002\n"+
|
|
98
|
+
CLOSED_MONTH_HELP,destructive:true,flags:[],forbidden:FORBIDDEN,prepare:(input,ctx)=>withDeposit(input,ctx,"allocation fill"),plan:input=>({method:"POST",path:`${PATH}/${depositIdArg(input,"allocation fill")}/allocations/fill-invoice-remaining`}),plannedNotes(input){const deposit=resolvedDeposit(input);const candidates=fillCandidates(deposit);const reason=text(deposit["excess_reason"]);const head=[`\u5F15\u304D\u4E0A\u3052\u308B\u5165\u91D1: ${describeDeposit(deposit)}`,` \u672A\u5F15\u5F53 ${yen(
|
|
99
|
+
deposit["unallocated_amount"])}\u30FB\u904E\u4E0D\u8DB3\u7406\u7531 ${reason===""?"\u306A\u3057":EXCESS_REASONS[reason]??reason}\u30FB\u904E\u4E0D\u8DB3\u91D1\u984D ${deposit["excess_amount"]===null||deposit["excess_amount"]===void 0?"\u306A\u3057":yen(deposit["excess_amount"])}`," \u5F15\u304D\u4E0A\u3052\u306E\u4E0A\u9650\u306F\u672A\u5F15\u5F53\u984D\uFF08\u904E\u4E0D\u8DB3\u7406\u7531\u304C\u632F\u8FBC\u624B\u6570\u6599\u30FB\u4EE3\u884C\u624B\u6570\u6599\u306A\u3089\u3001\u6B63\u306E\u904E\u4E0D\u8DB3\u91D1\u984D\u3092\u8DB3\u3057\u305F\u984D\uFF09\u3067\u3001\u5224\u5B9A\u306F\u30B5\u30FC\u30D0\u304C\u3057\u307E\u3059"];
|
|
100
|
+
if(candidates.length===0)return[...head," \u672A\u5165\u91D1\u6B8B\u306E\u3042\u308B\u5F15\u5F53\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u30B5\u30FC\u30D0\u304C\u300C\u5F15\u304D\u4E0A\u3052\u3089\u308C\u308B\u5F15\u5F53\u304C\u3042\u308A\u307E\u305B\u3093\u300D\u3067\u65AD\u308A\u307E\u3059\uFF09"];const order=row=>`${text(row["invoice_date"])||"9999-12-31"}-${text(row["invoice_id"]).padStart(12,"0")}`;const ordered=[...candidates].sort((a,b)=>order(a)<order(b)?-1:order(a)>order(b)?1:0);return[
|
|
101
|
+
...head,` \u5019\u88DC ${candidates.length} \u4EF6\uFF08\u3053\u306E\u9806\u306B\u3001\u4E0A\u9650\u306E\u7BC4\u56F2\u3067\u30B5\u30FC\u30D0\u304C\u914D\u5206\u3057\u3001\u5C3D\u304D\u305F\u3068\u3053\u308D\u3067\u6253\u3061\u5207\u308A\u307E\u3059\uFF09:`,...ordered.map(row=>` ${describeAllocation(row)}\u30FB\u8ACB\u6C42\u306E\u672A\u5165\u91D1\u6B8B ${yen(row["invoice_remaining_amount"])}`)]},summarize:body=>isRecord(body)&&Array.isArray(body["updated_allocations"])?body["updated_allocatio\
|
|
102
|
+
ns"]:[],raw:body=>{envelope(body,"\u5F15\u5F53\u306E\u5F15\u304D\u4E0A\u3052");return body["updated_allocations"]??[]},notes:body=>{const updated=isRecord(body)&&Array.isArray(body["updated_allocations"])?body["updated_allocations"].filter(isRecord):[];return[...serverMessage(body),...updated.map(row=>` \u5F15\u5F53 ${text(row["allocation_id"])}\uFF08\u8ACB\u6C42 ${text(row["invoice_no"])||`ID ${text(row["invoice_id"])}`}\uFF09: ${yen(row["before_amount"])} \u2192 ${yen(row["after_amount"])}`)]}};
|
|
103
|
+
var allocationResource={name:"allocation",summary:"\u5165\u91D1\u306E\u5F15\u5F53\uFF08\u4E00\u89A7\u30FB\u8FFD\u52A0\u30FB\u4E00\u62EC\u8FFD\u52A0\u30FB\u89E3\u9664\u30FB\u672A\u5165\u91D1\u6B8B\u307E\u3067\u306E\u5F15\u304D\u4E0A\u3052\uFF09",operations:[allocationListOperation,allocationAddOperation,allocationRemoveOperation,allocationFillOperation]};var PLAN_FILTER_FLAGS=[{name:"--from",summary:"\u652F\u6255\u671F\u65E5\u304C\u3053\u306E\u65E5\u4EE5\u964D\uFF08YYYY-MM-DD\u30FB\u5FC5\u9808\uFF09",
|
|
104
|
+
takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--to",summary:"\u652F\u6255\u671F\u65E5\u304C\u3053\u306E\u65E5\u4EE5\u524D\uFF08YYYY-MM-DD\u30FB\u5FC5\u9808\u30FB--from \u304B\u3089 366 \u65E5\u307E\u3067\uFF09",takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--customer",summary:"\u53D6\u5F15\u5148\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u4F01\u696D\u540D\u30FB\u7565\u79F0\u30FB\u30AB\u30CA\u306E\u5B8C\u5168\u4E00\u81F4\u304B ID\uFF09",takesValue:true,placeholder:"<\u53D6\u5F15\u5148>"},{
|
|
105
|
+
name:"--status",summary:"\u5BFE\u8C61\u306B\u3059\u308B\u8ACB\u6C42\u306E\u30B9\u30C6\u30FC\u30BF\u30B9\uFF08\u65E2\u5B9A\u306F\u4FDD\u7BA1\u6E08\u3060\u3051\u30FB\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\u30FBall \u3067\u5168\u90E8\uFF09",takesValue:true,placeholder:"<\u30B9\u30C6\u30FC\u30BF\u30B9>",repeatable:true}];var PLAN_FILTER_HELP=`--from / --to \u306F\u8ACB\u6C42\u306E\u652F\u6255\u671F\u65E5\u306E\u7BC4\u56F2\u3067\u3001\u4E21\u65B9\u5FC5\u9808\u3067\u3059\uFF08\u7BC4\u56F2\u306F 366 \u65E5\u307E\u3067\uFF09\u3002
|
|
106
|
+
--status \u3092\u7701\u304F\u3068\u4FDD\u7BA1\u6E08\uFF08archived\uFF09\u306E\u8ACB\u6C42\u3060\u3051\u304C\u5BFE\u8C61\u3067\u3059\uFF08\u753B\u9762\u3068\u540C\u3058\uFF09\u3002all \u3092\u6E21\u3059\u3068\u4F5C\u6210\u4E2D\u30FB\u524A\u9664\u6E08\u4EE5\u5916\u306E\u5168\u90E8\u3067\u3059\u3002
|
|
107
|
+
\u6E21\u305B\u308B\u5024: ${invoiceFilters.statusHelp()}
|
|
108
|
+
\u53D6\u6D88\uFF08\u7121\u52B9\uFF09\u30FB\u5931\u6CE8\u30FB\u7D71\u5408\u6E08\u307F\u306E\u8ACB\u6C42\u3068\u3001\u672A\u5165\u91D1\u6B8B\u306E\u7121\u3044\u8ACB\u6C42\u306F\u30B5\u30FC\u30D0\u304C\u5916\u3057\u307E\u3059\u3002`;async function preparePlanFilters(input,ctx,op){const from=isoDate(input,"--from");const to=isoDate(input,"--to");if(from===void 0||to===void 0)throw new UsageError("\u652F\u6255\u671F\u65E5\u306E\u7BC4\u56F2\u3092 --from <\u65E5\u4ED8> \u3068 --to <\u65E5\u4ED8> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
109
|
+
usageOf(op));if(to<from)throw new UsageError(`--to\uFF08${to}\uFF09\u304C --from\uFF08${from}\uFF09\u3088\u308A\u524D\u3067\u3059`);const all=repeatedValues(input,"--status").some(raw=>raw.trim().toLowerCase()==="all");if(all&&repeatedValues(input,"--status").length>1)throw new UsageError("--status all \u3068\u4ED6\u306E\u30B9\u30C6\u30FC\u30BF\u30B9\u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");const status=all?"all":(await invoiceFilters.statusCodes(input)).join(",");const resolved={
|
|
110
|
+
from,to};if(status!=="")resolved["status"]=status;const customer=nonEmpty(input.flags,"--customer");if(customer!==void 0)resolved["customer"]=(await ctx.resolver.company(customer,{flag:"--customer",source:"sales",mustExist:true})).id;return withResolved(input,resolved)}function planQuery(input){const resolved=input.resolved??{};return{due_date_from:requireResolved(input,"from"),due_date_to:requireResolved(input,"to"),company_id:resolved["customer"],status_list:resolved["status"]}}function planRows(body){
|
|
111
|
+
const rows=envelope(body,"\u5165\u91D1\u4E88\u5B9A")["list"];if(!Array.isArray(rows))throw new ApiResponseError("\u5165\u91D1\u4E88\u5B9A\u306E\u5FDC\u7B54\u306B list \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return rows.filter(isRecord)}var PLAN_COLUMNS=["company_id","company_name","invoice_count","total_amount","earliest_due_date","latest_due_date","company_last_payee_id"];function planSummaryNotes(body){const summary=isRecord(
|
|
112
|
+
body)?body["summary"]:void 0;const list=isRecord(body)?body["status_list"]:void 0;const scope=Array.isArray(list)?list.length===0?"\u4F5C\u6210\u4E2D\u30FB\u524A\u9664\u6E08\u4EE5\u5916\u306E\u5168\u30B9\u30C6\u30FC\u30BF\u30B9":list.map(code=>invoiceFilters.statusName(String(code))).join("\u30FB"):"";if(!isRecord(summary))return[];return[`\u53D6\u5F15\u5148 ${text(summary["company_count"])} \u793E\u30FB\u8ACB\u6C42 ${text(summary["invoice_count"])} \u4EF6\u30FB\u672A\u56DE\u53CE \u5408\u8A08 ${yen(
|
|
113
|
+
summary["total_amount"])}${scope===""?"":`\uFF08\u5BFE\u8C61: ${scope}\uFF09`}`]}var planListOperation={name:"list",summary:"\u5165\u91D1\u4E88\u5B9A\uFF08\u652F\u6255\u671F\u65E5\u3067\u7D5E\u3063\u305F\u672A\u56DE\u53CE\u8ACB\u6C42\u306E\u53D6\u5F15\u5148\u3054\u3068\u306E\u5408\u8A08\uFF09\u3092\u4E00\u89A7\u3059\u308B",usage:"twp deposit plan list --from <\u65E5\u4ED8> --to <\u65E5\u4ED8> [--customer <\u53D6\u5F15\u5148>] [--status <\u30B9\u30C6\u30FC\u30BF\u30B9>]...",description:"GET /api/\
|
|
114
|
+
v2/sales/deposits/plans\u3002\u652F\u6255\u671F\u65E5\u304C\u7BC4\u56F2\u306B\u5165\u308B\u672A\u56DE\u53CE\u306E\u8ACB\u6C42\u3092\u53D6\u5F15\u5148\u3054\u3068\u306B\u5408\u8A08\u3057\u307E\u3059\uFF08\u672A\u56DE\u53CE\u984D\u306E\u5927\u304D\u3044\u9806\uFF09\u3002\n\u30DA\u30FC\u30B8\u30F3\u30B0\u306F\u3042\u308A\u307E\u305B\u3093\u3002\n\n"+PLAN_FILTER_HELP+`
|
|
115
|
+
|
|
116
|
+
--output json \u306F\u53D6\u5F15\u5148\u3054\u3068\u306E\u8ACB\u6C42\u306E\u5185\u8A33\uFF08invoices\uFF09\u30FB\u524D\u56DE\u306E\u632F\u8FBC\u5148\uFF08company_last_payee_id\uFF09\u3092\u542B\u3080\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
|
|
117
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${PLAN_COLUMNS.join(" / ")}\uFF09\u3067\u3059\u3002
|
|
118
|
+
\u3053\u306E\u4E88\u5B9A\u304B\u3089\u5165\u91D1\u3092\u307E\u3068\u3081\u3066\u767B\u9332\u3059\u308B\u306A\u3089 twp deposit plan register --generate-cli-skeleton \u3067\u3072\u306A\u5F62\u3092\u51FA\u3057\u307E\u3059\u3002`,flags:PLAN_FILTER_FLAGS,forbidden:FORBIDDEN,prepare:(input,ctx)=>{noArgs(input,"plan list");return preparePlanFilters(input,ctx,"plan list")},plan:input=>({method:"GET",path:`${PATH}/plans`,query:planQuery(input)}),summarize:body=>planRows(body).map(row=>pick(row,PLAN_COLUMNS)),
|
|
119
|
+
raw:planRows,notes:planSummaryNotes};var PLAN_BODY_KEYS=["deposit_date","items"];var PLAN_ITEM_KEYS=["company_id","payee_id","deposit_amount","memo","excess_reason","excess_amount","excess_note","excess_tax_category","excess_tax_amount","allocations"];var PLAN_ALLOCATION_KEYS=["invoice_id","allocated_amount"];var PLAN_FILE_HELP=`\u672C\u6587\uFF08--content-file \u306E JSON\uFF09\u306F {"deposit_date": "YYYY-MM-DD", "items": [\u53D6\u5F15\u5148\u3054\u3068\u306E\u5165\u91D1]} \u3067\u30011\u4EF6\u306E\u5165\u91D1\u306F
|
|
120
|
+
{"company_id", "payee_id", "deposit_amount", "memo", "excess_reason", "excess_amount", "excess_note", "excess_tax_category", "excess_tax_amount",
|
|
121
|
+
"allocations": [{"invoice_id", "allocated_amount"}]} \u3067\u3059\uFF08\u53D6\u5F15\u5148\u306F 1 \u56DE\u305A\u3064\u30FB\u8ACB\u6C42\u306F\u5168\u4F53\u3067 1 \u56DE\u305A\u3064\uFF09\u3002
|
|
122
|
+
deposit_amount \u3092\u7701\u304F\u3068\u5F15\u5F53\u306E\u5408\u8A08\u304C\u5165\u91D1\u984D\u306B\u306A\u308A\u307E\u3059\u3002memo \u306F 1000 \u6587\u5B57\u307E\u3067\u3002
|
|
123
|
+
\u53D6\u5F15\u5148\u306F ${PLAN_MAX_ITEMS} \u4EF6\u307E\u3067\u30FB1\u53D6\u5F15\u5148\u306E\u5F15\u5F53\u306F 100 \u4EF6\u307E\u3067\u3067\u3059\u3002
|
|
124
|
+
\u672A\u77E5\u306E\u30AD\u30FC\u306F\u9001\u308B\u524D\u306B\u5168\u90E8\u6319\u3052\u3066\u6B62\u3081\u307E\u3059\uFF08\u30B5\u30FC\u30D0\u306F\u9ED9\u3063\u3066\u6368\u3066\u308B\u306E\u3067\u300C\u9001\u3063\u305F\u306E\u306B\u52B9\u3044\u3066\u3044\u306A\u3044\u300D\u306B\u306A\u308B\u305F\u3081\uFF09\u3002
|
|
125
|
+
\u5024\u306E\u8AA4\u308A\uFF08\u91D1\u984D\u306E\u904E\u4E0D\u8DB3\u30FB\u53D6\u5F15\u5148\u3068\u8ACB\u6C42\u306E\u4E0D\u4E00\u81F4\u30FB\u91CD\u8907\uFF09\u306F\u30B5\u30FC\u30D0\u304C\u65AD\u308A\u307E\u3059\u3002`;function parsePlanBody(raw,source){let body;try{body=JSON.parse(raw.replace(/^\uFEFF/,""))}catch{throw new UsageError(`${source} \u3092 JSON \u3068\u3057\u3066\u8AAD\u3081\u307E\u305B\u3093`,PLAN_FILE_HELP)}if(!isRecord(body))throw new UsageError(`${source} \u306E\u6700\u4E0A\u4F4D\u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
126
|
+
PLAN_FILE_HELP);const unknown=Object.keys(body).filter(key=>!PLAN_BODY_KEYS.includes(key));const shape=[];const items=body["items"];if(!Array.isArray(items))throw new UsageError(`${source} \u306E items \u306F\u914D\u5217\u306B\u3057\u3066\u304F\u3060\u3055\u3044`,PLAN_FILE_HELP);items.forEach((item,index)=>{if(!isRecord(item)){unknown.push(`items[${index}]\uFF08\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09`);return}for(const key of Object.keys(item))if(!PLAN_ITEM_KEYS.
|
|
127
|
+
includes(key))unknown.push(`items[${index}].${key}`);const allocations=item["allocations"];if(!Array.isArray(allocations)||allocations.length===0){shape.push(`items[${index}].allocations\uFF08\u5F15\u5F53\u30921\u4EF6\u4EE5\u4E0A\u306E\u914D\u5217\u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF09`);return}if(allocations.length>PLAN_MAX_ALLOCATIONS)shape.push(`items[${index}].allocations\uFF08${allocations.length} \u4EF6\u30FB1\u53D6\u5F15\u5148 ${PLAN_MAX_ALLOCATIONS} \u4EF6\u307E\u3067\uFF09`);
|
|
128
|
+
allocations.forEach((row,j)=>{if(!isRecord(row)){unknown.push(`items[${index}].allocations[${j}]\uFF08\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09`);return}for(const key of Object.keys(row))if(!PLAN_ALLOCATION_KEYS.includes(key))unknown.push(`items[${index}].allocations[${j}].${key}`)})});if(unknown.length>0)throw new UsageError(`${source} \u306B\u9001\u308C\u306A\u3044\u30AD\u30FC\u304C\u3042\u308B\u305F\u3081\u30011\u4EF6\u3082\u9001\u3063\u3066\u3044\u307E\u305B\u3093: ${unknown.
|
|
129
|
+
join(", ")}`,PLAN_FILE_HELP);if(shape.length>0)throw new UsageError(`${source} \u306E\u5F62\u304C\u9055\u3046\u305F\u3081\u30011\u4EF6\u3082\u9001\u3063\u3066\u3044\u307E\u305B\u3093: ${shape.join(", ")}`,PLAN_FILE_HELP);if(items.length===0)throw new UsageError(`${source} \u306E items \u304C\u7A7A\u3067\u3059`,PLAN_FILE_HELP);if(items.length>PLAN_MAX_ITEMS){throw new UsageError(`${source} \u306E\u53D6\u5F15\u5148\u304C ${items.length} \u4EF6\u3042\u308A\u307E\u3059\u3002\u30B5\u30FC\u30D0\u304C1\u56DE\u306B\u53D7\u3051\u308B\u306E\u306F ${PLAN_MAX_ITEMS}\
|
|
130
|
+
\u4EF6\u307E\u3067\u3067\u3059`,"\u30D5\u30A1\u30A4\u30EB\u3092\u5206\u3051\u3066\u6253\u3063\u3066\u304F\u3060\u3055\u3044\uFF081\u56DE\u3054\u3068\u306B\u5168\u4EF6\u6210\u529F\u304B\u5168\u4EF6\u5931\u6557\u3067\u3059\uFF09\u3002")}for(const[index,item]of items.entries()){const memo=item["memo"];if(typeof memo==="string"&&[...memo].length>PLAN_MEMO_MAX_CHARS)throw new UsageError(`items[${index}].memo \u304C ${PLAN_MEMO_MAX_CHARS} \u6587\u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059`)}return body}
|
|
131
|
+
function serverId(value,label){const raw=typeof value==="string"||typeof value==="number"?String(value):"";if(!isExactNumericId(raw))throw new ApiResponseError(`\u5165\u91D1\u4E88\u5B9A\u306E\u5FDC\u7B54\u306E${label} ID \u304C\u6570\u5B57\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return Number(raw)}function planSkeleton(body,depositDate){const missingPayee=[];const items=planRows(body).map(row=>{const invoices=Array.
|
|
132
|
+
isArray(row["invoices"])?row["invoices"].filter(isRecord):[];const payee=row["company_last_payee_id"];if(payee===null||payee===void 0||payee==="")missingPayee.push(`${text(row["company_name"])}\uFF08\u53D6\u5F15\u5148 ID ${text(row["company_id"])}\uFF09`);return{company_id:serverId(row["company_id"],"\u53D6\u5F15\u5148"),payee_id:payee===null||payee===void 0||payee===""?null:serverId(payee,"\u632F\u8FBC\u5148"),allocations:invoices.map(invoice=>({invoice_id:serverId(invoice["id"],"\u8ACB\u6C42"),
|
|
133
|
+
allocated_amount:invoice["remaining_amount"]}))}});return{skeleton:{deposit_date:depositDate,items},missingPayee}}function todayJst(now=new Date){return new Date(now.getTime()+9*60*60*1e3).toISOString().slice(0,10)}var SKELETON_FLAG={name:"--generate-cli-skeleton",summary:"\u5165\u91D1\u4E88\u5B9A\u304B\u3089\u672C\u6587\u306E\u3072\u306A\u5F62\u3092\u51FA\u3057\u3066\u7D42\u4E86\u3059\u308B\uFF08\u767B\u9332\u3057\u306A\u3044\u30FB--from / --to \u304C\u8981\u308B\uFF09",takesValue:false};var PLAN_FILE_FLAG={
|
|
134
|
+
name:"--content-file",summary:"\u767B\u9332\u3059\u308B\u5165\u91D1\u306E JSON \u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"};async function preparePlanRegister(input,ctx){noArgs(input,"plan register");const usage=usageOf("plan register");if(input.flags.has(SKELETON_FLAG.name)){if(input.flags.has(PLAN_FILE_FLAG.name))throw new UsageError("--generate-cli-skeleton \u3068 --content-file \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093",
|
|
135
|
+
usage);return preparePlanFilters(input,ctx,"plan register")}const filters=PLAN_FILTER_FLAGS.map(flag=>flag.name).filter(name=>input.flags.has(name)||repeatedValues(input,name).length>0);if(filters.length>0)throw new UsageError(`${filters.join(" / ")} \u306F --generate-cli-skeleton \u306E\u3068\u304D\u3060\u3051\u4F7F\u3044\u307E\u3059\uFF08\u767B\u9332\u306E\u4E2D\u8EAB\u306F --content-file \u306B\u66F8\u304D\u307E\u3059\uFF09`,usage);const raw=await readBody(input,{flag:"--content",fileFlag:PLAN_FILE_FLAG.
|
|
136
|
+
name,label:"\u767B\u9332\u3059\u308B\u5165\u91D1",maxChars:CONTENT_MAX_CHARS,usage});if(raw===void 0)throw new UsageError("\u767B\u9332\u3059\u308B\u5165\u91D1\u3092 --content-file <\u30D1\u30B9> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044","\u3072\u306A\u5F62\u306F twp deposit plan register --generate-cli-skeleton --from <\u65E5\u4ED8> --to <\u65E5\u4ED8> \u3067\u51FA\u305B\u307E\u3059\u3002");const body=parsePlanBody(raw,`${PLAN_FILE_FLAG.name} ${input.flags.get(PLAN_FILE_FLAG.name)??
|
|
137
|
+
""}`);return withResolved(input,{body:JSON.stringify(body)})}function planRegisterPlan(input){if(input.flags.has(SKELETON_FLAG.name))return{method:"GET",path:`${PATH}/plans`,query:planQuery(input)};return{method:"POST",path:`${PATH}/plans/register`,body:bodyOf(input)}}function isSkeletonResult(value){return isRecord(value)&&isRecord(value["skeleton"])&&Array.isArray(value["missingPayee"])}function registeredDeposits(body){const data=envelope(body,"\u5165\u91D1\u4E88\u5B9A\u304B\u3089\u306E\u767B\u9332")["\
|
|
138
|
+
data"];if(!Array.isArray(data))throw new ApiResponseError("\u5165\u91D1\u4E88\u5B9A\u304B\u3089\u306E\u767B\u9332\u306E\u5FDC\u7B54\u306B data \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return data.filter(isRecord)}var planRegisterOperation={name:"register",summary:"\u5165\u91D1\u4E88\u5B9A\u304B\u3089\u5165\u91D1\u3068\u5F15\u5F53\u3092\u307E\u3068\u3081\u3066\u767B\u9332\u3059\u308B\uFF08--content-file \u306E JSON\uFF09",
|
|
139
|
+
usage:"twp deposit plan register --content-file <\u30D1\u30B9> | twp deposit plan register --generate-cli-skeleton --from <\u65E5\u4ED8> --to <\u65E5\u4ED8> [--customer <\u53D6\u5F15\u5148>] [--status <\u30B9\u30C6\u30FC\u30BF\u30B9>]...",description:"POST /api/v2/sales/deposits/plans/register\u3002\u53D6\u5F15\u5148\u3054\u3068\u306B\u5165\u91D1\u30921\u4EF6\u4F5C\u308A\u3001\u305D\u306E\u53D6\u5F15\u5148\u306E\u8ACB\u6C42\u3078\u5F15\u304D\u5F53\u3066\u307E\u3059\u3002\n\u30B5\u30FC\u30D0\u306F\u5168\u4EF6\u6210\u529F\u304B\u5168\u4EF6\u5931\u6557\u3067\u51E6\u7406\u3059\u308B\u306E\u3067\u3001\u4E00\u90E8\u306E\u53D6\u5F15\u5148\u3060\u3051\u767B\u9332\u3055\u308C\u305F\u72B6\u614B\u306B\u306F\u306A\u308A\u307E\u305B\u3093\u3002\u65AD\u3089\u308C\u305F\u3089\u4F55\u3082\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\u306E\u3067\u3001\n\u76F4\u3057\u3066\u540C\u3058\u30B3\u30DE\u30F3\u30C9\u3092\u6253\u3061\u76F4\u3057\u307E\u3059\u3002\u5FDC\u7B54\u3092\u53D7\u3051\u53D6\u308C\u306A\u304B\u3063\u305F\u3068\u304D\u306F\u3001\u6253\u3061\u76F4\u3059\u524D\u306B twp deposit list --from <\u5165\u91D1\u65E5> --to <\u5165\u91D1\u65E5> \u3067\n\u767B\u9332\u3055\u308C\u305F\u304B\u3092\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\uFF08\u6253\u3061\u76F4\u3059\u3068\u5165\u91D1\u304C\u4E8C\u91CD\u306B\u3067\u304D\
|
|
140
|
+
\u307E\u3059\uFF09\u3002\n"+CLOSED_MONTH_HELP+"\n\n--generate-cli-skeleton \u306F\u5165\u91D1\u4E88\u5B9A\uFF08twp deposit plan list \u3068\u540C\u3058\u7D5E\u308A\u8FBC\u307F\uFF09\u3092\u8AAD\u307F\u3001\u753B\u9762\u306E\u521D\u671F\u72B6\u614B\u3068\u540C\u3058\u3072\u306A\u5F62\u3092\u51FA\u3057\u307E\u3059:\n \u53D6\u5F15\u5148\u3054\u3068\u306E\u5168\u8ACB\u6C42\u3092\u672A\u5165\u91D1\u6B8B\u306E\u5168\u984D\u3067\u5F15\u304D\u5F53\u3066\u3001\u5165\u91D1\u984D\u306F\u7701\u304D\uFF08\uFF1D\u5F15\u5F53\u306E\u5408\u8A08\uFF09\u3001\u632F\u8FBC\u5148\u306F\u305D\u306E\u53D6\u5F15\u5148\u306E\u524D\u56DE\u306E\u632F\u8FBC\u5148\u3001\u5165\u91D1\u65E5\u306F\u4ECA\u65E5\uFF08\u65E5\u672C\u6642\u9593\uFF09\u3002\n \u5B9F\u969B\u306E\u7740\u91D1\u984D\u304C\u9055\u3046\u53D6\u5F15\u5148\u306F deposit_amount \u3068 excess_reason\uFF08\u904E\u4E0D\u8DB3\u7406\u7531\uFF09\u3092\u66F8\u304D\u8DB3\u3057\u3001\u5165\u91D1\u306E\u7121\u3044\u53D6\u5F15\u5148\u30FB\u8ACB\u6C42\u306F\u6D88\u3057\u3066\u304B\u3089 --content-file \u3067\u6E21\u3057\u307E\u3059\u3002\n \u524D\u56DE\u306E\u632F\u8FBC\u5148\u304C\u7121\u3044\u53D6\u5F15\u5148\u306F payee_id \u304C null \u3067\u3059\uFF08\u753B\u9762\u306F\u632F\u8FBC\u5148\u3092\u9078\u3076\u307E\u3067\u767B\u9332\u3055\u305B\u307E\u305B\u3093\u3002\u305D\u306E\u307E\u307E\u9001\u308B\u3068\u632F\u8FBC\u5148\u306E\u7121\u3044\u5165\u91D1\u304C\u3067\u304D\u307E\u3059\uFF09\u3002\n\n"+
|
|
141
|
+
PLAN_FILE_HELP+"\n\n"+PLAN_FILTER_HELP,flags:[PLAN_FILE_FLAG,SKELETON_FLAG,...PLAN_FILTER_FLAGS],forbidden:FORBIDDEN,prepare:preparePlanRegister,plan:planRegisterPlan,plannedNotes(input){if(input.flags.has(SKELETON_FLAG.name))return[];const body=bodyOf(input);const items=body["items"]??[];const allocations=items.reduce((n,item)=>n+(item["allocations"]?.length??0),0);const noPayee=items.filter(item=>item["payee_id"]===null||item["payee_id"]===void 0).map(item=>`\u53D6\u5F15\u5148 ID ${text(item["\
|
|
142
|
+
company_id"])}`);return[`\u5165\u91D1\u65E5 ${text(body["deposit_date"])} \u3067\u3001\u53D6\u5F15\u5148 ${items.length} \u4EF6\u306E\u5165\u91D1\u3068\u5F15\u5F53 ${allocations} \u4EF6\u3092\u767B\u9332\u3057\u307E\u3059\uFF08\u5168\u4EF6\u6210\u529F\u304B\u5168\u4EF6\u5931\u6557\uFF09`,...noPayee.length>0?[` \u632F\u8FBC\u5148\uFF08payee_id\uFF09\u304C\u7121\u3044\u5165\u91D1\u304C\u3067\u304D\u307E\u3059: ${noPayee.join(" / ")}`]:[]]},async execute(input,ctx){if(input.flags.has(SKELETON_FLAG.
|
|
143
|
+
name))return planSkeleton(await ctx.send(planRegisterPlan(input)),todayJst());return sendAtomic(planRegisterPlan(input),ctx,{refused:"\u30B5\u30FC\u30D0\u304C\u65AD\u3063\u305F\u305F\u3081\u30011\u4EF6\u3082\u767B\u9332\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u5168\u4EF6\u6210\u529F\u304B\u5168\u4EF6\u5931\u6557\u3067\u3059\uFF09\u3002",uncertain:"\u767B\u9332\u3092\u9001\u308A\u307E\u3057\u305F\u304C\u3001\u7D50\u679C\u3092\u53D7\u3051\u53D6\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u767B\u9332\u3055\u308C\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u6253\u3061\u76F4\u3059\u524D\u306B twp deposit list \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002"})},
|
|
144
|
+
summarize:body=>isSkeletonResult(body)?body.skeleton:registeredDeposits(body).map(row=>withStatusName(row,LIST_COLUMNS)),raw:body=>isSkeletonResult(body)?body.skeleton:registeredDeposits(body),notes(body){if(isSkeletonResult(body)){const items=body.skeleton["items"].length;return[`\u3072\u306A\u5F62\u3067\u3059\uFF08\u767B\u9332\u3057\u3066\u3044\u307E\u305B\u3093\uFF09\u3002\u53D6\u5F15\u5148 ${items} \u4EF6\u30FB\u91D1\u984D\u306F\u5404\u8ACB\u6C42\u306E\u672A\u5165\u91D1\u6B8B\u306E\u5168\u984D\u3067\u3059\u3002\u7740\u91D1\u984D\u304C\u9055\u3046\u53D6\u5F15\u5148\u306F deposit_amount \u3068 excess_reason \u3092\u66F8\u304D\u8DB3\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
|
|
145
|
+
...body.missingPayee.length>0?[`\u524D\u56DE\u306E\u632F\u8FBC\u5148\u304C\u7121\u3044\u305F\u3081 payee_id \u304C null \u306E\u53D6\u5F15\u5148: ${body.missingPayee.join(" / ")}`]:[]]}return serverMessage(body)}};var planResource={name:"plan",summary:"\u5165\u91D1\u4E88\u5B9A\uFF08\u652F\u6255\u671F\u65E5\u3067\u7D5E\u3063\u305F\u672A\u56DE\u53CE\u8ACB\u6C42\u306E\u53D6\u5F15\u5148\u3054\u3068\u306E\u5408\u8A08\uFF09\u3068\u3001\u305D\u3053\u304B\u3089\u306E\u5165\u91D1\uFF0B\u5F15\u5F53\u306E\u4E00\u62EC\u767B\u9332",
|
|
146
|
+
operations:[planListOperation,planRegisterOperation]};var depositDomain={name:"deposit",summary:"\u8CA9\u58F2\u7BA1\u7406\u306E\u5165\u91D1\uFF08\u4E00\u89A7\u30FB\u8A73\u7D30\u30FB\u767B\u9332\u30FB\u66F4\u65B0\u30FB\u524A\u9664\u30FBCSV\u30FB\u5F15\u5F53\u30FB\u5165\u91D1\u4E88\u5B9A\u304B\u3089\u306E\u4E00\u62EC\u767B\u9332\u3002\u8CA9\u58F2\u7BA1\u7406\u306E\u7BA1\u7406\u8005\uFF09",operations:[listOperation,getOperation,createOperation,updateOperation,deleteOperation,exportOperation],subresources:[
|
|
147
|
+
allocationResource,planResource]};export{salesAdminForbidden,depositIdArg,describeDeposit,sendAtomic,excerpt,parseAllocationRows,parsePlanBody,planSkeleton,depositDomain};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{isModeId,isPermissionModeId}from"./chunk-NAUH75MM.js";import{API_TOKEN,HELP_TOKEN,isDomainName}from"./chunk-
|
|
3
|
+
import{isModeId,isPermissionModeId}from"./chunk-NAUH75MM.js";import{API_TOKEN,HELP_TOKEN,isDomainName}from"./chunk-EOSSFTNG.js";import{splitFlagToken}from"./chunk-QQRJLH6B.js";var BUILTIN_COMMANDS=["login","logout","whoami","update","task-loop"];var TASK_LOOP_ACTIONS=["run","status","stop","schedule","setup","charter","skill"];var VALUE_FLAGS=new Set(["-p","--print","--profile","--tenant","--mode","--permission-mode","--model","--allowed-tools","--disallowed-tools","--project","--engine","--interval","--max-cycles","--ai","--workspace","--ai-config-file","--now","--counts","--gate","--file","--out","--revision","--dir","--output","--query"]);var BOOLEAN_FLAGS=new Set(
|
|
4
4
|
["-h","--help","-v","--version","--no-tui","--doctor","--password","--token","--no-browser","--safe","--daemon","--force-runner","--force","--drain","--yes","-y","--no-ai-config-file","--verbose","--all","--dry-run","--debug","--refresh"]);function dispatch(argv,limit=2){const tokens=[];const indexes=[];let truncated=false;for(let i=0;i<argv.length;i++){const arg=argv[i];if(arg===void 0)continue;if(arg.startsWith("-")&&arg!=="-"){const{name,value:inline}=splitFlagToken(arg);if(BOOLEAN_FLAGS.has(
|
|
5
5
|
name)){if(inline!==void 0){truncated=true;break}continue}if(VALUE_FLAGS.has(name)){if(inline!==void 0)continue;const next=argv[i+1];if(next!==void 0&&(!next.startsWith("-")||next==="-"))i++;continue}truncated=true;break}if(arg===""||arg==="-")continue;if(tokens.length>=limit)break;tokens.push(arg);indexes.push(i)}return{tokens,indexes,truncated}}function isBuiltin(token){return token!==void 0&&BUILTIN_COMMANDS.includes(token)}function isTaskLoopAction(token){return token!==void 0&&TASK_LOOP_ACTIONS.
|
|
6
6
|
includes(token)}function resolveRoute(result){const{tokens,indexes}=result;const[first,second]=tokens;const firstIndex=indexes[0];if(first===void 0||firstIndex===void 0)return{kind:"none",consumed:[]};const consumed=[firstIndex];const secondIndex=indexes[1];if(isBuiltin(first)){if(first==="task-loop"&&isTaskLoopAction(second)){if(secondIndex!==void 0)consumed.push(secondIndex);return{kind:"builtin",command:first,action:second,consumed}}return{kind:"builtin",command:first,...first==="task-loop"?{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{booleanText,boundedText,isoDate}from"./chunk-UDPJ2IGK.js";import{ORG_MASTER_LIMIT}from"./chunk-
|
|
3
|
+
import{booleanText,boundedText,isoDate}from"./chunk-UDPJ2IGK.js";import{ORG_MASTER_LIMIT}from"./chunk-BZAXQOLB.js";import{ULID_RE,UUID_RE,isSafePathSegment}from"./chunk-GMBJTG6A.js";import{nonEmpty,positiveInteger}from"./chunk-5R4SEO3I.js";import{requireResolved,singleRef,withResolved}from"./chunk-ZN5EFDH7.js";import{acknowledgement,isRecord,pick}from"./chunk-ZWVYVS2A.js";import{ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var CLEAR_DATE="none";function placeholderOf(field){switch(field.kind){case"text":return`<${field.label}>`;case"integer":return"<\u6574\u6570>";case"boolean":return"<true|false>";case"enum":return`<${field.values.join("|")}>`;case"date":return`<YYYY-MM-DD|${CLEAR_DATE}>`;case"ref":return field.placeholder}}function createFlags(fields){return fields.map(field=>({name:field.flag,summary:field.summary,takesValue:true,placeholder:placeholderOf(field)}))}function updateFlags(fields){const flags=[];for(const field of fields){
|
|
4
4
|
flags.push({name:field.flag,summary:field.summary,takesValue:true,placeholder:placeholderOf(field)});if(field.kind==="ref")flags.push({name:field.clearFlag,summary:field.clearSummary,takesValue:false})}return flags}function integerValue(field,raw){const trimmed=raw.trim();const value=/^\d+$/.test(trimmed)?Number(trimmed):Number.NaN;const tooLarge=field.max!==void 0&&value>field.max;if(!Number.isSafeInteger(value)||value<field.min||tooLarge){const range=field.max!==void 0?`${field.min} \u4EE5\u4E0A ${field.
|
|
5
5
|
max} \u4EE5\u4E0B`:`${field.min} \u4EE5\u4E0A`;throw new UsageError(`${field.flag} \u306F ${range}\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,`${field.label}\u3092\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return value}function fieldBody(input,fields){const body={};for(const field of fields){switch(field.kind){case"text":{const value=boundedText(input,field.flag,{maxChars:field.maxChars,label:field.label});if(value!==void 0)body[field.
|
|
6
6
|
key]=value;break}case"integer":{const raw=input.flags.get(field.flag);if(raw!==void 0)body[field.key]=integerValue(field,raw);break}case"boolean":{const raw=input.flags.get(field.flag);if(raw!==void 0)body[field.key]=booleanText(field.flag,raw);break}case"enum":{const raw=input.flags.get(field.flag);if(raw===void 0)break;const value=raw.trim().toLowerCase();if(!field.values.includes(value)){throw new UsageError(`${field.flag} \u306B\u300C${raw}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{repeatedValues}from"./chunk-IOGVQVGD.js";import{isoDate}from"./chunk-UDPJ2IGK.js";import{SALES_ESTIMATES_PATH,SALES_INVOICES_PATH,isExactNumericId,resolveNamed}from"./chunk-
|
|
3
|
+
import{repeatedValues}from"./chunk-IOGVQVGD.js";import{isoDate}from"./chunk-UDPJ2IGK.js";import{SALES_ESTIMATES_PATH,SALES_INVOICES_PATH,isExactNumericId,resolveNamed}from"./chunk-BZAXQOLB.js";import{LIST_PAGING_HELP,PAGE_NUMBER_LIST_FLAGS,PAGE_NUMBER_PAGING_HELP,STABLE_PAGE_ORDER,nonEmpty,pageNumberPaging,pageNumberQuery,pageRangeNotes}from"./chunk-5R4SEO3I.js";import{withResolved}from"./chunk-ZN5EFDH7.js";import{isRecord,pick}from"./chunk-ZWVYVS2A.js";import{
|
|
4
4
|
ApiResponseError,UsageError}from"./chunk-7WSNIXTQ.js";var ESTIMATE_STATUSES={new:"\u4F5C\u6210\u4E2D",create_completed:"\u4F5C\u6210\u5B8C\u4E86",in_progress:"\u7533\u8ACB\u4E2D",approved:"\u627F\u8A8D\u6E08",submitted:"\u63D0\u793A\u6E08",rejected:"\u5DEE\u3057\u623B\u3057",deleted:"\u524A\u9664\u6E08"};var INVOICE_STATUSES={new:"\u4F5C\u6210\u4E2D",create_completed:"\u4F5C\u6210\u5B8C\u4E86",in_progress:"\u7533\u8ACB\u4E2D",approved:"\u627F\u8A8D\u6E08",rejected:"\u5DEE\u3057\u623B\u3057",submitted:"\u63D0\u793A\u6E08",manager_confirmation:"\u6848\u4EF6\u62C5\u5F53\u8005\
|
|
5
5
|
_\u6848\u4EF6\u5185\u5BB9\u30FB\u91D1\u984D\u78BA\u8A8D",invoice_issued:"\u8ACB\u6C42\u66F8\u767A\u884C\u6E08",sent_to_client:"\u5148\u65B9\u9001\u4ED8\u6E08",archived:"\u4FDD\u7BA1\u6E08",deleted:"\u524A\u9664\u6E08",cancelled:"\u53D6\u6D88\uFF08\u7121\u52B9\uFF09",lost:"\u5931\u6CE8"};var ALLOCATION_STATUSES={unallocated:"\u672A\u56DE\u53CE",allocated:"\u56DE\u53CE\u6E08"};function statusRefs(table){return Object.entries(table).map(([code,name])=>({id:code,name,code}))}function statusHelp(table){
|
|
6
6
|
return Object.entries(table).map(([code,name])=>`${code}\uFF08${name}\uFF09`).join(" / ")}function licenseForbidden(guidance){return body=>body?.error==="permission_denied"?guidance:void 0}function featureLicenseGuidance(feature){return`${feature}\u3092\u4F7F\u3046\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u30C6\u30CA\u30F3\u30C8\u304C${feature}\u3092\u5951\u7D04\u3057\u3066\u3044\u306A\u3044\u304B\u3001\u3042\u306A\u305F\u306E${feature}\u306E\u6A29\u9650\u304C\u300C\u306A\u3057\u300D\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}
|
|
@@ -8,19 +8,20 @@ var SALES_FORBIDDEN=licenseForbidden(featureLicenseGuidance("\u8CA9\u58F2\u7BA1\
|
|
|
8
8
|
`${what}\u306E\u5FDC\u7B54\u306B data.id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return data}function withStatusName(row,columns,table){const picked=pick(row,columns);const status=isRecord(row)?row["status"]:void 0;if(typeof status!=="string")return picked;return Object.fromEntries(Object.entries(picked).flatMap(([key,value])=>key==="status"?[[key,value],["status_name",table[status]??status]]:[[key,value]]))}function totalsNote(body){
|
|
9
9
|
if(!isRecord(body))return[];const sum=body["sum"];const amount=body["total_amount"];if(typeof sum!=="number")return pageRangeNotes(body);return[...pageRangeNotes(body),typeof amount==="number"?`\u8A72\u5F53 ${sum} \u4EF6\u30FB\u5408\u8A08\u91D1\u984D\uFF08\u7A0E\u8FBC\uFF09${amount.toLocaleString("ja-JP")} \u5186`:`\u8A72\u5F53 ${sum} \u4EF6`]}var ESTIMATE={name:"estimate",label:"\u898B\u7A4D",path:SALES_ESTIMATES_PATH,statuses:ESTIMATE_STATUSES,userParam:"estimate_user_id",dateParam:"estimate_d\
|
|
10
10
|
ate",dateLabel:"\u898B\u7A4D\u65E5",listColumns:["id","estimate_no","estimate_date","status","company_name","title","total","estimate_user_name"],getColumns:["id","estimate_no","title","status","estimate_date","estimate_expiration_date","company_name","project_name","estimate_user_name","subtotal","tax_amount","total"]};var INVOICE={name:"invoice",label:"\u8ACB\u6C42",path:SALES_INVOICES_PATH,statuses:INVOICE_STATUSES,userParam:"invoice_user_id",dateParam:"invoice_date",dateLabel:"\u8ACB\u6C42\u65E5",
|
|
11
|
-
listColumns:["id","invoice_no","invoice_date","status","company_name","title","total","remaining_amount"],getColumns:["id","invoice_no","title","status","invoice_date","due_date","company_name","project_name","estimate_no","invoice_user_name","subtotal","tax_amount","total","deposit_amount","remaining_amount"]};function
|
|
11
|
+
listColumns:["id","invoice_no","invoice_date","status","company_name","title","total","remaining_amount"],getColumns:["id","invoice_no","title","status","invoice_date","due_date","company_name","project_name","estimate_no","invoice_user_name","subtotal","tax_amount","total","deposit_amount","remaining_amount"]};function filterFlags(resource){const flags=[{name:"--keyword",summary:`\u4EF6\u540D\u30FB${resource.label}\u756A\u53F7\u30FB\u5099\u8003\u306E\u8A9E\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u90E8\u5206\u4E00\u81F4\uFF09`,
|
|
12
12
|
takesValue:true,placeholder:"<\u8A9E>"},{name:"--status",summary:"\u30B9\u30C6\u30FC\u30BF\u30B9\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u30B3\u30FC\u30C9\u304B\u8868\u793A\u540D\u30FB\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u30B9\u30C6\u30FC\u30BF\u30B9>",repeatable:true},{name:"--customer",summary:"\u53D6\u5F15\u5148\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u4F01\u696D\u540D\u30FB\u7565\u79F0\u30FB\u30AB\u30CA\u306E\u5B8C\u5168\u4E00\u81F4\u304B ID\uFF09",takesValue:true,
|
|
13
13
|
placeholder:"<\u53D6\u5F15\u5148>"},{name:"--project",summary:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u30B3\u30FC\u30C9\u304B ID\uFF09",takesValue:true,placeholder:"<\u30B3\u30FC\u30C9|ID>"},{name:"--assignee",summary:`${resource.label}\u62C5\u5F53\u8005\u3067\u7D5E\u308A\u8FBC\u3080\uFF08me\u30FBID\u30FB\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u30FB\u6C0F\u540D\uFF09`,takesValue:true,placeholder:"<\u30E6\u30FC\u30B6\u30FC>"},{name:"--from",summary:`${resource.
|
|
14
14
|
dateLabel}\u304C\u3053\u306E\u65E5\u4EE5\u964D\uFF08YYYY-MM-DD\uFF09`,takesValue:true,placeholder:"<\u65E5\u4ED8>"},{name:"--to",summary:`${resource.dateLabel}\u304C\u3053\u306E\u65E5\u4EE5\u524D\uFF08YYYY-MM-DD\uFF09`,takesValue:true,placeholder:"<\u65E5\u4ED8>"}];if(resource.name==="invoice"){flags.push({name:"--allocation",summary:"\u56DE\u53CE\u72B6\u6CC1\u3067\u7D5E\u308A\u8FBC\u3080\uFF08unallocated\uFF1D\u672A\u56DE\u53CE / allocated\uFF1D\u56DE\u53CE\u6E08\uFF09",takesValue:true,placeholder:"\
|
|
15
|
-
<\u72B6\u6CC1>"})}return flags}async function statusCodes(input,resource){const refs=statusRefs(resource.statuses);const codes=[];for(const raw of repeatedValues(input,"--status")){const ref=await resolveNamed(raw,refs,{flag:"--status",label:`${resource.label}\u306E\u30B9\u30C6\u30FC\u30BF\u30B9`,scope:"\u3053\u306E CLI"});if(!codes.includes(ref.id))codes.push(ref.id)}return codes}async function allocationCode(input){
|
|
16
|
-
raw,statusRefs(ALLOCATION_STATUSES),{flag:"--allocation",label:"\u56DE\u53CE\u72B6\u6CC1",scope:"\u3053\u306E CLI"})).id}function noArgs(input,resource,op){if(input.args.length>0){throw new UsageError(`${op} \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,`twp ${resource.name} ${op} help`)}}async function
|
|
17
|
-
name==="invoice"?await allocationCode(input):void 0;const resolved={};if(status.length>0)resolved["status"]=status.join(",");if(allocation!==void 0)resolved["allocation"]=allocation;const customer=nonEmpty(input.flags,"--customer");if(customer!==void 0){resolved["customer"]=(await ctx.resolver.company(customer,{flag:"--customer",source:"
|
|
18
|
-
input.flags,"--assignee");if(assignee!==void 0)resolved["assignee"]=(await ctx.resolver.user(assignee,"--assignee")).id;return withResolved(input,resolved)}function
|
|
19
|
-
"--from"),[`${resource.dateParam}_to`]:isoDate(input,"--to"),...resource.name==="invoice"?{allocation_status:resolved["allocation"],consolidated_view:1}:{},...STABLE_PAGE_ORDER,page_limit,page_no}}function recordId(input,resource){const[raw,...rest]=input.
|
|
20
|
-
\u308C\u308B${resource.label} ID \u306F1\u3064\u3060\u3051\u3067\u3059: ${rest.join(" ")}`,usage);if(!isExactNumericId(id)){throw new UsageError(`${resource.label}\u306E ID \u306F\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}
|
|
21
|
-
return id}function listOperation(resource){const paging=pageNumberPaging({label:`${resource.label}\u4E00\u89A7`});const rows=body=>{envelope(body,`${resource.label}\u4E00\u89A7`);return paging.items(body)};const consolidated=resource.
|
|
22
|
-
"";return{name:"list",summary:`${resource.label}\u3092\u4E00\u89A7\u3059\u308B\uFF08\u767B\u9332\u306E\u65B0\u3057\u3044\u9806\uFF09`,usage:`twp ${resource.
|
|
23
|
-
\u8CA9\u58F2\u7BA1\u7406\u306E${resource.label}\u3092\u4E00\u89A7\u3057\u307E\u3059\u3002\u898B\u3048\u308B\u306E\u306F\u30B5\u30FC\u30D0\u304C\u3042\u306A\u305F\u306B\u898B\u305B\u308B${resource.
|
|
15
|
+
<\u72B6\u6CC1>"})}return flags}function listFlags(resource){return[...PAGE_NUMBER_LIST_FLAGS,...filterFlags(resource)]}async function statusCodes(input,resource){const refs=statusRefs(resource.statuses);const codes=[];for(const raw of repeatedValues(input,"--status")){const ref=await resolveNamed(raw,refs,{flag:"--status",label:`${resource.label}\u306E\u30B9\u30C6\u30FC\u30BF\u30B9`,scope:"\u3053\u306E CLI"});if(!codes.includes(ref.id))codes.push(ref.id)}return codes}async function allocationCode(input){
|
|
16
|
+
const raw=nonEmpty(input.flags,"--allocation");if(raw===void 0)return void 0;return(await resolveNamed(raw,statusRefs(ALLOCATION_STATUSES),{flag:"--allocation",label:"\u56DE\u53CE\u72B6\u6CC1",scope:"\u3053\u306E CLI"})).id}function noArgs(input,resource,op){if(input.args.length>0){throw new UsageError(`${op} \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,`twp ${resource.name} ${op} help`)}}async function prepareFilters(input,ctx,resource,op){noArgs(
|
|
17
|
+
input,resource,op);if(op==="list")listQuery(input,resource);else filterQuery(input,resource);const status=await statusCodes(input,resource);const allocation=resource.name==="invoice"?await allocationCode(input):void 0;const resolved={};if(status.length>0)resolved["status"]=status.join(",");if(allocation!==void 0)resolved["allocation"]=allocation;const customer=nonEmpty(input.flags,"--customer");if(customer!==void 0){resolved["customer"]=(await ctx.resolver.company(customer,{flag:"--customer",source:"\
|
|
18
|
+
sales",mustExist:true})).id}const project=nonEmpty(input.flags,"--project");if(project!==void 0)resolved["project"]=await ctx.projectId(project);const assignee=nonEmpty(input.flags,"--assignee");if(assignee!==void 0)resolved["assignee"]=(await ctx.resolver.user(assignee,"--assignee")).id;return withResolved(input,resolved)}function filterQuery(input,resource){const resolved=input.resolved??{};return{keyword:nonEmpty(input.flags,"--keyword"),status_list:resolved["status"],company_id:resolved["cus\
|
|
19
|
+
tomer"],project_id:resolved["project"],[resource.userParam]:resolved["assignee"],[`${resource.dateParam}_from`]:isoDate(input,"--from"),[`${resource.dateParam}_to`]:isoDate(input,"--to"),...resource.name==="invoice"?{allocation_status:resolved["allocation"],consolidated_view:1}:{},...STABLE_PAGE_ORDER}}function listQuery(input,resource){const{page_no,page_limit}=pageNumberQuery(input);return{...filterQuery(input,resource),page_limit,page_no}}function recordId(input,resource){const[raw,...rest]=input.
|
|
20
|
+
args;const id=raw?.trim()??"";const usage=`twp ${resource.name} get help`;if(id==="")throw new UsageError(`${resource.label}\u306E ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,usage);if(rest.length>0)throw new UsageError(`get \u304C\u53D7\u3051\u53D6\u308C\u308B${resource.label} ID \u306F1\u3064\u3060\u3051\u3067\u3059: ${rest.join(" ")}`,usage);if(!isExactNumericId(id)){throw new UsageError(`${resource.label}\u306E ID \u306F\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}`,
|
|
21
|
+
`${resource.label}\u756A\u53F7\uFF08${resource.name==="estimate"?"EST0000063":"INV0000170"} \u306E\u3088\u3046\u306A\u5024\uFF09\u3067\u63A2\u3059\u306A\u3089 twp ${resource.name} list --keyword <\u756A\u53F7> \u306E id \u5217\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`)}return id}function listOperation(resource){const paging=pageNumberPaging({label:`${resource.label}\u4E00\u89A7`});const rows=body=>{envelope(body,`${resource.label}\u4E00\u89A7`);return paging.items(body)};const consolidated=resource.
|
|
22
|
+
name==="invoice"?"\u753B\u9762\u306E\u8ACB\u6C42\u4E00\u89A7\u3068\u540C\u3058\u304F\u3001\u7D71\u5408\u8ACB\u6C42\u66F8\u306F\u672C\u4F53\u30921\u884C\u3067\u51FA\u3057\u3001\u7D71\u5408\u5143\u306E\u8ACB\u6C42\u306F\u305D\u306E children \u306B\u5165\u308A\u307E\u3059\uFF08\u6700\u4E0A\u4F4D\u306B\u306F\u51FA\u307E\u305B\u3093\uFF09\u3002\n":"";return{name:"list",summary:`${resource.label}\u3092\u4E00\u89A7\u3059\u308B\uFF08\u767B\u9332\u306E\u65B0\u3057\u3044\u9806\uFF09`,usage:`twp ${resource.
|
|
23
|
+
name} list [--keyword <\u8A9E>] [--status <\u30B9\u30C6\u30FC\u30BF\u30B9>]... [--customer <\u53D6\u5F15\u5148>] [--project <\u30B3\u30FC\u30C9|ID>] [--assignee <\u30E6\u30FC\u30B6\u30FC>] [--from <\u65E5\u4ED8>] [--to <\u65E5\u4ED8>]${resource.name==="invoice"?" [--allocation <\u72B6\u6CC1>]":""} [--all] [--limit <\u4EF6\u6570>]`,description:`\u8CA9\u58F2\u7BA1\u7406\u306E${resource.label}\u3092\u4E00\u89A7\u3057\u307E\u3059\u3002\u898B\u3048\u308B\u306E\u306F\u30B5\u30FC\u30D0\u304C\u3042\u306A\u305F\u306B\u898B\u305B\u308B${resource.
|
|
24
|
+
label}\u3060\u3051\u3067\u3059
|
|
24
25
|
\uFF08\u7BA1\u7406\u8005\u4EE5\u5916\u306F\u3001\u30E1\u30F3\u30D0\u30FC\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E${resource.label}\u3068\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u672A\u8A2D\u5B9A\u3067\u81EA\u5206\u304C\u4F5C\u6210\u8005\u30FB\u62C5\u5F53\u8005\u306E${resource.label}\uFF09\u3002
|
|
25
26
|
`+consolidated+`
|
|
26
27
|
--status \u306B\u6E21\u305B\u308B\u5024: ${statusHelp(resource.statuses)}
|
|
@@ -33,8 +34,8 @@ return id}function listOperation(resource){const paging=pageNumberPaging({label:
|
|
|
33
34
|
--output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
|
|
34
35
|
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${resource.listColumns.join(" / ")}\u3001status \u306E\u5F8C\u308D\u306B status_name\uFF09\u3067\u3059\u3002
|
|
35
36
|
|
|
36
|
-
`+LIST_PAGING_HELP+"\n"+PAGE_NUMBER_PAGING_HELP,flags:listFlags(resource),paging,forbidden:SALES_FORBIDDEN,prepare:(input,ctx)=>
|
|
37
|
+
`+LIST_PAGING_HELP+"\n"+PAGE_NUMBER_PAGING_HELP,flags:listFlags(resource),paging,forbidden:SALES_FORBIDDEN,prepare:(input,ctx)=>prepareFilters(input,ctx,resource,"list"),plan:input=>({method:"GET",path:resource.path,query:listQuery(input,resource)}),summarize:body=>rows(body).map(row=>withStatusName(row,resource.listColumns,resource.statuses)),raw:rows,notes:totalsNote}}function getOperation(resource){const what=resource.label;return{name:"get",summary:`${what}1\u4EF6\u306E\u8A73\u7D30\u3092\u8868\u793A\u3059\u308B`,
|
|
37
38
|
usage:`twp ${resource.name} get <${what}ID>`,description:`ID \u306F twp ${resource.name} list \u306E id \u5217\u306E\u6570\u5B57\u3067\u3059\uFF08${what}\u756A\u53F7\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09\u3002
|
|
38
39
|
|
|
39
|
-
--output json \u306F${what}\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u660E\u7D30 details \u3092\u542B\u3080\uFF09\u3092\u51FA\u3057\u307E\u3059\u3002`,flags:[],forbidden:SALES_FORBIDDEN,plan:input=>({method:"GET",path:`${resource.path}/${encodeURIComponent(recordId(input,resource))}`}),summarize:body=>withStatusName(detail(body,what),resource.getColumns,resource.statuses),raw:body=>detail(body,what)}}
|
|
40
|
-
|
|
40
|
+
--output json \u306F${what}\u306E\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u660E\u7D30 details \u3092\u542B\u3080\uFF09\u3092\u51FA\u3057\u307E\u3059\u3002`,flags:[],forbidden:SALES_FORBIDDEN,plan:input=>({method:"GET",path:`${resource.path}/${encodeURIComponent(recordId(input,resource))}`}),summarize:body=>withStatusName(detail(body,what),resource.getColumns,resource.statuses),raw:body=>detail(body,what)}}var estimateReadOperations=[listOperation(ESTIMATE),getOperation(ESTIMATE)];var invoiceReadOperations=[
|
|
41
|
+
listOperation(INVOICE),getOperation(INVOICE)];var invoiceFilters={flags:()=>filterFlags(INVOICE),prepare:(input,ctx,op)=>prepareFilters(input,ctx,INVOICE,op),query:input=>filterQuery(input,INVOICE),statusName:code=>INVOICE_STATUSES[code]??code,statusCodes:input=>statusCodes(input,INVOICE),statusHelp:()=>statusHelp(INVOICE_STATUSES)};export{licenseForbidden,featureLicenseGuidance,estimateReadOperations,invoiceReadOperations,invoiceFilters};
|