Skip to Content
Menu
This question has been flagged
1 Reply
1050 Views

Hello everyone, two questions

 How can I generate a surcharge to a client for not making the payment on time.

Total Invoice: $ 100

Invoice date: 10/20/2020

Invoice Due Date: 10/27/2020

Today is 10/30/2020

I need to evaluate these options

1) add $ 2 x day, so today you must pay $ 106

2) add 2%, then you must pay $ 102


Thanks

Avatar
Discard
Best Answer

Hey for this you can add a button in  the header

current date = fields.Date(string ='current date', default = datetime.today())

def action_surcharge(self):

    new_cur_date = self.current_date.strftime('%Y=%m-%d')

    due_date = self.your_due_date.strftime('%Y-%m-%d')

     if new_cur_date > due_date:

        #for subtracting two dates you may need to use strptime() here m just subtracting it

         extra_days = (new_cur_date - due_date).days

         sur_charge = extra_days * 2

         self.total = self.total + sur_charge
P.S. : As i have written the code here as text so it may have indentation error etc it is just to give you an idea. Hope it helps. You may have to use @api.depends also.

Thanks

Avatar
Discard
Author

regards