Skip to content

Instantly share code, notes, and snippets.

@Ehbraheem
Created December 31, 2019 11:01
Show Gist options
  • Save Ehbraheem/e1b154aeb577d0435b46df0d1ea1316e to your computer and use it in GitHub Desktop.
Save Ehbraheem/e1b154aeb577d0435b46df0d1ea1316e to your computer and use it in GitHub Desktop.
Elephant /invoice request spec
// primary-care-api-billing/src/persistence/mongoose/Invoice/queries.js
// Set invoice status to BALANCED if paid
if( invoiceDoc.status === 'ISSUED' && invoiceDoc.balance.paid) {
invoiceDoc.status = 'BALANCED';
}
// Save and return
console.trace(JSON.stringify(await invoiceDoc.save())) // eslint-disable-line no-console
return invoiceDoc
}
Bolatans-MacBook-Pro:primary-care-api-billing ehbraheem$ yarn test -t "create"
# Irrelivant test output
RUNS integration/invoices/invoices.test.js
Test Suites: 7 skipped, 5 passed, 5 of 13 total
Tests: 115 skipped, 10 passed, 125 total
PASS integration/invoices/invoices.test.js (5.529s)
● Console
console.info node_modules/@ctt/crud-api/lib/server.js:157
Server setup completed...
console.error console.js:274
Trace: {"_id":"5e0b26ba1981f8bb5d4751de","subject":"482e3860-54bf-49d6-891d-acc6c0cc1756","issuer":{"_id":"5e0b26ba1981f8bb5d4751df","clinic":"dfb578c3-990c-405c-ade7-b365b5a209bf","unit":"0a7908d8-ad01-4012-9e6a-a6306cd6a1f9","reporter":"c286b564-4e55-4316-91cc-428ade576593"},"transactions":[],"events":[{"quantity":1,"_id":"5e0b26ba1981f8bb5d4751e0","revenueDepartment":"Inpatient","price":{"overridden":false,"value":100,"currency":"KSH","recorder":"aaa7fd57-5d6b-4563-b60e-6c9f78f19579"},"eventPrice":{"_id":"5e0b26ba1981f8bb5d4751e1","uuid":"2bfadc23-335e-40b6-a037-5f14454f0dfc","organisation":"5984579e-2a71-47e9-baa0-98db5d20a514","service":"d69021dc-266e-4b44-be2a-0f8d82453bc9","currency":"KSH","code":"0111.003","name":"Bed Charges Amenity","amount":100,"category":"Inpatient","unitOfMeasure":"Serve"},"prescriptionItem":{},"delivered":{"status":false},"insuranceScheme":"","invoice":"c72fba53-7d1d-4f3c-a670-46db7687c1c7","uuid":"fb8f8c57-19b9-4da3-9fd8-585438d6f07b","_ref":{"_$ref":"events","_$db":"primarycare-billing","_$id":"fb8f8c57-19b9-4da3-9fd8-585438d6f07b"}}],"status":"ISSUED","meta":{"active":true,"created":"2019-12-31T12:45:14.000Z"},"uuid":"c72fba53-7d1d-4f3c-a670-46db7687c1c7","currency":"KSH","total":100,"balance":{"paid":false,"_id":"5e0b26ba1981f8bb5d4751e4","patient":0,"insurer":0,"total":100},"__v":0}
at createWithEvents (/Users/ehbraheem/Documents/projects/elephant/primary-care-pilot/packages/primary-care-api-billing/src/persistence/mongoose/Invoice/queries.js:94:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
console.error console.js:274
Trace: {"_id":"5e0b26ba1981f8bb5d4751e8","subject":"482e3860-54bf-49d6-891d-acc6c0cc1756","issuer":{"_id":"5e0b26ba1981f8bb5d4751e9","clinic":"dfb578c3-990c-405c-ade7-b365b5a209bf","unit":"0a7908d8-ad01-4012-9e6a-a6306cd6a1f9","reporter":"c286b564-4e55-4316-91cc-428ade576593"},"transactions":[{"_id":"5e0b26ba1981f8bb5d4751ee","type":"PAYMENT","method":"CASH","bankedBy":"some-geeza","note":"They paid some of it","price":{"_id":"5e0b26ba1981f8bb5d4751ef","currency":"KSH","value":50,"valueInPence":5000},"invoice":"4f9f15c7-f37d-4972-9e0a-4531f64e4568","uuid":"56385520-3799-43f7-a826-e0e49f29b158","_ref":{"_$ref":"transactions","_$db":"primarycare-billing","_$id":"56385520-3799-43f7-a826-e0e49f29b158"}}],"events":[{"quantity":1,"_id":"5e0b26ba1981f8bb5d4751ea","revenueDepartment":"Inpatient","price":{"overridden":false,"value":100,"currency":"KSH","recorder":"aaa7fd57-5d6b-4563-b60e-6c9f78f19579"},"eventPrice":{"_id":"5e0b26ba1981f8bb5d4751eb","uuid":"2bfadc23-335e-40b6-a037-5f14454f0dfc","organisation":"5984579e-2a71-47e9-baa0-98db5d20a514","service":"d69021dc-266e-4b44-be2a-0f8d82453bc9","currency":"KSH","code":"0111.003","name":"Bed Charges Amenity","amount":100,"category":"Inpatient","unitOfMeasure":"Serve"},"prescriptionItem":{},"delivered":{"status":false},"insuranceScheme":"","invoice":"4f9f15c7-f37d-4972-9e0a-4531f64e4568","uuid":"5dae64cc-f0af-404d-9f61-65587f5fd207","_ref":{"_$ref":"events","_$db":"primarycare-billing","_$id":"5dae64cc-f0af-404d-9f61-65587f5fd207"}}],"status":"ISSUED","meta":{"active":true,"created":"2019-12-31T12:45:14.000Z"},"uuid":"4f9f15c7-f37d-4972-9e0a-4531f64e4568","currency":"KSH","total":100,"balance":{"paid":false,"_id":"5e0b26ba1981f8bb5d4751f2","patient":50,"insurer":0,"total":50},"__v":0}
at createWithEvents (/Users/ehbraheem/Documents/projects/elephant/primary-care-pilot/packages/primary-care-api-billing/src/persistence/mongoose/Invoice/queries.js:94:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
console.error console.js:274
Trace: {"_id":"5e0b26ba1981f8bb5d4751f7","subject":"482e3860-54bf-49d6-891d-acc6c0cc1756","issuer":{"_id":"5e0b26ba1981f8bb5d4751f8","clinic":"dfb578c3-990c-405c-ade7-b365b5a209bf","unit":"0a7908d8-ad01-4012-9e6a-a6306cd6a1f9","reporter":"c286b564-4e55-4316-91cc-428ade576593"},"transactions":[{"_id":"5e0b26ba1981f8bb5d4751fd","type":"PAYMENT","method":"CASH","bankedBy":"54aa9216-e9da-43fb-bd13-b76898170053","note":"They paid some of it","price":{"_id":"5e0b26ba1981f8bb5d4751fe","currency":"KSH","value":50,"valueInPence":5000},"invoice":"8e6da596-8a34-4b31-ac31-c1543a7b7d25","uuid":"896900b0-9862-4819-8c3d-cac581d69f7e","_ref":{"_$ref":"transactions","_$db":"primarycare-billing","_$id":"896900b0-9862-4819-8c3d-cac581d69f7e"}},{"_id":"5e0b26ba1981f8bb5d4751ff","type":"PAYMENT","method":"CASH","bankedBy":"54aa9216-e9da-43fb-bd13-b76898170053","note":"They paid the rest of it","price":{"_id":"5e0b26ba1981f8bb5d475200","currency":"KSH","value":50,"valueInPence":5000},"invoice":"8e6da596-8a34-4b31-ac31-c1543a7b7d25","uuid":"95321eed-2aa2-4764-8d94-91fa01b7e8a1","_ref":{"_$ref":"transactions","_$db":"primarycare-billing","_$id":"95321eed-2aa2-4764-8d94-91fa01b7e8a1"}}],"events":[{"quantity":1,"_id":"5e0b26ba1981f8bb5d4751f9","revenueDepartment":"Inpatient","price":{"overridden":false,"value":100,"currency":"KSH","recorder":"aaa7fd57-5d6b-4563-b60e-6c9f78f19579"},"eventPrice":{"_id":"5e0b26ba1981f8bb5d4751fa","uuid":"2bfadc23-335e-40b6-a037-5f14454f0dfc","organisation":"5984579e-2a71-47e9-baa0-98db5d20a514","service":"d69021dc-266e-4b44-be2a-0f8d82453bc9","currency":"KSH","code":"0111.003","name":"Bed Charges Amenity","amount":100,"category":"Inpatient","unitOfMeasure":"Serve"},"prescriptionItem":{},"delivered":{"status":false},"insuranceScheme":"","invoice":"8e6da596-8a34-4b31-ac31-c1543a7b7d25","uuid":"0d5f2ee2-8cbb-4aa0-996f-634d601520c4","_ref":{"_$ref":"events","_$db":"primarycare-billing","_$id":"0d5f2ee2-8cbb-4aa0-996f-634d601520c4"}}],"status":"BALANCED","meta":{"active":true,"created":"2019-12-31T12:45:14.000Z"},"uuid":"8e6da596-8a34-4b31-ac31-c1543a7b7d25","currency":"KSH","total":100,"balance":{"paid":true,"_id":"5e0b26ba1981f8bb5d475205","patient":100,"insurer":0,"total":0},"__v":0}
at createWithEvents (/Users/ehbraheem/Documents/projects/elephant/primary-care-pilot/packages/primary-care-api-billing/src/persistence/mongoose/Invoice/queries.js:94:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
Test Suites: 7 skipped, 6 passed, 6 of 13 total
Tests: 124 skipped, 13 passed, 137 total
Snapshots: 0 total
Time: 7.091s
Ran all test suites with tests matching "create".
✨ Done in 10.04s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment