Skip to content

Make discounts non-negative entry#91

Open
Aryan20 wants to merge 1 commit intodevelopfrom
non_negative_fix
Open

Make discounts non-negative entry#91
Aryan20 wants to merge 1 commit intodevelopfrom
non_negative_fix

Conversation

@Aryan20
Copy link
Contributor

@Aryan20 Aryan20 commented Mar 3, 2026

Description

This pull request updates the validation rules for several fields in the Affiliate Referral Fee Rule and Coupon Batch doctypes to ensure that percentage and discount values cannot be negative. This helps prevent invalid data entry and enforces more robust data integrity.

Validation improvements for non-negative values:

  • Added the non_negative constraint to the first_referral_rate and subsequent_referral_rate percent fields in affiliate_referral_fee_rule.json to prevent negative referral rates.
  • Added the non_negative constraint to the discount and recurring_discount float fields in coupon_batch.json to ensure discounts cannot be negative. [1] [2]

Relevant Technical Choices

Testing Instructions

Additional Information:

Screenshot/Screencast

Checklist

  • I have carefully reviewed the code before submitting it for review.
  • This code is adequately covered by unit tests to validate its functionality.
  • I have conducted thorough testing to ensure it functions as intended.
  • A member of the QA team has reviewed and tested this PR (To be checked by QA or code reviewer)

Fixes #

@Aryan20 Aryan20 requested review from Copilot and niraj2477 March 3, 2026 10:39
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances data integrity by implementing non-negative validation for critical percentage and discount fields across the Affiliate Referral Fee Rule and Coupon Batch doctypes. This ensures that all entered referral rates and discount amounts are positive or zero, preventing erroneous data and improving the reliability of financial calculations.

Highlights

  • Affiliate Referral Fee Rule Validation: The first_referral_rate and subsequent_referral_rate fields in affiliate_referral_fee_rule.json now include a non_negative constraint to prevent negative referral percentages.
  • Coupon Batch Discount Validation: The discount and recurring_discount fields in coupon_batch.json have been updated with a non_negative constraint to ensure that discount values cannot be negative.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • frappe_affiliate/frappe_affiliate/doctype/affiliate_referral_fee_rule/affiliate_referral_fee_rule.json
    • Added non_negative: 1 to the first_referral_rate field definition.
    • Added non_negative: 1 to the subsequent_referral_rate field definition.
    • Updated the modified timestamp.
  • frappe_affiliate/frappe_affiliate/doctype/coupon_batch/coupon_batch.json
    • Added non_negative: 1 to the discount field definition.
    • Added non_negative: 1 to the recurring_discount field definition.
    • Updated the modified timestamp.
Activity
  • No specific review comments or activity have been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds non_negative validation to several percentage and discount fields, which improves data integrity by preventing negative values. The changes in affiliate_referral_fee_rule.json and coupon_batch.json are a good step. I've added a couple of suggestions for coupon_batch.json to further enhance the validation logic for percentage-based discounts.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Frappe DocType field metadata to prevent entering negative referral rates and coupon discount values, improving data integrity for affiliate fee rules and coupon batch configuration.

Changes:

  • Add non_negative: 1 to first_referral_rate and subsequent_referral_rate (Percent) in Affiliate Referral Fee Rule.
  • Add non_negative: 1 to discount and recurring_discount (Float) in Coupon Batch.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
frappe_affiliate/frappe_affiliate/doctype/coupon_batch/coupon_batch.json Enforces non-negative coupon discount fields via DocType metadata.
frappe_affiliate/frappe_affiliate/doctype/affiliate_referral_fee_rule/affiliate_referral_fee_rule.json Enforces non-negative referral rate percentages via DocType metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants