UNPKG

@rsc-labs/medusa-store-analytics

Version:
55 lines (54 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 PdfProductsTemplate { static generateTableRow(doc, product, variant, sum) { const startY = doc.y; doc .fontSize(10) .text(product, 70, startY, { align: "left" }) .text(variant, 200, startY, { align: "left" }) .text(sum, 320, startY, { width: 90, align: "right" }); } static generateTable(doc, variantsCountPopularityResult) { doc.font("Helvetica-Bold"); this.generateTableRow(doc, "Product", "Variant", "Sum"); (0, common_1.moveDown)(doc); (0, hr_1.generateHr)(doc); (0, common_1.moveDown)(doc); doc.font("Helvetica"); let totalCurrent = 0; for (const currentResults of variantsCountPopularityResult.current) { totalCurrent += Number(currentResults.sum); this.generateTableRow(doc, currentResults.productTitle, currentResults.variantTitle, currentResults.sum); (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('Top products', 70, doc.y, { align: "left" }); doc .fontSize(12); (0, common_1.moveDown)(doc); } } exports.default = PdfProductsTemplate;