Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VDJVpPiGiWjJP1yVvvGhzQ
This commit is contained in:
+34
-5
@@ -282,6 +282,7 @@
|
||||
const merged = new Set(DASHBOARD_COMPANY_MULTIPLIERS);
|
||||
const units = [];
|
||||
const seen = new Set();
|
||||
const sharedOut = codaSharedOutDepts();
|
||||
depts.forEach(d => {
|
||||
const company = shortCompanyName(map.get(d) || '');
|
||||
if (merged.has(company)) {
|
||||
@@ -293,6 +294,8 @@
|
||||
if (artist > 0) units.push({ label: company, company: true, multiplier: internal / artist });
|
||||
return;
|
||||
}
|
||||
// CODA 整包分出去的部門只算成本,不顯示倍率。
|
||||
if (sharedOut.has(d)) return;
|
||||
const stats = deptStats[d];
|
||||
if (stats && stats.multiplier) units.push({ label: d, company: false, multiplier: stats.multiplier });
|
||||
});
|
||||
@@ -305,14 +308,40 @@
|
||||
return p.costNoUtil !== undefined ? p.costNoUtil : (p.totalCost || 0);
|
||||
}
|
||||
|
||||
// CODA sharing (夢境現實 only): the whole CODA of the "from" departments plus the P staff
|
||||
// of that company who have no department (e.g. the CEO) is split over the "to" departments
|
||||
// CODA sharing: the whole CODA of the "from" departments, plus (noDeptP) the P staff of
|
||||
// that company who have no department (e.g. the CEO), is split over the "to" departments
|
||||
// in proportion to their own CODA. Inside a receiving department it follows the normal
|
||||
// group / person rules.
|
||||
const CODA_SHARE_RULES = [
|
||||
// group / person rules. A "from" department keeps no CODA of its own, so it carries no
|
||||
// 倍率 and no A:P: it is a cost-only unit (see dashboardMultiplierUnits).
|
||||
// 核心參數 codaShareRules 會覆寫這份清單;沒有設定時用下面的預設。
|
||||
const DEFAULT_CODA_SHARE_RULES = [
|
||||
{ company: '夢境現實', from: ['專案與場館營運部'], noDeptP: true, to: ['互動技術部', '互動美術部'] }
|
||||
];
|
||||
|
||||
// 讀核心參數的分配規則。格式不對的整條跳過;已經在 from 的部門不會再被當成 to。
|
||||
function codaShareRules() {
|
||||
const configured = globalParams.codaShareRules;
|
||||
if (!Array.isArray(configured)) return DEFAULT_CODA_SHARE_RULES;
|
||||
const names = (value) => [...new Set((Array.isArray(value) ? value : [])
|
||||
.map(name => String(name == null ? '' : name).trim()).filter(Boolean))];
|
||||
const rules = [];
|
||||
for (const rule of configured) {
|
||||
if (!rule || typeof rule !== 'object' || Array.isArray(rule)) continue;
|
||||
const from = names(rule.from);
|
||||
const to = names(rule.to).filter(name => !from.includes(name));
|
||||
if (!from.length || !to.length) continue;
|
||||
rules.push({ company: String(rule.company || '').trim(), from, to, noDeptP: Boolean(rule.noDeptP) });
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
// 整包把 CODA 分出去的部門:只算成本,不談指標(不顯示倍率、不看 A:P)。
|
||||
function codaSharedOutDepts() {
|
||||
const out = new Set();
|
||||
codaShareRules().forEach(rule => rule.from.forEach(dept => out.add(dept)));
|
||||
return out;
|
||||
}
|
||||
|
||||
// Returns { add: {dept: amount}, out: {dept: amount}, rules: [...] } for the current data.
|
||||
// ownCoda is each department's own P + A CODA before sharing.
|
||||
function codaShares(current, ownCoda) {
|
||||
@@ -320,7 +349,7 @@
|
||||
const out = {};
|
||||
const rules = [];
|
||||
const map = deptCompanyMap(current);
|
||||
CODA_SHARE_RULES.forEach(rule => {
|
||||
codaShareRules().forEach(rule => {
|
||||
const to = rule.to.filter(d => d in ownCoda);
|
||||
if (!to.length) return;
|
||||
const fromDepts = rule.from.filter(d => d in ownCoda);
|
||||
|
||||
Reference in New Issue
Block a user