Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Handle error handler for InvalidPurchaseOrderNumberError
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenedith committed Nov 11, 2015
1 parent aa24916 commit 861b812
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/client/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ var ServiceUnavailableError = receiptsModel.error.ServiceUnavailableError;
var AlreadyExistsError = receiptsModel.error.AlreadyExistsError;
var UnknownValidateError = receiptsModel.error.UnknownValidateError;
var InvalidPointOfSaleError = receiptsModel.error.InvalidPointOfSaleError;
var InvalidPurchaseOrderNumberError = receiptsModel.error.InvalidPurchaseOrderNumberError;
var InvalidDateError = receiptsModel.error.InvalidDateError;
var InvalidAmountError = receiptsModel.error.InvalidAmountError;
var InvalidTaxRegistrationNumberError = receiptsModel.error.InvalidTaxRegistrationNumberError;
var mainClient = require('./main');
var moment = require('moment-timezone');
var receiptIdRegex = /drukuj\/(.+)$/;
var receiptIdRegex = /drukuj\/(.+)\/.*$/;

var buildForm = function buildForm(ticketRequest, captcha) {
logger.debug('buildForm');
Expand Down Expand Up @@ -191,6 +192,10 @@ var buildResponse = function buildResponse(body, callback) {
return callback(new InvalidPointOfSaleError('Invalid pointOfSale number', json.nr_kasy.join(','), 'pointOfSale'));
}

if (json.hasOwnProperty('nr_wydruku')) {
return callback(new InvalidPurchaseOrderNumberError('Invalid purchaseOrderNumber number', json.nr_wydruku.join(','), 'purchaseOrderNumber'));
}

if (json.hasOwnProperty('miesiac')) {
return callback(new InvalidDateError('Invalid date', json.miesiac.join(','), 'date'));
}
Expand All @@ -203,9 +208,8 @@ var buildResponse = function buildResponse(body, callback) {
if (json.nip.length > 1) {
return callback(new InvalidTaxRegistrationNumberError('Invalid taxRegistrationNumber number', json.nip[1], 'taxRegistrationNumber'));
}
else {
return callback(new InvalidTaxRegistrationNumberError('Invalid taxRegistrationNumber number', json.nip[0], 'taxRegistrationNumber'));
}

return callback(new InvalidTaxRegistrationNumberError('Invalid taxRegistrationNumber number', json.nip[0], 'taxRegistrationNumber'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"async": "^1.5.0",
"cheerio": "^0.19.0",
"moment-timezone": "^0.4.1",
"receipts-model": "0.5.5",
"receipts-model": "0.5.6",
"request": "^2.65.0",
"winston": "^2.0.0",
"winston-loggly": "^1.2.0"
Expand Down

0 comments on commit 861b812

Please sign in to comment.