UNPKG

@rsc-labs/medusa-store-analytics

Version:
54 lines (53 loc) 2.02 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 common_1 = require("./common"); const hr_1 = require("./hr"); class PdfCustomersTemplate { static generateTableRow(doc, date, customers) { const startY = doc.y; doc .fontSize(10) .text(date, 70, startY, { align: "left" }) .text(customers, 320, startY, { width: 90, align: "right" }); } static generateTable(doc, customersHistoryResult) { doc.font("Helvetica-Bold"); this.generateTableRow(doc, "Date", "New customers count"); (0, common_1.moveDown)(doc); (0, hr_1.generateHr)(doc); (0, common_1.moveDown)(doc); doc.font("Helvetica"); let totalCurrent = 0; for (const currentCustomersHistoryResult of customersHistoryResult.current) { totalCurrent += Number(currentCustomersHistoryResult.customerCount); this.generateTableRow(doc, new Date(currentCustomersHistoryResult.date).toLocaleDateString(), currentCustomersHistoryResult.customerCount); (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('New customers', 70, doc.y, { align: "left" }); doc .fontSize(12); (0, common_1.moveDown)(doc); } } exports.default = PdfCustomersTemplate;