# `Sp_System_CalcCurrentPeriodCost_1115` (procedure)

> @author:杨恒林
							@date:20210523 封存
							@describe: 从成本月结表中，拿到工单数据，计算本月成本数据后回写到成本月结表	注意点：
							1.本期期初成本从本工单最近一次月结成本表中获取，不一定就是上期
							2.在制品是指所有入库数小于工单数的工单


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `sPeriod` | `varchar(100)` |
| 4 | IN | `sProInParam` | `varchar(255)` |
| 5 | IN | `sMakePerson` | `varchar(100)` |
| 6 | IN | `sBrId` | `varchar(100)` |
| 7 | IN | `sSuId` | `varchar(100)` |
| 8 | OUT | `sReturn` | `varchar(1000)` |
| 9 | OUT | `sCode` | `int` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_System_CalcCurrentPeriodCost_1115`'`._

## Narrative

**Business context:** 成本核算 → 订单成本分析 / 工单本期成本 — dated backup revision (`_1115`) of `Sp_System_CalcCurrentPeriodCost`. Same author/header — preserved alongside the live body so a rollback or comparison is possible if the recomputation produces unexpected period numbers.

**What it does:** Same algorithm as `Sp_System_CalcCurrentPeriodCost` at the time of the `1115` snapshot — walks `accordercostanalysis` rows in the requested period, sums 入库 / 材料 / 人工 / 制造费用 from the respective ledgers, applies the work order's most recent prior 期初 amount, and writes `dInMoney`/`dEndMoney`/`d_*Cost` back to the month-end row. Per the playbook backup-variant convention, treat divergence from the live body as a regression candidate rather than an intentional behavioural difference.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName` hook, no `gdsconfigformmaster` binding, no other-routine caller in `information_schema.ROUTINES`, no xly-src reference outside the procedure itself. Kept purely as a backup snapshot of the production proc — not expected to be called from any live flow. Verify before redeploying.
