Proposal Item calculation

Documentation: apply_custom_manual_discount Function

Overview

The apply_custom_manual_discount function applies a custom manual discount or markup to items in a child table based on a discount percentage specified in the main form. This function specifically applies the discount only to items belonging to the item groups "Serviced Office" or "Dedicated Desk".


How the Calculation Works

  1. Check Discount Percentage
    The function first verifies that the discount percentage (custom_manual_discount_percentage) is set and not null.

  2. Filter by Item Group
    The discount logic is applied only if the item belongs to either "Serviced Office" or "Dedicated Desk".

  3. Calculate Duration (Months)
    It calculates the number of months between the from_time and to_time fields of the item. This duration is stored in the item as months.

  4. Apply Discount or Markup

    • If the discount percentage is positive, it reduces the price rate by that percentage.

    • If the discount percentage is negative, it increases the price rate by the absolute value of that percentage.

    The adjusted rate is then multiplied by the quantity (qty1) of the item to get the final discounted rate.

  5. Update Rate Field
    The computed discounted rate is set back into the item’s rate field.


Example Calculation

Suppose we have an item with the following details:

Field

Value

item_group

Serviced Office

price_list_rate

10,000

qty1

2

custom_manual_discount_percentage

10 (positive)

from_time

2025-01-01

to_time

2025-07-01

Step 1: Calculate Months

  • From 2025-01-01 to 2025-07-01 = 6 months

Step 2: Calculate Discounted Rate

  • Discount percentage is 10%, so the price is reduced by 10%.

  • Formula:
    [ \text{Discounted Rate} = (\text{pricelistrate} \times (1 - \frac{\text{discount_percentage}}{100})) \times \text{qty1} ]

  • Calculation:
    [ = (10,000 \times (1 - \frac{10}{100})) \times 2 = (10,000 \times 0.9) \times 2 = 9,000 \times 2 = 18,000 ]

Final Result:

  • The item’s rate field is updated to 18,000.


Example Cases

Case 1: Booking starts on the 1st of the month

Parameter

Value

from_time

2025-04-01 00:00

to_time

2028-04-30 00:00

item_group

Parking / Non-Parking (separately explained)

pricelistrate

1000

customnumberof_parking (if applicable)

3

rate (for non-parking items)

1000

qty1 (quantity)

1 or parkingQty (for parking)

Step 1: Date Formatting and Days Calculation

  • start_date: "2025-04" (YYYY-MM)

  • booked_date: "01" (DD)

  • Total days in April 2025 = 30

  • Days in first month = 30 - 1 + 1 = 30 days (full month)

Step 2: Calculate Total Months

  • totalMonths = months between from_time and to_time + 1 day difference

  • From 01-Apr-2025 to 30-Apr-2028 is exactly 36 months (3 years)

  • monthsExcludingFirst = 36 - 1 = 35 months

Step 3: Calculations for Parking Item Group

  • Adjusted rate = price_list_rate × parkingQty = 1000 × 3 = 3000

  • Since booked date is "01":

    • firstMonthValue = adjustedRate = 3000

    • remainingMonthsValue = adjustedRate × monthsExcludingFirst = 3000 × 35 = 105,000

  • Total value = 3000 + 105,000 = 108,000

Step 4: Calculations for Non-Parking Item Group

  • Since booked date is "01":

    • firstMonthValue = rate = 1000

    • remainingMonthsValue = rate × monthsExcludingFirst = 1000 × 35 = 35,000

  • Total value = 1000 + 35,000 = 36,000

Step 5: Pro-Rata Calculation (common for both)

  • proRata = (noOfDaysInFirstMonth × (rate × 12) / 365) × qty1

  • For parking: rate = adjustedRate = 3000, qty1 = parkingQty = 3

  • For non-parking: rate = 1000, qty1 = 1

Calculating pro-rata for non-parking example: - proRata = 30 × (1000 × 12 / 365) × 1 ≈ 30 × 32.88 = 986.3

Step 6: Days Difference

  • daysDifference = number of days from 01-Apr-2025 to 30-Apr-2028 inclusive

  • daysDifference = 3 years × 365 + leap days ≈ 1096 days


Case 2: Booking starts on a day other than 1st

Parameter

Value

from_time

2025-04-17 00:00

to_time

2028-04-30 00:00

item_group

Parking / Non-Parking (separately explained)

pricelistrate

1000

customnumberof_parking (if applicable)

3

rate (for non-parking items)

1000

qty1 (quantity)

1 or parkingQty (for parking)

Step 1: Date Formatting and Days Calculation

  • start_date: "2025-04"

  • booked_date: "17"

  • Total days in April 2025 = 30

  • Days in first month = 30 - 17 + 1 = 14 days

Step 2: Calculate Total Months

  • totalMonths = months between from_time and to_time + 1 day difference

  • From 17-Apr-2025 to 30-Apr-2028 is roughly 36 months (same as case 1)

  • monthsExcludingFirst = 36 - 1 = 35 months

