Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

sfi-2225 subscribe to statement data updates #10

Merged
merged 15 commits into from
Aug 30, 2022

Conversation

simonnineteen90
Copy link
Contributor

Copy link
Member

@johnwatson484 johnwatson484 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs update to provision.azure.yaml file to include the new queue

@marctemp marctemp marked this pull request as ready for review August 29, 2022 13:31
const getCalculationBySbi = async (sbi, transaction) => {
return db.organisation.findOne({
transaction,
lock: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the value in locking the rows if we're not going to update the locked record?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, naively gust copied from other db retrievals, inserts, etc -- will remove as I assume this is only used for data entry

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you can lock it if you're going to update that record. If you're not going to update, no value in the lock. Because you're running in a transaction shouldn't cause any issues but it adds no value here.

const getCompletedPaymentRequestByInvoiceNumber = async (invoiceNumber, transaction) => {
return db.paymentRequest.findOne({
transaction,
lock: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, any reason for lock?

console.info(`Duplicate calculation received, skipping ${existingCalculation.sbi}`)
await transaction.rollback()
} else {
await savePlaceholderOrganisation({ sbi: calculation.sbi }, calculation.sbi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also include the FRN too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calculation data does not have frn

@@ -0,0 +1,13 @@
const db = require('../../data')

const getCalculationBySbi = async (sbi, transaction) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called get calculation but returns an organisation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Fixing going to get by calculationReference to clear up comment below too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, GitHub dnt do gifs... noted

const transaction = await db.sequelize.transaction()

try {
const existingCalculation = await getCalculationBySbi(calculation.sbi, transaction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An existing calculation should be calculationRef not SBI. One SBI will have multiple legitimate calculations if they've had a post payment adjustment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadda comment next to this asking tht exact ques on which field to use

const db = require('../../data')

const savePlaceholderOrganisation = async (organisation, sbi, transaction) => {
await db.organisation.findOrCreate({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you're doing this by PK you could use upsert rather than findOrCreate. However, I don't actually know if there's any actual benefit to doing that so more just for info.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@johnwatson484 johnwatson484 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marctemp marctemp merged commit ebe9fb9 into main Aug 30, 2022
@marctemp marctemp deleted the sfi-2225-subscribe-to-statement-data-updates branch August 30, 2022 10:33
@marctemp marctemp restored the sfi-2225-subscribe-to-statement-data-updates branch August 30, 2022 10:34
johnwatson484 added a commit that referenced this pull request Aug 30, 2022
johnwatson484 added a commit that referenced this pull request Aug 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants