{% extends "core/detail.html" %} {% load seizou_tags seizou_icons purchasing_tags %} {# 発注の詳細: core の詳細 (基本情報と「送った記録」のタブ) の下に明細の表 (相手の出荷の知らせの列と、出荷ごとの「受入を記録する」を含む。受入の link は取消と断られた発注には出さず、数量は知らせのまだ受け入れていない数 (purchasing_tags の notice_rests)) と、seizou どうしで送った発注だけ検収の節。「作成」のときだけ送り直す、「作成」か「断られた」のとき取り消すのボタン。書く入口 (送り直す・取り消す・受入・検収の送り直す) は発注の権限がある人だけ (決め 11-04 00:0x)。明細の表の先頭の「操作」の列は、行ごとの ⋮ のメニュー (受注の明細と同じ形で、右クリックでも同じメニュー。中身は受入の新規登録 (出す条件は前のボタンと同じ) と、完了にする (取消でも断られたでもない発注の、取り消していない終わっていない明細 = 完了の印が偽で受入の残が 0 より大きい明細) と、完了を外す (取消でない発注の完了の明細)。完了の 2 つは発注を書ける人 (can_write "purchasing.PurchaseOrder") だけで、数量まで受け入れて終わった明細にはどちらも出さない (N400b)。出す物が無い行には ⋮ も出さない。受入の残の枡の後ろに、完了の明細だけ「完了」「完了 (受けない n)」の印 (purchasing_tags の line_completed_label)。表が箱より広い幅でも送らずに押せるように。決め 11-03 17:2x・11-06 22:2x = 作者の決め)。頭の右の緑はその伝票で次にする操作 1 つ (作者の決め 11-06 22:1x。無ければ今のまま): 「作成」は「再送」、ほかは受け入れていない出荷の知らせがあれば「受入を記録する」(行き先は表の一番上の「受入を記録する」と同じ。purchasing_tags の next_receipt。作者の決め)。 #} {# 指示書の工程を指す明細 (N406b): 部品の枡の下に「指示書 <番号> の工程 <順> <名前>」(指示書の詳細への link。purchasing_tags の line_step。部署で指示書を開けない人には字だけ = 土台の基本の表の値の link (record_url) と同じ判定。詳細の画面は部署で絞らないので URL を直に開けば開くが、入口は出さない。seizou_tags の can_open) と「渡した日 <日付>」か「まだ渡していない」を出す (列は足さない)。明細の ⋮ に「渡した日」(渡した日の画面を小窓で開く。JS の無いときは ?next= で画面へ) を、取消でない発注の取り消していない明細で、受入を書ける人 (can_write "purchasing.Receipt"。渡した日は数と日だけの操作) にだけ出す。⋮ を出す条件は、この項目が出るときにも広げる (ほかの項目の条件は今のまま)。 #} {# 見出しの帯 (#po-heading)・黄の知らせ (#po-alert)・明細と検収の節 (#po-live)・左のメニューの「受入」の印 (#menu-count-purchasingreceipt_list。小窓で受入を保存した後も印が古いまま残らないように。作者の決め) は 2 秒ごとに同じ URL を取りに行って入れ替え、前の更新と状態が違う発注の見出しの帯に seizou-changed を付ける (purchasing_tags の live_state)。タブは入れ替えない (選んだタブが基本情報に戻らないように)。取消と受入の入口は小窓で開く (data-modal-form)。小窓で保存した後の seizou:refresh でも 2 秒ごとの取り直しを走らせる (決め 11-05 11:4x。開発の記録 docs/nights/20261105/N158b.md)。明細の箱を横に送っている間 (scrollLeft が 0 でない) と、明細の ⋮ のメニューを開いている間と、字を選んでいる間 (window.getSelection() の字が空でない) は 2 秒ごとに取り直さない。入れ替えると箱が左の端へ戻り、開いたメニューが閉じ、選んだ字が消えるため (発注の一覧の scrollTop と同じ形。作者の決め。字の選びは作者の決め)。 #} {# 2 列 (作者の決め。開発の記録 docs/nights/20261105/N150.md): 題の上にパンくず「発注 › 番号」(見出しの帯の中。土台の block heading に crumb を渡す)。block content で黄の知らせの次に右の列のカード (purchasing_tags の purchase_order_aside) を置いてから土台を呼ぶ。明細・検収・流れ (#po-live) は土台の全幅の口 block wide (lg 以上は 2 列の上に全幅。作者の決め)。右の列 (#detail-aside) も 2 秒ごとに入れ替える。 #} {# 段の帯 (開発の記録 docs/nights/20261105/N151.md。core/_stage_band.html) は見出しの帯 (#po-heading) の中の、土台の見出し (パンくずの with の後) に置く。2 秒ごとの入れ替えで段も新しくなる。取消の発注には出さない。 #} {# タブの最後の「会話」は connect の会話の枠 (connect/_chat.html。相手の会社とのやり取り = 作者の決め。0 件でも書く欄と使えない訳を出すので block tab_empty にも置く)。block main にメモの枠 (#po-live の外。#po-live は 2 秒ごとに入れ替わるので、中に置くとメモの書く枠が消える。社内の書き込みはメモ = 本人の決め)。 #} {% block heading %}{% live_state object as live %}
{% purchase_order_head_chips object seizou.hide_money as head_chips %}{% with crumb="発注" %}{{ block.super }}{% endwith %}{% load purchasing_timeline %}{% purchase_order_stages object as band %}{% include "core/_stage_band.html" with stages_id="po-stages" %}
{% endblock %} {# 送った発注の変更 (作者の決め): 見出しの右の白の「変更」は、発注の権限があり、変更を送れる発注 (purchasing_tags の can_change_order) だけ。画面の全体で開く (小窓にしない = 明細の表が広いため)。 #} {# 書く入口の 2 つの答え (決め 11-07 21:0x〜21:2x): 「変更」「取消」は金額に関わる操作なので can_write "purchasing.PurchaseOrder" (発注の権限 + 金額の閲覧)。「再送」「受入を記録する」(頭・明細の ⋮・出荷の知らせの横)・検収の「送り直す」は数だけの操作 (作者の決め) なので、受入の新規登録と同じ答え can_write "purchasing.Receipt" (発注の権限だけ。金額の閲覧を見ない) で出す。 #} {# 版が 2 以上で今の版が相手に届いていない間は、頭の右の緑を「再送」にする (取消の版は状態が「取消」でも)。#po-alert に届いていない・相手が断ったの黄色の 1 行 (revision_state の alert)。 #} {# 印刷用の画面と PDF は協力企業への発注書 (金額が主な書面なので金額の閲覧の無い人には出さない。開発の記録 docs/nights/20261108/N356.md)。新しいタブで開く普通の link (請求書の詳細と同じ字と形)。 #} {% block actions %}{% can_write "purchasing.PurchaseOrder" as can_po %}{% if can_po %}{% can_change_order object as can_change %}{% if can_change %}{% icon "pencil" "size-4" %}変更{% endif %}{% endif %} {% if not seizou.hide_money %} {% icon "file" "size-4" %}印刷用の画面 {% icon "download" "size-4" %}PDF {% endif %} {% endblock %} {# 「⋯」の「取消」は「下書き」「断られた」と、「送った」「相手が受け入れた」の発注に出す (一部を出荷した発注にも出し、押して保存すると断りの字が「変更」の道を案内する)。 #} {% block more %}{% can_write "purchasing.PurchaseOrder" as can_po %}{% if can_po %}{% if object.status == "draft" or object.status == "rejected" or object.status == "sent" or object.status == "accepted" %}{% url 'purchasing:purchaseorder_cancel' object.pk as cancel_url %}{% include "core/_detail_more.html" with more_url=cancel_url more_label="取消" more_modal=True %}{% endif %}{% endif %}{% endblock %} {# 「下書き」で、取引先に向き「送る」のつながりが無い発注 (purchasing_tags の can_mark_sent_outside) は、頭の右の緑を「再送」の代わりに「発注書を送った」にする (小窓で確かめる。出す人は「再送」と同じ。依頼書 N439。本人の決め 11-12 14:3x・18:2x)。つながりのある発注と、版が 2 以上の「再送」の分かれは今のまま。 #} {% block edit_button %}{% can_write "purchasing.Receipt" as can_receipt %}{% if can_receipt %}{% revision_state object as revision %}{% can_mark_sent_outside object as sent_outside %}{% if sent_outside %}{% url 'purchasing:purchaseorder_sent_outside' object.pk as sent_outside_url %} {% icon "check" "size-4" %}発注書を送った {% elif object.status == "draft" or revision and not revision.delivered %}
{% csrf_token %}
{% else %}{% next_receipt object as receipt %}{% if receipt %}{% icon "plus" "size-4" %}受入を記録する{% endif %}{% endif %}{% endif %}{% endblock %} {# 送れなかった「作成」の発注は、送った記録の最後の行 (Outbox の並びは新しい順) の返事を頭の黄の知らせに出す (保存の直後も、送り直すまで)。 #} {# 相手が条件付で受けた・相手が保留した発注は、記録の今の状態を黄の 1 行で出す (知らせの段 5。答えが届くと 2 秒ごとの入れ替えで開いている画面にも出る)。後の版を相手が受け入れた条件付の発注は、受け入れた事の 1 行に替える (本体の決め 11-11 14:2x)。今の版の変更への受諾が届くと、発注の状態は「相手が受け入れた」に進む (本人の決め 11-12 14:1x。connect の受け口) ので、この 1 行が出るのは、その直しの前に答えが届いていた発注 (状態が条件付のまま残った記録) だけ。revision_state は #po-alert の頭で 1 回だけ呼び、条件付の分かれと revision.alert の両方が同じ値を読む。 #} {# つながりの無い「下書き」の発注で、送った記録の無い物は、発注書を seizou の外で送る案内の 1 行 (知らせの段 5)。「発注書を送った」で記録した発注は、取消でない間、記録した日時と、答えが届かない事の 1 行 (依頼書 N439)。 #} {% block content %}
{% revision_state object as revision %}{% if object.status == "draft" %}{% with last=object.outbox_messages.first %}{% if last and last.response != "受け取った" %} {% elif not last %}{% can_mark_sent_outside object as sent_outside %}{% if sent_outside %} {% endif %}{% endif %}{% endwith %}{% elif object.status == "conditional" %}{% if revision and revision.delivered and revision.reply == "AP" %} {% else %} {% endif %}{% elif object.status == "on_hold" %} {% endif %}{% if object.sent_outside_at and object.status != "cancelled" %} {% endif %}{% if revision.alert %} {% endif %}
{% purchase_order_aside object fields seizou.hide_money as aside %}{{ block.super }} {% endblock %} {% block wide %}{% can_write "purchasing.Receipt" as can_receipt %}{% can_write "purchasing.PurchaseOrder" as can_po %}

明細

{% if not seizou.hide_money %}{% endif %} {# 明細は受入の数 (received_total) と受入の残 (remaining_total) を足した物 (発注の読むだけの property)。 #} {% can_open "workorders" as can_open_wo %}{% for line in object.lines_with_received %} {% if not seizou.hide_money %}{% endif %} {# 受けすぎ (受入の数の合計が明細の数量を超えた) の明細は、行の下に黄の知らせ (purchasing_tags の over_receipt_text。受入は止めない)。 #} {% over_receipt_text line as over %}{% if over %}{% endif %} {# 相手の注文回答の明細の答え (条件付受諾の回答単価・回答数量・回答納期。purchasing_tags の reply_line_text。同じ for の中なので問い合わせは増えない)。 #} {% reply_line_text line seizou.hide_money as reply_text %}{% if reply_text %}{% endif %} {% endfor %}
操作 行番号 部品 数量 単位単価 金額受入の数 受入の残 相手からの出荷の知らせ 納期 備考
{% if object.status != "cancelled" and object.status != "rejected" and line.remaining_total > 0 and not line.is_cancelled and can_receipt or object.status != "cancelled" and object.status != "rejected" and line.remaining_total > 0 and not line.is_cancelled and not line.completed and can_po or object.status != "cancelled" and line.completed and can_po or object.status != "cancelled" and line.workorder_step_id and not line.is_cancelled and can_receipt %}{% endif %} {{ line.line_no }}{% if line.is_cancelled %} 取消{% elif line.line_status_code == "1" %} 追加{% elif line.line_status_code == "3" %} 変更 ({{ line.get_line_status_reason_code_display }}){% endif %} {% master_link line.item %}{% if line.process_id %}工程 {{ line.process.name }}{% endif %}{% if line.quote_no %}見積の番号 {{ line.quote_no }}{% endif %}{% line_step line as step %}{% if step %}{% url 'workorders:workorder_detail' step.workorder as workorder_url %}{% if workorder_url and can_open_wo %}{{ step.text }}{% else %}{{ step.text }}{% endif %}{% if line.handed_on %}渡した日 {{ line.handed_on|date:"Y-m-d" }}{% else %}まだ渡していない{% endif %}{% endif %} {{ line.qty|comma }} {{ line.unit }}{{ line.unit_price|yen }} / {{ line.price_unit_text }} {{ line.amount|yen }}{{ line.received_total|comma }} {% if line.remaining_total < 0 %}{{ line.remaining_total|comma }}{% else %}{{ line.remaining_total|comma }}{% endif %}{% line_completed_label line as completed_label %}{% if completed_label %}{{ completed_label }}{% endif %} {% with notice=line.shipping_notice %}{% if notice.rows %}{% notice_rests line as rests %}
    {% for entry in rests %}{% with row=entry.notice %}
  • {{ row.shipped_at|date:"Y-m-d" }} ×{{ row.qty_text }}{% if row.order_revision_no < object.revision_no %} 第 {{ row.order_revision_no }} 版の注文への知らせ (今は第 {{ object.revision_no }} 版){% endif %}{% if object.status != "cancelled" and object.status != "rejected" and line.remaining_total > 0 and entry.rest > 0 and not line.is_cancelled and can_receipt %} 受入を記録する{% endif %}
  • {% endwith %}{% endfor %}
{% if notice.count > 1 %}

合計 {{ notice.total_text }}

{% endif %}{% else %}—{% endif %}{% endwith %}
{% if line.due_date %}{{ line.due_date|date:"Y-m-d" }}{% else %}—{% endif %} {{ line.note }}
{% if object.outbox_messages.exists %}

検収 ({{ object.partner.name }} へ送った受入の数)

受入を登録すると、受け入れた数を {{ object.partner.name }} の受注に「検収」として送ります。届いていない物は「送り直す」で送れます。

{% with receipts=object.receipts.all %}{% if receipts %}
{% for receipt in receipts %} {% endfor %}
受入日明細数量検収操作
{{ receipt.received_on|date:"Y-m-d" }} {{ receipt.line.line_no }} {% master_link receipt.line.item %} {{ receipt.qty|comma }} {% with state=receipt.acceptance_state %}{% if receipt.acceptance_sent_at %}{{ state }}{% elif state %}{{ state }}{% else %}—{% endif %}{% endwith %} {% if not receipt.acceptance_sent_at and can_receipt %}
{% csrf_token %}
{% endif %}
{% else %}

受入はまだありません。

{% endif %}{% endwith %}
{% endif %} {% include "purchasing/_timeline.html" %}
{% endblock %} {% block main %}{% if "notes" in seizou.parts %}{% include "notes/_note.html" %}{% endif %}{% endblock %} {% block tab_rows %}{% if tab.related == "chat_messages" %}{% include "connect/_chat.html" with chat_target=object %}{% else %}{{ block.super }}{% endif %}{% endblock %} {% block tab_empty %}{% if tab.related == "chat_messages" %}{% include "connect/_chat.html" with chat_target=object %}{% else %}{{ block.super }}{% endif %}{% endblock %}