{% extends "erp_base.html" %} {% from "inout/_macros.html" import status_badge, order_badge, progress, due, n, ymd, ymdhm %} {#- 메일 창(발주 메일 · 입고 요청 메일 같은 모양) — 열면 미리보기 GET, [메일 발송]을 눌러야 보낸다(inout.js initMail) -#} {%- macro mail_dialog(id, title, open_url='', open_title='') -%}

{{ title }}

불러오는 중…

{%- endmacro -%} {% block head_extra %}{% endblock %} {% block content %} {% set active = order.status in ('open', 'partial') %} {% set receiving = perms.can_receive and can_receive_now %} {# 전체 입고 완료(모든 품목 입고완료·초과) — 입고 칸·[입고 저장]을 흐리게 막는다(서버도 거절, 2026-10-19). 입고 기록을 지우면 다시 열림 #} {% set recv_done = order.status in ('done', 'over') %} {% set dis = ' disabled' if recv_done else '' %} {% set photo_admin = perms.can_receive and not order.cancelled_at %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
{% include "inout/_nav.html" %}

{{ order.order_no }}

{{ order_badge(order.status, order.status_label) }}
공장
{{ order.factory_name }}{% if order.factory_manager or order.factory_contact %}{{ order.factory_manager }}{% if order.factory_manager and order.factory_contact %} · {% endif %}{{ order.factory_contact }}{% endif %}
발주일
{{ ymd(order.order_date) }}
입고 예정일
{{ due(order.due_date, today, active) }}
진행
{{ progress(order.summary) }}
발주 메일
{% if order.mails %}{% set last = order.mails[-1] %}보냄 {{ ymdhm(last.sent_at) }}{{ last.sent_by }} → {{ last.to_addrs }}{% if order.mails|length > 1 %} · 모두 {{ order.mails|length }}번{% endif %}{% else %}아직 안 보냄{% endif %}
{% if order.memo %}
메모
{{ order.memo }}
{% endif %} {% if order.closed_at %}
종결
{{ ymd(order.closed_at) }} · {{ order.closed_by }}{% if order.close_reason %} — {{ order.close_reason }}{% endif %}
{% endif %} {% if order.cancelled_at %}
취소
{{ ymd(order.cancelled_at) }} · {{ order.cancelled_by }}
{% endif %}
발주
{{ n(order.summary.ordered) }}
입고
{{ n(order.summary.received) }}
미입고
{{ n(order.summary.remaining) }}
{% if order.summary.over %}
초과
+{{ n(order.summary.over) }}
{% endif %}
{% if perms.can_order and not order.cancelled_at %}
발주서 고치기 {% if order.closed_at %}
{% elif order.summary.remaining %}
{% endif %} {% if not order.receipts %}
{% endif %}
{% endif %}
{% if error %}{% endif %}
{# Enter 키 = 이 버튼(일반 저장). 없으면 폼의 첫 제출 버튼인 [초과 입고로 저장]이 눌려 확인 없이 초과가 저장된다 #} {% if receiving %}{% endif %}

품목

{% if receiving and recv_done %}✓ 전체 입고 완료 — 더 입고할 수 없습니다(잘못 넣은 입고는 아래 입고 기록에서 지운 뒤 다시 넣으세요) {% elif receiving %}물류에 들어온 수량을 [이번 입고]에 넣고 저장 — 여러 번 나눠 넣어도 됩니다 {% elif perms.can_receive and order.closed_at %}종결된 발주서 — 입고하려면 발주 담당이 종결을 풀어야 합니다{% endif %}
{% if over %} {% elif photos_lost %}

고른 입고증 사진은 다시 첨부해야 합니다(화면이 다시 열리면서 빠졌습니다).

{% endif %}
{# 입고 담당(발주 담당 아님) = 제품 이름·발주 수량(+ 이번 입고)만, 발주 담당 = 단가·금액·PP·은 함께 #} {% if not items_limited %}{% endif %} {% if show_prices %}{% endif %} {% if not items_limited %}{% endif %} {% if receiving %}{% endif %} {% for ln in order.lines %} {% if not items_limited %}{% endif %} {% if show_prices %} {% set amt = line_amount(ln.qty, ln.unit_price) %}{% set ag = silver_g(ln.weight_g, ln.silver_pct) %}{% set use = line_usage(ln) %} {# 발주 수량 전체 사용량(2026-10-21) — PP 사용량·은 함유량 kg(메일 표와 같은 값), 아래 작은 글씨 = 개당 값 #} {% endif %} {% if not items_limited %} {% endif %} {% if receiving %}{% endif %} {% endfor %} {% if show_prices and order.lines %} {# 합계 무게 = 소수 첫째 자리에서 반올림(정수 kg) #} {% if not items_limited %}{% endif %} {% if receiving %}{% endif %} {% endif %}
#제품 코드제품발주단가(원)금액(원)PP 사용량은(Ag) 함유량입고미입고상태이번 입고
{{ loop.index }}{{ ln.item_code }}{{ ln.item_name }}{% if ln.memo %}
{{ ln.memo }}
{% endif %}
{{ n(ln.qty) }}{{ fmt_num(ln.unit_price) if ln.unit_price is not none else '-' }} {{ fmt_num(amt) if amt is not none else '-' }}{% if use.pp_use_kg is not none %}{{ fmt_num(use.pp_use_kg, 3) }}kg{% else %}-{% endif %}{% if ln.weight_g is not none %}
{{ fmt_num(ln.weight_g) }}g/개
{% endif %}
{% if use.ag_kg is not none %}{{ fmt_num(use.ag_kg, 3) }}kg{% else %}-{% endif %}{% if ln.silver_pct is not none %}
{{ fmt_num(ln.silver_pct, 4) }}%{% if ag is not none %} · {{ fmt_num(ag, 4) }}g/개{% endif %}
{% endif %}
{{ n(ln.received) }} {{ n(ln.remaining) }}{% if ln.over %}
초과 +{{ n(ln.over) }}
{% endif %}
{{ status_badge(ln.status, ln.status_label) }}
합계 {{ n(order.summary.ordered) }} {{ fmt_num(totals.amount) ~ ' 원' if totals.amount is not none else '-' }}{% if totals.missing_price %}
단가 미입력 {{ totals.missing_price }}종 제외
{% endif %}
{% if totals.pp_use_kg is not none %}{{ fmt_num(totals.pp_use_kg, 0) }} kg{% else %}-{% endif %} {% if totals.silver_g is not none %}{{ fmt_num(totals.silver_g / 1000, 0) }} kg{% else %}-{% endif %}
{% if receiving %}
입고증 사진 (최대 {{ max_photos }}장)
{% endif %}

입고 기록

{{ order.receipts|length }}회
{% if order.receipts %}
{% if photo_admin %}{% endif %} {% for r in order.receipts %} {% if photo_admin %} {% endif %} {% endfor %}
입고일품목별 수량합계입고증입력입고 요청 메일 · 사방넷
{{ ymd(r.receipt_date) }}{% if r.memo %}
{{ r.memo }}
{% endif %}
{% for x in r.lines %}{% if items_limited %}{{ x.item_name }}{% else %}{{ x.item_code }}{% endif %} {{ n(x.qty) }}{% endfor %} {{ n(r.total) }} {% for ph in r.photos %} {% endfor %} {% if photo_admin and r.photos|length < max_photos %}
{% elif not r.photos %}-{% endif %}
{{ r.created_by }}
{{ ymdhm(r.created_at) }}
{% if r.mails %}{% set lm = r.mails[-1] %}보냄 {{ ymdhm(lm.sent_at) }}
{{ lm.sent_by }}{% if r.mails|length > 1 %} · 모두 {{ r.mails|length }}번{% endif %}
{% endif %} {% if perms.can_receive %} {% elif not r.mails %}-{% endif %} {% if perms.can_order or perms.can_receive %} 사방넷 입고 파일 {% endif %}
{% else %}

아직 입고된 것이 없습니다.

{% endif %}
{# 입고증 사진 크게 보기 — 앞뒤 넘기기(←/→), 원본 열기, 지우기(입고 담당) #}
원본 {% if photo_admin %}
{% endif %}
입고증 사진
{% if perms.can_order and not order.cancelled_at %} {# 발주 메일 — 열면 GET /inout/orders/{id}/mail 로 미리보기, [메일 발송]을 눌러야 보낸다(발주 담당 본인 Gmail) #} {{ mail_dialog('io-mail', '발주 메일 보내기 · ' ~ order.order_no) }} {% endif %} {% if perms.can_receive and order.receipts %} {# 입고 요청 메일(005) — 물류센터 입고 담당자에게 전산 등록 부탁(입고 담당 본인 Gmail). 입고 저장 뒤 ?rmail={입고 id} 면 바로 연다 #} {% set open_r = order.receipts | selectattr('id', 'equalto', open_rmail) | list if open_rmail else [] %} {% if open_r %} {{ mail_dialog('io-rmail', '입고 요청 메일', '/inout/orders/' ~ order.id ~ '/receipts/' ~ open_r[0].id ~ '/mail', '입고 요청 메일 · ' ~ ymd(open_r[0].receipt_date) ~ ' 입고 ' ~ n(open_r[0].total) ~ '개') }} {% else %}{{ mail_dialog('io-rmail', '입고 요청 메일') }}{% endif %} {% endif %}
{% include "inout/_calendar.html" %}
{% endblock %} {% block scripts %}{% endblock %}