|
|
@@ -260,7 +260,7 @@ def createVoucherService(files,data,app,mongo):
|
|
|
suffix.append(key[len('product_dec'):])
|
|
|
|
|
|
od = []
|
|
|
-
|
|
|
+ total_amount = 0
|
|
|
# Upload Order Details
|
|
|
for value in suffix:
|
|
|
|
|
|
@@ -311,12 +311,14 @@ def createVoucherService(files,data,app,mongo):
|
|
|
str(value)])
|
|
|
|
|
|
if append == True:
|
|
|
+ total_amount += (quote['product_amount'] * quote['product_qty']) + quote['product_gst']
|
|
|
od.append(quote)
|
|
|
|
|
|
insert_doc['od'] = od
|
|
|
|
|
|
if 'p_additional_charges' in data:
|
|
|
insert_doc['po_additional_charges'] = float(data['p_additional_charges'])
|
|
|
+ total_amount+=insert_doc['po_additional_charges']
|
|
|
|
|
|
if 'tds_rate' in data:
|
|
|
insert_doc['tds_rate'] = float(data['tds_rate'])
|
|
|
@@ -423,9 +425,8 @@ def createVoucherService(files,data,app,mongo):
|
|
|
selectGenrate==True
|
|
|
|
|
|
if 'product_total_amount' in data:
|
|
|
- insert_doc['product_total_amount'] = float(data['product_total_amount' ])
|
|
|
- total_amount = float(data['product_total_amount'])
|
|
|
- insert_doc['product_gross_amount'] = float(data['product_total_amount' ])
|
|
|
+ insert_doc['product_total_amount'] = total_amount
|
|
|
+ insert_doc['product_gross_amount'] = total_amount
|
|
|
|
|
|
if 'vendor_type' in data and data['vendor_type']=='registered':
|
|
|
if 'vendors' in data and data['vendors'] != '':
|
|
|
@@ -468,8 +469,8 @@ def createVoucherService(files,data,app,mongo):
|
|
|
insert_doc['MOP'] = MOP
|
|
|
|
|
|
if 'amount_words' in data and data['amount_words'] != '':
|
|
|
- amount_words = data['amount_words'] # MOU Expiry
|
|
|
- insert_doc['amount_words'] = amount_words
|
|
|
+ amount_words = number_to_word(total_amount)
|
|
|
+ insert_doc['amount_words'] = amount_words.lower()
|
|
|
|
|
|
if 'intervention' in data and data['intervention']!='':
|
|
|
insert_doc['intervention']=data['intervention']
|
|
|
@@ -930,4 +931,45 @@ def createAndGenrateAssetCode(data,od,voucher_code,timestamp,mongo):
|
|
|
create_voucher=False
|
|
|
print(err)
|
|
|
|
|
|
- return create_voucher
|
|
|
+ return create_voucher
|
|
|
+
|
|
|
+def number_to_word(number):
|
|
|
+ def get_word(n):
|
|
|
+ words={ 0:"", 1:"One", 2:"Two", 3:"Three", 4:"Four", 5:"Five", 6:"Six", 7:"Seven", 8:"Eight", 9:"Nine", 10:"Ten", 11:"Eleven", 12:"Twelve", 13:"Thirteen", 14:"Fourteen", 15:"Fifteen", 16:"Sixteen", 17:"Seventeen", 18:"Eighteen", 19:"Nineteen", 20:"Twenty", 30:"Thirty", 40:"Forty", 50:"Fifty", 60:"Sixty", 70:"Seventy", 80:"Eighty", 90:"Ninty" }
|
|
|
+ if n<=20:
|
|
|
+ return words[n]
|
|
|
+ else:
|
|
|
+ ones=n%10
|
|
|
+ tens=n-ones
|
|
|
+ return words[tens]+" "+words[ones]
|
|
|
+
|
|
|
+ def get_all_word(n):
|
|
|
+ d=[100,10,100,100]
|
|
|
+ v=["","Hundred And","Thousand","lakh"]
|
|
|
+ w=[]
|
|
|
+ for i,x in zip(d,v):
|
|
|
+ t=get_word(n%i)
|
|
|
+ if t!="":
|
|
|
+ t+=" "+x
|
|
|
+ w.append(t.rstrip(" "))
|
|
|
+ n=n//i
|
|
|
+ w.reverse()
|
|
|
+ w=' '.join(w).strip()
|
|
|
+ if w.endswith("And"):
|
|
|
+ w=w[:-3]
|
|
|
+ return w
|
|
|
+
|
|
|
+ arr=str(number).split(".")
|
|
|
+ number=int(arr[0])
|
|
|
+ crore=number//10000000
|
|
|
+ number=number%10000000
|
|
|
+ word=""
|
|
|
+ if crore>0:
|
|
|
+ word+=get_all_word(crore)
|
|
|
+ word+=" crore "
|
|
|
+ word+=get_all_word(number).strip()+" Rupees"
|
|
|
+ if len(arr)>1:
|
|
|
+ if len(arr[1])==1:
|
|
|
+ arr[1]+="0"
|
|
|
+ word+=" and "+get_all_word(int(arr[1]))+" paisa"
|
|
|
+ return word
|