Files
ds_quickbooks/app/services/rules.py
T

96 lines
6.5 KiB
Python
Raw Normal View History

rule = '''
### Rule Scenarios
Impact of Signup Fields on Tax Calculation and Receipt Matching
Impact of Signup Fields (Country and Province/State) on Tax Calculation and Matching**
**Scenario 1:** User Location (Canada, Ontario) but Receipt from Another Location (e.g., Quebec)
User's Location: Canada, Ontario (for tax and depreciation purposes).
Receipt Location: The receipt comes from Quebec (the tax rules in Quebec are different from Ontario).
What Happens:
The sales tax rate should be applied based on the location of the receipt, not the user's profile location.
**For example:**
The user in Ontario will have 13% HST applied to their purchases.
If the receipt is from Quebec, the QST (Quebec Sales Tax) of 9.975% applies instead.
**Scenario 2:** User Location (Canada, Ontario) and Receipt Location is Different Country (e.g., USA)
User's Location: Canada, Ontario.
Receipt Location: The receipt is from a business in the USA (e.g., New York).
**What Happens:**
Sales Tax should not be applied for international transactions (USA in this case) unless the user is importing or there is a customs duty involved.
The system will not apply a Canadian sales tax to the receipt from the USA, but the foreign exchange (FX) rule will apply because there is a mismatch between currencies (USD vs. CAD).
**Scenario 3:** User Location (USA, New York) but Receipt from Another Location in the Same Country (e.g., California)
User's Location: USA, New York (for tax purposes).
Receipt Location: The receipt is from California (still in the USA, but the sales tax rate is different).
**What Happens:**
Sales tax should be applied based on the location of the receipt, not the users location, since the receipt was issued in California.
California may have a different sales tax rate than New York.
**Scenario 4:** User Location (Canada, Ontario) and Receipt Location with No Address Information
User's Location: Canada, Ontario.
Receipt Location: The receipt contains no clear shipping or billing address.
**What Happens:**
If the receipt does not have a clear location, the system will default to the users location for sales tax and depreciation.
Action:
Sales Tax: Apply the sales tax rate based on the user's location (Ontario). For example, 13% HST will be applied.
Depreciation: Apply the depreciation rules based on the users location (Ontario), even if the receipt doesnt have address information.
**Summary of Actions in These Scenarios:**
Sales Tax:If the receipt is from a different location (same country or foreign), use the location from the receipt for sales tax calculation.
If the receipt is from a different country, dont apply sales tax from the user's country but flag the FX discrepancy.
If the location is missing, apply the users location sales tax by default.
**Depreciation:** Always apply depreciation rules based on the users location, regardless of where the receipt is from.
**FX (Foreign Exchange):** If the receipt is in a different currency, flag the FX difference for manual review but dont fetch exchange rates.
### 2. **Foreign Exchange (FX) Rule**
**Purpose**: To handle discrepancies when transactions and receipts are in different currencies (e.g., USD vs. CAD).
- **Action**: Identify the currency mismatch, but do not automatically fetch the exchange rate. Flag the FX difference for manual review, allowing the user to approve or adjust the balance.
**Example**:
1. A transaction in USD for $100, matched to a receipt in CAD for $125, results in an FX discrepancy of $25.
2. The system flags the discrepancy for manual review by the user. The user can then approve the difference or adjust the amounts manually.
### 3. **Depreciation Rule**
**Purpose**: To calculate the depreciation for assets based on the Straight-Line Method (for accounting) or CCA Depreciation (Declining Balance) for tax purposes.
**Action**:
- Apply Straight-Line Depreciation (for accounting) across the assets useful life.
- Apply CCA Depreciation (for tax purposes) using a declining balance method.
**Example**:
1. Straight-Line Depreciation: An asset purchased for $10,000, with a 5-year useful life and a residual value of $1,000, will have an annual depreciation of:
- (10,000 - 1,000)/5 = 1,800 per year for 5 years.
2. CCA Depreciation: A truck purchased for $20,000, eligible for 30% CCA per year. The depreciation will be:
- Year 1: 20,000 x 30% = $6,000
- Year 2: (20,000 - 6,000) x 30% = $4,200
- The depreciation will decline each year as the book value reduces.
### 4. **Meals & Entertainment Tax Deduction Rule**
**Purpose**: To apply the correct tax deduction for Meals & Entertainment expenses.
**Action**:
- For Tax Purposes: Only 50% of the total receipt amount is deductible.
- For Accounting Purposes: 100% of the total receipt amount is deductible.
- Sales Tax: The full sales tax will be deducted for accounting purposes.
**Example**:
1. A $100 meal receipt for a business dinner:
- **Tax Purposes**: Only $50 of the total amount is deductible.
- **Accounting Purposes**: The full $100 is deductible.
2. If the sales tax on the meal is $12, the entire $12 is included in the accounting deduction, but for tax purposes, the $50 deduction will reflect the adjusted amount after the 50% rule is applied.
### **When Location on Receipt is Different from User's Location**
**1. Sales Tax**:
- **Scenario 1**: If the **receipt's location** is different (e.g., receipt from Quebec for a user in Ontario), the **sales tax** is applied based on the **receipt's location** (Quebec sales tax).
- **Scenario 2**: If the **receipt** is from a different **country** (e.g., USA), the **system flags** the **currency mismatch** but does not apply **Canadian sales tax**.
**2. Depreciation**:
- Depreciation is always calculated based on the **user's location**, not the receipt's location.
- **Depreciation Method** for **Canada (Ontario)**: **CCA method** will apply, regardless of where the receipt comes from.
**3. FX Handling**:
- If the receipt is in a different **currency** (e.g., USD for a CAD-based user), the system will **flag FX differences** for manual review but wont fetch exchange rates.
**4. General Process**:
- When the **receipt location** is different from the **user's location**, ensure that the **tax and depreciation** are correctly applied based on the **receipt's data**.
- For **foreign transactions**, ensure that **FX differences** are flagged for user review.
- For **missing location information**, apply **users location** by default for tax and depreciation.
'''