UNPKG

@rsc-labs/medusa-store-analytics

Version:
54 lines (53 loc) 1.97 kB
"use strict"; /* * Copyright 2024 RSC-Labs, https://rsoftcon.com/ * * MIT License * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); const hr_1 = require("./hr"); const common_1 = require("./common"); class PdfOrdersTemplate { static generateTableRow(doc, date, orders) { const startY = doc.y; doc .fontSize(10) .text(date, 70, startY, { align: "left" }) .text(orders, 320, startY, { width: 90, align: "right" }); } static generateTable(doc, ordersHistoryResult) { doc.font("Helvetica-Bold"); this.generateTableRow(doc, "Date", "Orders count"); (0, common_1.moveDown)(doc); (0, hr_1.generateHr)(doc); (0, common_1.moveDown)(doc); doc.font("Helvetica"); let totalCurrent = 0; for (const currentOrdersHistoryResult of ordersHistoryResult.current) { totalCurrent += Number(currentOrdersHistoryResult.orderCount); this.generateTableRow(doc, new Date(currentOrdersHistoryResult.date).toLocaleDateString(), currentOrdersHistoryResult.orderCount); (0, common_1.moveDown)(doc); (0, hr_1.generateHr)(doc); (0, common_1.moveDown)(doc); } this.generateTableRow(doc, "Total", totalCurrent); (0, common_1.moveDown)(doc); } static generateHeader(doc) { doc .fontSize(18); (0, common_1.moveDown)(doc); doc .text('Orders', 70, doc.y, { align: "left" }); doc .fontSize(12); (0, common_1.moveDown)(doc); } } exports.default = PdfOrdersTemplate;