@lynsoluciones/medusa-docs
Version:
Medusa plugins to generate docs
45 lines (44 loc) • 1.82 kB
JavaScript
;
/*
*
*
* 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 });
exports.generateItemsTable = void 0;
const hr_1 = require("./hr");
const i18next_1 = require("i18next");
function generateTableRow(doc, y, item, description, quantity) {
doc
.fontSize(10)
.text(item, 50, y)
.text(description, 200, y)
.text(quantity, 0, y, { align: "right" });
}
function generateItemsTable(doc, y, order, items) {
let i;
const invoiceTableTop = y + 35;
let totalQuantity = 0;
doc.font("Bold");
generateTableRow(doc, invoiceTableTop, (0, i18next_1.t)("packing-slip-table-header-item", "Item"), (0, i18next_1.t)("packing-slip-table-header-description", "Description"), (0, i18next_1.t)("packing-slip-table-header-quantity", "Quantity"));
(0, hr_1.generateHr)(doc, invoiceTableTop + 20);
doc.font("Regular");
for (i = 0; i < items.length; i++) {
const item = items[i];
totalQuantity += item.quantity;
const position = invoiceTableTop + (i + 1) * 30;
generateTableRow(doc, position, item.title, item.description, item.quantity);
(0, hr_1.generateHr)(doc, position + 20);
}
const totalQuantityPosition = invoiceTableTop + (i + 1) * 30;
doc.font("Bold");
generateTableRow(doc, totalQuantityPosition, "", (0, i18next_1.t)("packing-slip-table-header-total", "Total"), totalQuantity);
doc.font("Regular");
}
exports.generateItemsTable = generateItemsTable;