Topics

I needed a purchase order, so I created a purchase order generation tool (desktop app) using Claude Code.

  • column

Whenever we encounter something in our daily work that we find a bit too tedious to continue doing manually, it's become commonplace to simply create a small system using Claude Code!

This story is a perfect example of that, and it all started when we increased the company's capital.

Our fiscal year begins in February, and this capital increase also took place in February. However, with the increase in capital, we now need to be more meticulous in organizing our ordering processes with external partners and collaborating companies.

This is the area known as the Subcontracting Act, which under the current system will be called the "Subcontracting Act" from January 2026. The ordering party will have to deal with more things, such as clearly stating the order details, creating and saving transaction documents, and setting payment deadlines.

Of course, this isn't just a matter of "we have to do it because it's the law"!

When outsourcing work to an external partner, it's crucial for both the client and the service provider to clearly define the order details, price, date, and correspondence with the quotation.

It wasn't a feature included in the accounting tool.

Our company uses MoneyForward (hereinafter referred to as MoneyForward) tools for accounting, quoting, and invoicing.
It's convenient for everyday accounting and billing tasks, but what I wanted to do this time was slightly different.

Based on the quotation PDF received from the external partner, we create a purchase order PDF for Liberogic.

At least within the scope of our company's use, MoneyForward doesn't have the features that are just right, and it would be a waste of money to subscribe to the service just for that purpose.

If it were to be done manually,

  • Create a purchase order format
  • Manually transcribe the information from the quotation into the purchase order format.
  • Please enter the order date.
  • Transcribe the quotation number.
  • Transcribing the details
  • Please check the total amount and other details.
  • Format the file names
  • Other miscellaneous...

It's a hassle to have this extra task... so I decided to create it.

It was put into practical use in less than an hour using Claude Code.

The timing was also good.

The start of the fiscal year in February, the capital increase in February, and the release of Claude Code, along with its adoption by our staff, all coincided.

This was around the time when a hackathon-like movement was starting within the company, where people were using tools like Claude Code to create business improvement tools, small internal apps, and even deploy spontaneous ideas!

From a very basic specification outline to instructions for Claude Code, and including fine-tuning...

I was able to get it to a usable state in just under an hour.

Well, you can't just hand everything over to AI and expect it to be completed, but if you properly translate it into prompts, it can be quick and convenient!

Desktop application completed

This is a simple purchase order generation tool that runs on the operating system you're probably already using.

Please send the quotation PDF to the dedicated.appWhen you drag and drop the file, a Python script will be executed, which will read the contents of the quotation PDF and generate a purchase order PDF in the same folder.
Once completed, it's a simple process that displays a notification on macOS and automatically opens the generated purchase order PDF.

The structure is as follows:

~/Desktop/Generate Purchase Order/
Drop the quotation → Generate Purchase Order.app
_lib/
generate_purchase_order.py
liberogic_logo.png
liberogic_seal.png
purchase_order_counter.json

To allow accounting and administrative staff to use it without opening a terminal, we use an AppleScript droplet as the entry point, with the actual PDF generation process handled by Python.

In short, just toss in the quotation PDF.A desktop app that generates a PDF purchase order when you drag and drop it.It can be used without opening a terminal, making it easy to use for internal administrative tasks.

The appearance of the purchase order PDF is designed to resemble the invoice and quotation PDF format we use at our company.
The following text is included in the remarks section:

This purchase order constitutes a formal order. The order is placed based on quotation number XXX.

The order number was formatted as follows:

{会社略称}様 発注書{YYYY}{MM}{3桁連番}

For example, if it's the first item for Mr./Ms. XX in February 2026,

Dear Mr./Ms. XX, Purchase Order 202602001

It will look like this.

The sequential numbers by company and month arepurchase_order_counter.jsonThe system manages this, and the order date is automatically calculated as 5 business days after the date on the quotation. (This is just a temporary specification! It will be changed later under management!)
To exclude not only Saturdays and Sundays but also Japanese public holidays, PythonjpholidayI used it.

Just a few slightly difficult parts

The quotations that form the basis of purchase orders are obtained from external partners and collaborating companies, so the format varies from company to company.
Simply assuming "the company name is at this coordinate" or "the total amount is at this location" is not sufficient.

Ultimately, the process involves using regular expressions to extract vendor name, address, phone number, quotation number, quotation date, subject, details, subtotal, consumption tax, and total as flexibly as possible, treating companies with "Attn:" attached as our own company and others as suppliers, and dealing with issues like information that appears separate visually being merged into the text when extracting text from PDFs.

Because there were cases where building names or floor numbers were included after the subject line, we've added a process to filter out unnecessary address information using terms like "building" and "floor" as clues.

Whether it's AI or whatever, this is still a common issue with PDF processing.

Prompt passed to Claude Code

Rather than making a vague request, it's more economical to use tokens if you write as specifically as possible, including folder structure, processing flow, layout, numbering rules, business day calculation, PDF extraction items, etc.
Let's also have them read the sample PDF!

以下の条件で、見積書PDFを発注書PDFに自動変換するツールをmacOS向けに作ってください。

## 環境

- macOS / Python3(pip可)
- フォント:`~/Library/Fonts/NotoSansJP-Regular.ttf` / `NotoSansJP-Bold.ttf`

## フォルダ構成

