因此,我正在开发一个发票模块,并坚持一个逻辑。 步骤来生成发票:如何开发部分发票模块的逻辑/算法?
Bringing all those rows whose cancelled_date is none or is of current_month from the database
这给了我所有的数据,生成客户的发票当月。
伪代码 -
If membership is new:
if (working_days/total_days) in a month is 1:
Don't calculate prorata
else:
calculate pro rata(For no. of days)
else:
calculate invoice generally
现在的问题是:客户的cancelled_date可在上述方案等进行设定: 伪代码 -
If membership is new:
if (working_days/total_days) in a month is 1:
if cancelled_date == end_date_month:
Don't calculate prorata
else:
calculate pro rata
else:
if cancelled_date == end_date_month:
calculate pro rata(For no. of days)
else:
calculate pro rata (start_date & end_date for current
month)
else:
if cancelled_date == end_date_month:
calculate invoice generally
else:
calculate pro rata
我怎么能不使仅通过简单地解决cancelled_date场景来减少代码。我无法想到上面的一个好逻辑/算法。
嘿,你好,谢谢!这也导致如果其他因为代码是在Python中。我仍然需要把这些if/else。 –
对不起,我没有考虑到这一点 – OzW
我在想的是做两个单独的函数,并在类中为cancelled_membership创建一个属性并计算它们在不同函数中的发票。 –