Step 3: Calculations for Parking Item Group

  • Adjusted rate = price_list_rate × parkingQty = 1000 × 3 = 3000

  • Since booked date is not "01":

    • firstMonthValue = ((adjustedRate × 12) / 365) × noOfDaysInFirstMonth
      = ((3000 × 12) / 365) × 14 ≈ (36,000 / 365) × 14 ≈ 98.63 × 14 = 1380.82

    • remainingMonthsValue = price_list_rate × parkingQty × totalMonths = 1000 × 3 × 36 = 108,000

  • Total value = 1380.82 + 108,000 = 109,380.82

Step 4: Calculations for Non-Parking Item Group

  • Since booked date is not "01":

    • firstMonthValue = ((rate × 12) / 365) × noOfDaysInFirstMonth
      = ((1000 × 12) / 365) × 14 ≈ 32.88 × 14 = 460.32

    • remainingMonthsValue = rate × totalMonths = 1000 × 36 = 36,000

  • Total value = 460.32 + 36,000 = 36,460.32

Step 5: Pro-Rata Calculation (common for both)

  • proRata = (noOfDaysInFirstMonth × (rate × 12) / 365) × qty1

For non-parking example:
proRata = 14 × (1000 × 12 / 365) × 1 ≈ 460.32

Step 6: Days Difference

  • daysDifference = number of days from 17-Apr-2025 to 30-Apr-2028 inclusive

  • daysDifference ≈ 1079 days


Summary Table

Case

Item Group

First Month Value

Remaining Months Value

Total Value

Pro-Rata

Days

1

Parking

3000

105000

108000

986.3 (approx)

1096

1

Non-Parking

1000

35000

36000

986.3 (approx)

1096

2

Parking

1380.82

108000

109380.82

460.32 (approx)

1079

2

Non-Parking

460.32

36000

36460.32

460.32 (approx)

1079


Html Table-

No.

Proposed Office

List Price

Discount

Rate (INR)

Term Value

Term Value Without Escalation and Without Discount

Term Value with Escalation Without Discount

Term Value with Escalation With Discount

Workstation

Cost to Company

Management Cost

Client Cost

Net Value

1

Office A

50000

5.00

47500

285000

300000

290000

275000

10

2000

3.5

2500

270000

2

Office B

60000

10.00

54000

324000

330000

320000

310000

15

3000

4.0

2800

305000

3

Customization Cost

0

0.00

0

0

0

0

0

0

5000

0

0

5000

| (A) Term Value Without Escalation and Without Discount - 630000 | (B) Term value with Esc. Without Discount - 610000 | (C) Term value With Escalation With Discount - 590000 | (A vs C) Total Discount % - 6.35%

If item group is serviced office and custom manula percetage is >0 then In that Item - discount = pricelistrate * (1-manual percentage*100) final amount = discount * qty

item.rate = discount final_amount = item.amount

pricelistrate = 23500 after give 5 % manula discount , monthly rate is 22325 and amount is (22325*1(qty)) = 22325

If Discount(Tier Prompts) = 5 then result = rate - (rate - Discount / 100) rate = result

For Proposal Item Table it fetch the fromtime and totime form Enquiry.

if document have customrentfree h then set the rent_free in child table.

*Proposal Item ***

Item

List price

Start Date

End date

Term

Rate

Amount

list price value

First Month Value

serviced

126177

01-04-2025

30-04-2028

37

126177





46,68,549.00





46,68,549.00





126177

parking

9000




27000

999000

999000

27000

Telephony

3000




3000

1,11,000.00

1,11,000.00

3000



Html Table (01)

Item

List price

rate

Term Value

Without Without

With /Without

With Esclation and with discount

Serviced

126177

126177

4668549

4668549

5062625.01

4926084.67

Parking

9000

9000

999000

999000

999000

999000

Telephony

3000

3000

111000

111000

111000

111000









IF ITEM IS FROM SERVICED -

Rate = (( "price_list_rate")) - (((row["Discount"])/100)*float(item.get("price_list_rate"))) * (float(item.get("qty1")))

otherwise - rate = monthly rent

Term Value = rate * months

Term Value Without Without – List Price Value

Term Value With escalation and Without Escalation -

if Item is from serviced office - sum of (amount in payment summary)

otherwise – rate * months

if item is from setup and exit - price_list_rate * workstation_sold

otherwise = amount

Term Value With Escalation and With discount – sum of amount in payment summary for service office

otherwise – item.amount


Fo Other Case (17 to 30 )-

Item

List price

Start Date

End date

Term

Rate

Amount

list price value

First Month Value

serviced

126177

01-04-2025

30-04-2028

37

126177



46,00,447.99


46,00,447.99

58075.99

parking

9000




27000

9,84,427.40

9,84,427.40





12427.4

Telephony

3000




3000

 1,09,380.82

1,09,380.82

1380.82


First month value fpr parking = (price_list_rate 12 /365) qty 14

term value = 58075.99 + rate *36

for another item froup -

first month value = (rate 12 /365) 14

term value = first_month_value + rate*36



On this page