`~/Desktop/発注書生成/
  見積書をドロップ→発注書生成.app
  _lib/
    generate_purchase_order.py
    liberogic_logo.png
    liberogic_seal.png
    purchase_order_counter.json`

## 処理フロー

1. `.app` に見積書PDFをドラッグ&ドロップ
2. Pythonスクリプトを実行し発注書PDFを生成
3. 完了通知(macOS通知)を出して発注書PDFを自動で開く
4. 発注書PDFは見積書と同じフォルダに保存

## 発注書の仕様

出力フォーマットは添付のMoneyForward形式のPDFに合わせること。

このPDFから以下を抽出して使う:

- ロゴ画像
- 押印画像
- レイアウト座標
- 列幅
- 余白
- フォントサイズ

## 自社情報

リベロジック株式会社
登録番号:T2010401081132
〒108-0073 東京都港区三田1-3-37 板金会館2F
TEL: 03-6809-4366 / FAX: 03-6809-4367

## 発注書番号

- 形式:`{会社略称}様 発注書{YYYY}{MM}{3桁連番}`
- 会社別・月別の連番を `purchase_order_counter.json` で管理
- 出力ファイル名もこの発注書番号に揃える

## 発注日

- 見積書の日付から5営業日後
- 土日と日本の祝日を除外する

## 見積書からの情報抽出

- どんな会社のフォーマットでも対応できる柔軟な正規表現で抽出
- 抽出項目:ベンダー名・住所・TEL、見積書番号、見積日、件名、明細、小計・消費税・合計
- ベンダー判定:「御中」の付いた会社=自社、それ以外=発注先
- 件名に住所の建物名が混入するケースに対応

## 発注書レイアウト

- タイトル「発注書」中央大文字
- 左:発注先の社名・住所・TEL
- 右:自社情報+ロゴ+押印+発注書番号・発注日・見積書番号・見積日
- 件名・発注金額を大きく表示
- 明細テーブル:品目/単価/数量/単位/価格
- 交互グレー背景
- 最低8行
- 合計エリア:小計・消費税・合計のみ
- 備考欄を枠付きで表示
- ページ番号なし

Although it's essentially a simplified specification document, it's important to provide as much detail as possible about the business constraints and the desired final product, but a simply saying "make it look good."
Well, in the end, it fails when I try to get it to read a different format, so I need Claude to work even harder, but it's still fast, so I guess it's okay.
(The number of external staff and collaborating partners we work with doesn't even reach double digits, so it's not a big deal!)

Because it's so convenient, we also need to be concerned about security.

On the other hand, when using AI development support, you need to consider not only convenience but also security.

As you work through the process, giving instructions to Claude Code, several operations will be performed on your local environment.

- Reading and writing files to ~/Desktop
- Considering access to ~/Library/Services/
- Adding Python libraries using pip install
- Generating AppleScript applications using osacompile
- Reading font files located in ~/Library/Fonts/

This isn't a particularly important story, but it's still a bit scary to give AI execution privileges in a local environment, isn't it? 😨

When entrusting terminal operations or file operations to a system, there is a possibility of unintended file creation/overwriting/deletion.

  • Check what you're allowing!
  • Make a backup!
  • For anything that can be managed with Git, check the differences!
  • Let's create separate working folders!

These basic measures are important. If you're using it for development work, it might be better to load the .env file via 1Password. It's a bit of a hassle, but it makes a big difference. (byOur CTO

On the other hand, as in this caseIf it's only intended for use in a local environment, the risks are relatively limited.In most cases, the impact rarely spreads externally via the network, and is limited to affecting only one's own environment at worst.

There are many other points to keep in mind, but "being able to create something quickly" and "being able to use it safely" are two different things. When developing using AI, be sure to check the execution permissions, file operations, external libraries, and how to handle input data as you go along!

Moving forward, we will focus on staff sharing and integration with Supabase.

So, what I've created this time is a simple purchase order generation tool that runs in a local environment.

In the initial stage,purchase_order_counter.jsonWe've set up a system to manage sequential numbers by company and month, but considering that we'll be sharing this with staff in the future, managing the sequential numbers using only local JSON files will naturally lead to issues like duplicate purchase order numbers.

Therefore, I plan to implement company-specific and monthly counters on the Supabase side so that there are no duplicate sequential numbers even when multiple people use it, and also add features such as purchase order issuance history, supplier, quotation number, order amount, order date, and PDF save location!

Written by

Despite being the CEO, he's always a counterpart. He finds joy in understanding new technologies and witnessing moments of convenience, and he's a hands-on, immersive individual. He's excited about future technologies and wants to continue enjoying new experiences no matter his age.

Morimoto

Project Manager / Director / Founded in 2007

View this staff member's article

We pride ourselves on our reliable team structure and speedy response capabilities.

At Liberogic, our experienced staff proactively drive projects forward, which is why we are highly regarded by our clients.
We ensure that project managers and directors are properly assigned to ensure the smooth progress of the entire project. We prevent unnecessary cost increases from full commitments and allocate resources to the right people in the right places, and are well-known for the speed with which we can grasp the work content, create and submit estimates.

Please note that we do not actively engage in SES-style on-site work.

We support almost all major project management and chat tools, including Slack, Teams, Redmine, Backlog, Asana, Jira, Notion, Google Workspace, Zoom, and Webex.

Please contact us with any web-related concerns you may have.

Case Study