feat(est): connect original quantity sheets
This commit is contained in:
@@ -15,15 +15,16 @@ const EstText = (() => {
|
||||
function expression(text) {
|
||||
return clean(
|
||||
String(text).replace(
|
||||
/\x0e[^\x0e]*\x0e|\x13[^\x13]*\x13|\x15[^\x15]*\x15|\{[^}]*\}|\([^()]*[가-힣][^()]*\)/g,
|
||||
/\x0e[^\x0e]*\x0e|\x13[^\x13]*\x13|\x15[^\x15]*\x15|\{[^}]*\}|\([가-힣][^()]*\)/g,
|
||||
"",
|
||||
),
|
||||
)
|
||||
.replace(
|
||||
/(\d)\s*(?:공\/?㎥|공|면|경간|개월|월|인|㎥|㎢|㎡|hr|sec|min|km|ton|kg|㎏|㎞|ℓ|회|개소|개|대|분|초|본|장|매|병|조|식|일|시간|원|포|동|μ|EA|mm|cm|m|g|L)(?:\/(?:개소|개|대|본|인|분|포|\$|hr|일|㎥|㎡|m|a))?/gi,
|
||||
/(\d)\s*(?:공\/?㎥|공|단|면|경간|개월|월|인|㎥|㎢|㎡|hr|sec|min|km|ton|kg|㎏|㎞|ℓ|회|개소|개|대|분|초|본|장|매|병|조|식|일|시간|원|포|동|μ|EA|mm|cm|m|g|L)(?:\/(?:개소|개|대|본|인|분|포|\$|hr|일|㎥|㎡|m|a))?/gi,
|
||||
"$1",
|
||||
)
|
||||
.replace(/(?<=\d)\s*\/(?:일|㎥|㎡)(?=\s|$)/g, "")
|
||||
.replace(/(?<=\))\s*(?:개|인|본|면|단)(?:\/(?:㎡|㎥|hr))?/g, "")
|
||||
.replace(/[①-⑳]/g, "")
|
||||
.replace(/=\s*$/, "");
|
||||
}
|
||||
@@ -159,15 +160,18 @@ const EstText = (() => {
|
||||
body = body.split("=")[0];
|
||||
calculated = EstExpression.evaluate(expression(body), (key) => variables[key]);
|
||||
}
|
||||
const assignmentText = text.replace(/\{[^}]*\}/g, (value) => " ".repeat(value.length));
|
||||
const assignmentText = text.replace(
|
||||
/\{[^}]*\}|\x0e[^\x0e]*\x0e|\x13[^\x13]*\x13|\x15[^\x15]*\x15/g,
|
||||
(value) => " ".repeat(value.length),
|
||||
);
|
||||
const assignments =
|
||||
sc < 0
|
||||
? []
|
||||
: [
|
||||
...assignmentText.matchAll(
|
||||
/(?:^| {2,}|[,,]\s*|(?<=[가-힣])\s+|[::]\s*)([A-Za-z][A-Za-z0-9]*)\s*=/g,
|
||||
/(?:^\s*| {2,}|[,,]\s*|(?<=[가-힣])\s+|[::]\s*)([A-Za-z][A-Za-z0-9]*)\s*=/g,
|
||||
),
|
||||
].filter((a) => !text.includes("\x0e") || a.index < text.indexOf("\x0e"));
|
||||
];
|
||||
for (let j = 0; j < assignments.length; j++) {
|
||||
const assignment = assignments[j],
|
||||
end = assignments[j + 1]?.index ?? text.length;
|
||||
@@ -241,6 +245,7 @@ const EstText = (() => {
|
||||
for (let part = 1; part < results.length; part++) {
|
||||
const previous = results[part - 1],
|
||||
next = results[part];
|
||||
const format = row.ResultFormats?.[part];
|
||||
const operation = expression(
|
||||
text.slice(previous.index + previous[0].length, next.index),
|
||||
).trim();
|
||||
@@ -251,8 +256,8 @@ const EstText = (() => {
|
||||
expression(`${calculated}${operation}`),
|
||||
(key) => variables[key],
|
||||
),
|
||||
digits,
|
||||
method,
|
||||
format?.digits ?? digits,
|
||||
format?.method ?? method,
|
||||
);
|
||||
assignmentName = assignedNames.get(next.index) || assignmentName;
|
||||
if (assignmentName) variables[assignmentName] = calculated;
|
||||
|
||||
Reference in New Issue
Block a user