Skip to content

Commit

Permalink
fix(vouchers): ensure that entity is picked up
Browse files Browse the repository at this point in the history
This commit ensures that the entity is formatted correctly in both the
SQL read request and the voucher create() call from the client.
  • Loading branch information
jniles committed Feb 12, 2024
1 parent d959002 commit a5c7e51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="ui-grid-cell-contents">
<bh-entity-typeahead
entity-uuid="row.entity.entity_uuid"
on-select-entity="grid.appScope.onSelectEntity(row, entity)"
on-select-callback="grid.appScope.onSelectEntity(row, entity)"
disabled="!row.entity._initialized">
</bh-entity-typeahead>
</div>
14 changes: 1 addition & 13 deletions client/src/modules/vouchers/vouchers.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,7 @@ function VoucherService(
const v = angular.copy(voucher);

// format items for posting, removing validation keys and unlinking old objects
v.items = v.items.map(item => {
const escapedItem = stripInternalObjectKeys(item);

if (escapedItem.entity) {
escapedItem.entity_uuid = escapedItem.entity.uuid;
}

if (escapedItem.document) {
escapedItem.document_uuid = escapedItem.document.uuid;
}

return escapedItem;
});
v.items = v.items.map(stripInternalObjectKeys);

// @FIXME(sfount) this uses javascript maths without using something like the
// BigNumber library. Our general default is to do maths in MySQL
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/finance/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ exports.lookupFinancialEntityByUuid = (req, res, next) => {
`;

const combinedSQL = `
SELECT uuid, text, hrLabel FROM (
SELECT BUID(uuid) as uuid, text, hrLabel FROM (
${debtorSQL} UNION ${creditorSQL}
)z ORDER BY text LIMITT 1;
)z ORDER BY text LIMIT 1;
`;

db.one(combinedSQL, [uuid, uuid])
Expand Down Expand Up @@ -103,7 +103,7 @@ exports.lookupFinancialEntity = (req, res, next) => {
const parameters = filters.parameters();

const query = `
SELECT uuid, text, hrLabel FROM (
SELECT BUID(uuid) as uuid, text, hrLabel FROM (
${debtorQuery} UNION ${creditorQuery}
)z ORDER BY text LIMIT ${limit};
`;
Expand Down

0 comments on commit a5c7e51

Please sign in to comment.