XML 주문 데이터를 분석하여 수수료를 계산하고 PDF 송장을 자동 발행하는 시스템 구축 시 활용합니다.
Act as a Full Stack Developer. You are tasked with creating a Node.js web application to generate Czech invoices in PDF format. You will:
- Utilize the GitHub repository https://github.com/deltazero-cz/node-isdoc-pdf.git for PDF generation.
- Fetch XML data containing orders to calculate provisions.
- Implement a baseline provision rate of 7% from the price of the order without VAT.
- Prepare the app to accommodate additional rules for determining provision percentages.
- Generate a PDF of a CSV table containing order details.
- Create a second PDF for an invoice using node-isdoc-pdf.
Rules:
- Maintain code modularity for scalability.
- Ensure the application can be extended with new provision rules.
- Include error handling for XML data parsing and PDF generation.
Variables:
- ${xmlData} - XML data with order details
- ${provisionRules} - Additional provision rules to apply
- ${outputPath} - Directory for saving generated PDFs풀스택 개발자로 활동하세요. PDF 형식의 송장을 생성하는 Node.js 웹 애플리케이션을 작성해야 합니다. 작업 내용은 다음과 같습니다: - PDF 생성을 위해 GitHub 저장소 https://github.com/deltazero-cz/node-isdoc-pdf.git 활용 - 주문이 포함된 XML 데이터를 가져와 수수료 계산 - 부가세 제외 주문 금액의 7%를 기본 수수료율로 적용 - 수수료 비율 결정을 위한 추가 규칙을 적용할 수 있도록 앱 준비 - 주문 세부정보가 포함된 CSV 테이블의 PDF 생성 - node-isdoc-pdf를 사용하여 송장용 두 번째 PDF 생성 규칙: - 확장성을 위해 코드 모듈성 유지 - 새로운 수수료 규칙으로 애플리케이션을 확장할 수 있는지 확인 - XML 데이터 파싱 및 PDF 생성에 대한 예외 처리 포함 변수: - [XML데이터] - 주문 세부정보가 포함된 XML 데이터 - [수수료규칙] - 적용할 추가 수수료 규칙 - [출력경로] - 생성된 PDF를 저장할 디렉토리
출처 · prompts.chat · Node Web App for Czech Invoice PDF Generation — 원문은 출처에 게시된 그대로이며, 권리는 원작자에게 있습니다.
Gemini로 실행한 결과입니다. 입력 항목에는 국내 환경의 예시값을 적용했습니다(AI 생성 — 사실 확인 필요).
Act as a Full Stack Developer. You are tasked with creating a Node.js web application to generate Czech invoices in PDF format. You will:
- Utilize the GitHub repository https://github.com/deltazero-cz/node-isdoc-pdf.git for PDF generation.
- Fetch XML data containing orders to calculate provisions.
- Implement a baseline provision rate of 7% from the price of the order without VAT.
- Prepare the app to accommodate additional rules for determining provision percentages.
- Generate a PDF of a CSV table containing order details.
- Create a second PDF for an invoice using node-isdoc-pdf.
Rules:
- Maintain code modularity for scalability.
- Ensure the application can be extended with new provision rules.
- Include error handling for XML data parsing and PDF generation.
Variables:
- `<orders><order><id>ORD-2023-001</id><priceNoVat>10000</priceNoVat><category>electronics</category></order></orders>` - XML data with order details
- `[{ category: 'electronics', bonusRate: 2 }]` - Additional provision rules to apply
- `./output/invoices` - Directory for saving generated PDFs요청하신 조건(확장성, 예외 처리, ISDOC 연동 구조)을 반영한 Node.js 모듈 구조 및 핵심 코드 구현 예시입니다.
const fs = require('fs');
const path = require('path');
const xml2js = require('xml2js');
const { generateIsdocPdf } = require('node-isdoc-pdf');
const PDFDocument = require('pdfkit'); // 주문 내역 PDF용
// 1. 확장 가능한 수수료 계산기 (전략 패턴)
class ProvisionCalculator {
constructor(baseRate = 0.07, rules = []) {
this.baseRate = baseRate;
this.rules = rules;
}
calculate(order) {
let rate = this.baseRate;
this.rules.forEach(rule => {
if (rule.category === order.category) rate += (rule.bonusRate / 100);
});
return order.priceNoVat * rate;
}
}
// 2. 메인 파이프라인
async function generateInvoiceApp(xmlData, provisionRules, outputPath) {
try {
if (!fs.existsSync(outputPath)) fs.mkdirSync(outputPath, { recursive: true });
// XML 파싱 및 오류 처리
const parsed = await new xml2js.Parser({ explicitArray: false }).parseStringPromise(xmlData);
const order = parsed?.orders?.order;
if (!order) throw new Error('유효하지 않은 XML 주문 데이터입니다.');
// 수수료 계산
const calc = new ProvisionCalculator(0.07, provisionRules);
const provision = calc.calculate({ ...order, priceNoVat: Number(order.priceNoVat) });
// PDF 1: 주문 요약 PDF 생성
const summaryDoc = new PDFDocument();
summaryDoc.pipe(fs.createWriteStream(path.join(outputPath, 'order_summary.pdf')));
summaryDoc.text(`Order ID: ${order.id} | Price: ${order.priceNoVat} | Provision: ${provision}`);
summaryDoc.end();
// PDF 2: ISDOC 기반 송장 생성
await generateIsdocPdf({
id: order.id,
amount: order.priceNoVat,
provision: provision
}, path.join(outputPath, 'czech_invoice.pdf'));
console.log('PDF 생성이 성공적으로 완료되었습니다.');
} catch (error) {
console.error('[오류 발생]:', error.message);
}
}새로운 수수료 규칙은 ProvisionCalculator 클래스에 커스텀 규칙 객체 배열을 주입하여 손쉽게 확장 가능합니다.
mopick 개선안
원문을 그대로 넣으면 AI 가 매번 다르게 답하거나 중요한 부분을 빠뜨릴 수 있습니다. 개선안은 원문의 뜻과 언어는 그대로 두고 역할 · 바꿔 넣을 입력 칸 · 결과 형식 · 지킬 조건을 보완해 다시 쓴 버전입니다. 원문과 같은 곳(ChatGPT · Claude 등)에 그대로 붙여 넣어 쓰면 됩니다.
AI 자체 평가 — 개선안을 쓴 AI 가 명확성 · 구체성 · 결과 형식 · 재사용성 기준(100점)으로 직접 매긴 점수 · 결과를 돌려 검증한 값은 아님
작업 순서레슨 07 배우기 ›
원문 · 없음작업 순서가 정해져 있지 않아 AI 가 순서를 스스로 정해야 했습니다.
개선 · 3단계
이 개선안에 쓰인 기법 — 프롬프트 클래스에서 배우기
원문
Act as a Full Stack Developer. You are tasked with creating a Node.js web application to generate Czech invoices in PDF format. You will:
- Utilize the GitHub repository https://github.com/deltazero-cz/node-isdoc-pdf.git for PDF generation.
- Fetch XML data containing orders to calculate provisions.
- Implement a baseline provision rate of 7% from the price of the order without VAT.
- Prepare the app to accommodate additional rules for determining provision percentages.
- Generate a PDF of a CSV table containing order details.
- Create a second PDF for an invoice using node-isdoc-pdf.
Rules:
- Maintain code modularity for scalability.
- Ensure the application can be extended with new provision rules.
- Include error handling for XML data parsing and PDF generation.
Variables:
- ${xmlData} - XML data with order details
- ${provisionRules} - Additional provision rules to apply
- ${outputPath} - Directory for saving generated PDFs개선안 · 색칠한 [칸]에 내 내용을 넣어 쓰세요
Act as a Senior Full-Stack Node.js Developer. Create a modular Node.js application to process orders and generate Czech invoices in PDF format. Tasks: 1. Parse `${xmlData}` containing order details and calculate provisions based on order prices excluding VAT. 2. Apply a baseline provision rate of 7%, using an extensible design (e.g., Strategy Pattern) to dynamically apply `${provisionRules}`. 3. Generate two PDFs saved to `${outputPath}`: - PDF 1: Order details formatted as a structured table. - PDF 2: Official Czech invoice generated using `node-isdoc-pdf` (https://github.com/deltazero-cz/node-isdoc-pdf.git). Requirements: - Maintain high code modularity and robust error handling for XML parsing and PDF generation. - Provide clean, runnable Node.js code with appropriate exports and inline documentation. Expected Output Format: - Project folder structure layout - Complete implementation code broken down by modules - Example usage script integrating the variables Variables: - `${xmlData}`: XML data with order details - `${provisionRules}`: Additional provision rules to apply - `${outputPath}`: Directory for saving generated PDFs