-
Notifications
You must be signed in to change notification settings - Fork 24
Create User Script for boranga users #1162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| #print (invoice_obj.amount) | ||
| #print (oracle_invoice_total) | ||
| invoice_obj = Invoice.objects.get(reference=oi.reference) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unhandled Invoice.DoesNotExist exception at line 76 crashes audit command if OracleParserInvoice lacks matching Invoice.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The Invoice.objects.get(reference=oi.reference) call at line 76 lacks error handling. If an OracleParserInvoice record exists without a corresponding Invoice (e.g., due to deletion or data corruption), a Invoice.DoesNotExist exception will be raised, causing the entire audit command to crash. This prevents the script from completing its intended function of identifying and reporting discrepancies.
💡 Suggested Fix
Wrap the Invoice.objects.get() call in a try-except Invoice.DoesNotExist block. If the invoice is not found, log the discrepancy and continue processing without crashing.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
ledger/payments/bpoint/management/commands/invoice_oracle_audit_report_segregated.py#L76
Potential issue: The `Invoice.objects.get(reference=oi.reference)` call at line 76 lacks
error handling. If an `OracleParserInvoice` record exists without a corresponding
`Invoice` (e.g., due to deletion or data corruption), a `Invoice.DoesNotExist` exception
will be raised, causing the entire audit command to crash. This prevents the script from
completing its intended function of identifying and reporting discrepancies.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4196900
| bpoint_payment = BpointTransaction.objects.filter(crn1=oi.reference) | ||
| if bpoint_payment.count() > 0: | ||
| if bpoint_payment[0].action == 'refund': | ||
| bpoint_payment_total = bpoint_payment[0].amount - bpoint_payment[0].amount - bpoint_payment[0].amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Incorrect refund calculation amount - amount - amount results in -amount, causing false discrepancies in audit comparisons.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The calculation for bpoint_payment_total for refund transactions at line 80 uses the formula amount - amount - amount, which mathematically evaluates to -amount. This incorrect negation causes false discrepancies in the audit report because the oracle_invoice_in_decimal and invoice_obj.amount totals, used for comparison, are not similarly negated, undermining the report's reliability.
💡 Suggested Fix
For refund actions, bpoint_payment_total should be calculated by subtracting the amount from a running total, similar to the pattern in bpoint_ledger_payment_audit_report.py.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
ledger/payments/bpoint/management/commands/invoice_oracle_audit_report_segregated.py#L80
Potential issue: The calculation for `bpoint_payment_total` for refund transactions at
line 80 uses the formula `amount - amount - amount`, which mathematically evaluates to
`-amount`. This incorrect negation causes false discrepancies in the audit report
because the `oracle_invoice_in_decimal` and `invoice_obj.amount` totals, used for
comparison, are not similarly negated, undermining the report's reliability.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4196900
No description provided.