Skip to content

Commit

Permalink
optional address
Browse files Browse the repository at this point in the history
  • Loading branch information
ardean committed Aug 9, 2016
1 parent 7b6b6e2 commit 63f7c23
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
13 changes: 5 additions & 8 deletions dist/pdf-invoice-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ return /******/ (function(modules) { // webpackBootstrap
};

function getTemplate(options) {
var organizationAddress = options.organizationAddress || {};
var organizationAddress = options.organizationAddress || null;
var billingAddress = options.billingAddress || {};
var date = options.date || (0, _moment2.default)();
var dueDate = options.dueDate || (0, _moment2.default)().add(10, "days");
Expand Down Expand Up @@ -193,15 +193,12 @@ return /******/ (function(modules) { // webpackBootstrap
}]);
}

var organizationAddressText = organizationAddress ? getFlatAddressText(organizationAddress) : "";

var doc = {
defaultStyle: defaultStyle,
content: [{
text: returnAddressText({
name: organizationAddress.name,
street: organizationAddress.street,
postCode: organizationAddress.postCode,
city: organizationAddress.city
}),
text: organizationAddressText,
margin: [0, 100, 0, 0],
fontSize: 8,
color: "gray"
Expand Down Expand Up @@ -316,7 +313,7 @@ return /******/ (function(modules) { // webpackBootstrap
return doc;
}

function returnAddressText(address) {
function getFlatAddressText(address) {
var location = [address.postCode, address.city].join(" ").trim();

return [address.name, address.street, location].filter(function (value) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pdf-invoice-simple",
"description": "A simple pdf invoice template",
"version": "0.3.0",
"version": "0.3.1",
"author": "Orbin",
"keywords": [
"pdf",
Expand Down
13 changes: 5 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default (options) => {
};

function getTemplate(options) {
const organizationAddress = options.organizationAddress || {};
const organizationAddress = options.organizationAddress || null;
const billingAddress = options.billingAddress || {};
const date = options.date || moment();
const dueDate = options.dueDate || moment().add(10, "days");
Expand Down Expand Up @@ -135,15 +135,12 @@ function getTemplate(options) {
]);
}

const organizationAddressText = organizationAddress ? getFlatAddressText(organizationAddress) : "";

const doc = {
defaultStyle: defaultStyle,
content: [{
text: returnAddressText({
name: organizationAddress.name,
street: organizationAddress.street,
postCode: organizationAddress.postCode,
city: organizationAddress.city
}),
text: organizationAddressText,
margin: [0, 100, 0, 0],
fontSize: 8,
color: "gray"
Expand Down Expand Up @@ -274,7 +271,7 @@ function getTemplate(options) {
return doc;
}

function returnAddressText(address) {
function getFlatAddressText(address) {
const location = [address.postCode, address.city].join(" ").trim();

return [address.name, address.street, location].filter((value) => {
Expand Down

0 comments on commit 63f7c23

Please sign in to comment.