@lynsoluciones/medusa-docs
Version:
Medusa plugins to generate docs
51 lines (50 loc) • 2.44 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.generateCustomerInformation = void 0;
const hr_1 = require("./hr");
const i18next_1 = require("i18next");
function generateCustomerInformation(doc, y, order) {
(0, hr_1.generateHr)(doc, y + 35);
const customerInformationTop = y + 50;
doc
.fontSize(10)
.font("Bold")
.text(`${(0, i18next_1.t)("packing-slip-bill-to", "Bill to")}:`, 50, customerInformationTop, { align: 'left' })
.font("Regular")
.text(`${order.billing_address.first_name} ${order.billing_address.last_name}`, 50, customerInformationTop + 15, { align: 'left' })
.text(`${order.billing_address.city} ${order.billing_address.postal_code}`, 50, customerInformationTop + 30, { align: 'left' });
const billAddress = order.billing_address.address_1;
const heightOfBillToAddress = doc.heightOfString(billAddress, { width: 150 });
doc.text(billAddress, 50, customerInformationTop + 45, { align: 'left', width: 150 })
.moveDown();
doc
.fontSize(10)
.font("Bold")
.text(`${(0, i18next_1.t)("packing-slip-ship-to", "Ship to")}:`, 50, customerInformationTop, { align: 'right' })
.font("Regular")
.text(`${order.shipping_address.first_name} ${order.shipping_address.last_name}`, 50, customerInformationTop + 15, { align: 'right' })
.text(`${order.shipping_address.city} ${order.shipping_address.postal_code}`, 50, customerInformationTop + 30, { align: 'right' })
.moveDown();
const shipAddress = order.shipping_address.address_1;
const heightOfShipToAddress = doc.heightOfString(shipAddress, { width: 150 });
doc.text(shipAddress, 360, customerInformationTop + 45, { align: 'right', widdth: 150 })
.moveDown();
if (heightOfShipToAddress > heightOfBillToAddress) {
return customerInformationTop + 45 + heightOfShipToAddress;
}
else {
return customerInformationTop + 45 + heightOfBillToAddress;
}
}
exports.generateCustomerInformation = generateCustomerInformation;