| Line 1841... |
Line 1841... |
| 1841 |
def add_billing_details(orderId, invoice_number, serialNumbers, itemNumbers, freebieWarehouseId, billedBy, jacketNumber, billingType, fulfilmentWarehouseId, authorize):
|
1841 |
def add_billing_details(orderId, invoice_number, serialNumbers, itemNumbers, freebieWarehouseId, billedBy, jacketNumber, billingType, fulfilmentWarehouseId, authorize):
|
| 1842 |
if billedBy is None or billedBy.strip() == "":
|
1842 |
if billedBy is None or billedBy.strip() == "":
|
| 1843 |
raise TransactionServiceException(110, "Invalid Biller")
|
1843 |
raise TransactionServiceException(110, "Invalid Biller")
|
| 1844 |
|
1844 |
|
| 1845 |
order = Order.get_by(id=orderId)
|
1845 |
order = Order.get_by(id=orderId)
|
| - |
|
1846 |
hsnCode = order.getLineItems.get(0).hsnCode
|
| 1846 |
if not order:
|
1847 |
if not order:
|
| 1847 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
1848 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
| 1848 |
|
1849 |
|
| 1849 |
newTaxType = __getOrderTaxType(order)
|
1850 |
newTaxType = __getOrderTaxType(order)
|
| 1850 |
if order.taxType == TaxType.CFORM and newTaxType == TaxType.VAT:
|
- |
|
| 1851 |
raise TransactionServiceException(101, "C-Form billing is not allowed for same state for Order" + str(orderId))
|
- |
|
| 1852 |
else:
|
- |
|
| 1853 |
order.taxType = newTaxType
|
1851 |
order.taxType = newTaxType
|
| 1854 |
|
1852 |
|
| 1855 |
|
1853 |
|
| 1856 |
if jacketNumber is None or jacketNumber <= 0:
|
1854 |
if jacketNumber is None or jacketNumber <= 0:
|
| 1857 |
if order.source == OrderSource.EBAY or order.source == OrderSource.SNAPDEAL or order.source == OrderSource.FLIPKART:
|
1855 |
if order.source == OrderSource.EBAY or order.source == OrderSource.SNAPDEAL or order.source == OrderSource.FLIPKART:
|
| 1858 |
print "Skipping Jacket Number field for OrderId " + str(orderId)
|
1856 |
print "Skipping Jacket Number field for OrderId " + str(orderId)
|
| Line 1900... |
Line 1898... |
| 1900 |
|
1898 |
|
| 1901 |
catalog_client = CatalogClient().get_client()
|
1899 |
catalog_client = CatalogClient().get_client()
|
| 1902 |
item = catalog_client.getItem(item_id)
|
1900 |
item = catalog_client.getItem(item_id)
|
| 1903 |
if order.status == OrderStatus.ACCEPTED:
|
1901 |
if order.status == OrderStatus.ACCEPTED:
|
| 1904 |
order.jacket_number = jacketNumber
|
1902 |
order.jacket_number = jacketNumber
|
| 1905 |
if order.source == 6:
|
- |
|
| 1906 |
order.jacket_number = "600"+str(orderId)
|
- |
|
| 1907 |
if order.source == 7:
|
- |
|
| 1908 |
order.jacket_number = "700"+str(orderId)
|
- |
|
| 1909 |
if order.source == 8:
|
- |
|
| 1910 |
order.jacket_number = "800"+str(orderId)
|
- |
|
| - |
|
1903 |
|
| 1911 |
if itemNumbers:
|
1904 |
if itemNumbers:
|
| 1912 |
lineitem.item_number = itemNumbers[0]
|
1905 |
lineitem.item_number = itemNumbers[0]
|
| 1913 |
|
1906 |
|
| 1914 |
if singleInvoiceAttr:
|
- |
|
| 1915 |
if singleInvoiceAttr.value == "true":
|
- |
|
| 1916 |
if serialNumbers:
|
- |
|
| 1917 |
finalSerialNo =''
|
- |
|
| 1918 |
for serialNumber in serialNumbers:
|
- |
|
| 1919 |
finalSerialNo = finalSerialNo +','+ serialNumber
|
- |
|
| 1920 |
lineItemImei = Line_Item_Imei()
|
- |
|
| 1921 |
lineItemImei.serial_number = serialNumber
|
- |
|
| 1922 |
lineItemImei.line_item_id = lineitem.id
|
- |
|
| 1923 |
|
- |
|
| 1924 |
finalSerialNo = finalSerialNo[1:]
|
- |
|
| 1925 |
|
- |
|
| 1926 |
if lineitem.serial_number is None:
|
- |
|
| 1927 |
lineitem.serial_number = finalSerialNo
|
- |
|
| 1928 |
else:
|
- |
|
| 1929 |
lineitem.serial_number = lineitem.serial_number + ',' + finalSerialNo
|
- |
|
| 1930 |
else:
|
- |
|
| 1931 |
if serialNumbers:
|
1907 |
if serialNumbers:
|
| 1932 |
lineitem.serial_number = serialNumbers[0]
|
1908 |
lineitem.serial_number = serialNumbers[0]
|
| 1933 |
|
- |
|
| 1934 |
'''
|
- |
|
| 1935 |
if billingType == BillingType.EXTERNAL or billingType == BillingType.OURS_EXTERNAL:
|
- |
|
| 1936 |
if billedOrdersColorMap.has_key(orderId):
|
- |
|
| 1937 |
etpColor = billedOrdersColorMap.get(orderId)
|
- |
|
| 1938 |
ourColor = order.lineitems[0].color
|
- |
|
| 1939 |
if ourColor and etpColor != ourColor and not authorize:
|
- |
|
| 1940 |
raise TransactionServiceException(777, "ETP color: " + etpColor + " and Order color: " + ourColor)
|
- |
|
| 1941 |
else:
|
- |
|
| 1942 |
billedOrdersColorMap.pop(orderId)
|
- |
|
| 1943 |
'''
|
- |
|
| 1944 |
|
1909 |
|
| 1945 |
if order.productCondition == ProductCondition.BAD:
|
1910 |
if order.productCondition == ProductCondition.BAD:
|
| 1946 |
if billingType != BillingType.OURS:
|
1911 |
if billingType != BillingType.OURS:
|
| 1947 |
raise TransactionServiceException(110, 'Bad inventory is not allowed to be sold from current warehouse')
|
1912 |
raise TransactionServiceException(110, 'Bad inventory is not allowed to be sold from current warehouse')
|
| 1948 |
if billingType == BillingType.EXTERNAL:
|
1913 |
if billingType == BillingType.EXTERNAL:
|
| Line 1979... |
Line 1944... |
| 1979 |
inventory_client = InventoryClient().get_client()
|
1944 |
inventory_client = InventoryClient().get_client()
|
| 1980 |
warehouse = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
1945 |
warehouse = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| 1981 |
item_pricing = inventory_client.getItemPricing(item_id, warehouse.vendor.id)
|
1946 |
item_pricing = inventory_client.getItemPricing(item_id, warehouse.vendor.id)
|
| 1982 |
lineitem.transfer_price = item_pricing.transferPrice
|
1947 |
lineitem.transfer_price = item_pricing.transferPrice
|
| 1983 |
lineitem.nlc = item_pricing.nlc
|
1948 |
lineitem.nlc = item_pricing.nlc
|
| 1984 |
if order.taxType == TaxType.CFORM:
|
- |
|
| 1985 |
lineitem.vatRate = 2
|
- |
|
| 1986 |
else:
|
- |
|
| 1987 |
if fetchStateMaster()[warehouse.stateId].vatType==VatType.MRP and lineitem.mrp:
|
- |
|
| 1988 |
lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, warehouse.stateId, lineitem.mrp)
|
- |
|
| 1989 |
else:
|
- |
|
| 1990 |
lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, warehouse.stateId, lineitem.unit_price)
|
- |
|
| 1991 |
order.vendorId = warehouse.vendor.id
|
- |
|
| 1992 |
whStateId = warehouse.stateId
|
- |
|
| 1993 |
except InventoryServiceException as e:
|
1949 |
except InventoryServiceException as e:
|
| 1994 |
print sys.exc_info()[0]
|
1950 |
print sys.exc_info()[0]
|
| 1995 |
print e.message
|
1951 |
print e.message
|
| 1996 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
1952 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
| 1997 |
|
1953 |
|
| 1998 |
if order.orderType == OrderType.B2B:
|
- |
|
| 1999 |
tinNumber = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == "tinNumber").first()
|
- |
|
| 2000 |
if tinNumber is None:
|
- |
|
| 2001 |
raise TransactionServiceException(101, "Tin Number is Missing for B2B Order. Please contact engineering Team" + str(orderId))
|
- |
|
| 2002 |
if newTaxType != 0:
|
- |
|
| 2003 |
order.orderType = OrderType.B2C
|
- |
|
| 2004 |
|
- |
|
| 2005 |
|
- |
|
| 2006 |
# For OUR warehouse, we need to scan out items for every billed order
|
1954 |
# For OUR warehouse, we need to scan out items for every billed order
|
| 2007 |
if billingType == BillingType.OURS:
|
1955 |
if billingType == BillingType.OURS:
|
| 2008 |
if order.productCondition == ProductCondition.GOOD:
|
1956 |
if order.productCondition == ProductCondition.GOOD:
|
| 2009 |
for index, serialNumber in enumerate(serialNumbers):
|
1957 |
for index, serialNumber in enumerate(serialNumbers):
|
| 2010 |
try:
|
1958 |
try:
|
| Line 2114... |
Line 2062... |
| 2114 |
return True
|
2062 |
return True
|
| 2115 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
2063 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
| 2116 |
#as of now only company 2 - SORPL, 3-New company is operating and cutoff config will decide the company to be used to bill
|
2064 |
#as of now only company 2 - SORPL, 3-New company is operating and cutoff config will decide the company to be used to bill
|
| 2117 |
#until further change - Amit Gupta
|
2065 |
#until further change - Amit Gupta
|
| 2118 |
seller_id = __get_seller(order.warehouse_id)
|
2066 |
seller_id = __get_seller(order.warehouse_id)
|
| 2119 |
order.invoice_number = get_next_invoice_counter(seller_id, order.warehouse_id, order.orderType)
|
2067 |
order.invoice_number = get_next_invoice_counter(seller_id, order.warehouse_id, hsnCode)
|
| 2120 |
order.seller_id = seller_id
|
2068 |
order.seller_id = seller_id
|
| 2121 |
whaddressmapping = WarehouseAddressMapping.query.filter_by(warehouse_id=order.warehouse_id).one()
|
2069 |
whaddressmapping = WarehouseAddressMapping.query.filter_by(warehouse_id=order.warehouse_id).one()
|
| 2122 |
order.warehouse_address_id = whaddressmapping.address_id
|
2070 |
order.warehouse_address_id = whaddressmapping.address_id
|
| 2123 |
session.commit()
|
2071 |
session.commit()
|
| 2124 |
return True
|
2072 |
return True
|
| Line 2840... |
Line 2788... |
| 2840 |
entity_id = InvoiceIDGenerator.query.filter(InvoiceIDGenerator.orderType == orderType).with_lockmode("update").one()
|
2788 |
entity_id = InvoiceIDGenerator.query.filter(InvoiceIDGenerator.orderType == orderType).with_lockmode("update").one()
|
| 2841 |
invoice_number = entity_id.id + 1
|
2789 |
invoice_number = entity_id.id + 1
|
| 2842 |
entity_id.id = invoice_number
|
2790 |
entity_id.id = invoice_number
|
| 2843 |
return invoice_number
|
2791 |
return invoice_number
|
| 2844 |
|
2792 |
|
| 2845 |
def get_next_invoice_counter(seller_id, warehouse_id, orderType):
|
2793 |
def get_next_invoice_counter(seller_id, warehouse_id, hsnCode):
|
| 2846 |
#Sequence would now be maintained through single order for seller
|
2794 |
#Sequence would now be maintained through single order for seller
|
| 2847 |
if OrderType.B2Cbulk == orderType:
|
- |
|
| 2848 |
orderType = OrderType.B2C
|
- |
|
| 2849 |
#entity_id = InvoiceCounterGenerator.query.filter(InvoiceCounterGenerator.orderType == orderType).filter(InvoiceCounterGenerator.stateId == stateId).filter(InvoiceCounterGenerator.companyId==companyId).with_lockmode("update").one()
|
2795 |
#entity_id = InvoiceCounterGenerator.query.filter(InvoiceCounterGenerator.orderType == orderType).filter(InvoiceCounterGenerator.stateId == stateId).filter(InvoiceCounterGenerator.companyId==companyId).with_lockmode("update").one()
|
| 2850 |
entity_id = SellerWarehouse.query.filter(SellerWarehouse.warehouse_id == warehouse_id).filter(SellerWarehouse.seller_id==seller_id).with_lockmode("update").one()
|
2796 |
entity_id = SellerWarehouse.query.filter(SellerWarehouse.warehouse_id == warehouse_id).filter(SellerWarehouse.seller_id==seller_id).with_lockmode("update").one()
|
| - |
|
2797 |
prefix = entity_id.prefix
|
| - |
|
2798 |
if hsnCode=="NOGST":
|
| - |
|
2799 |
document_number = entity_id.challan_id + 1
|
| - |
|
2800 |
entity_id.challan_id = document_number
|
| - |
|
2801 |
prefix = 'CHLN-' + prefix
|
| - |
|
2802 |
else:
|
| 2851 |
invoice_number = entity_id.id + 1
|
2803 |
document_number = entity_id.id + 1
|
| 2852 |
entity_id.id = invoice_number
|
2804 |
entity_id.id = document_number
|
| 2853 |
ret_invoiceNo = entity_id.prefix + str(invoice_number)
|
2805 |
ret_invoiceNo = entity_id.prefix + str(document_number)
|
| 2854 |
return ret_invoiceNo
|
2806 |
return ret_invoiceNo
|
| 2855 |
|
2807 |
|
| 2856 |
def toggle_doa_flag(order_id):
|
2808 |
def toggle_doa_flag(order_id):
|
| 2857 |
order = get_order(order_id)
|
2809 |
order = get_order(order_id)
|
| 2858 |
if(order.doaFlag):
|
2810 |
if(order.doaFlag):
|
| Line 8544... |
Line 8496... |
| 8544 |
raise TransactionServiceException(301, "No order found for the given order id" + str(orderId))
|
8496 |
raise TransactionServiceException(301, "No order found for the given order id" + str(orderId))
|
| 8545 |
else:
|
8497 |
else:
|
| 8546 |
ordersList.append(order)
|
8498 |
ordersList.append(order)
|
| 8547 |
|
8499 |
|
| 8548 |
singleOrder = ordersList[0]
|
8500 |
singleOrder = ordersList[0]
|
| - |
|
8501 |
hsnCode = singleOrder.getLineItems.get(0).hsnCode
|
| 8549 |
if singleOrder.logisticsTransactionId is not None:
|
8502 |
if singleOrder.logisticsTransactionId is not None:
|
| 8550 |
grouppedOrders = get_group_orders_by_logistics_txn_id(singleOrder.logisticsTransactionId)
|
8503 |
grouppedOrders = get_group_orders_by_logistics_txn_id(singleOrder.logisticsTransactionId)
|
| 8551 |
|
8504 |
|
| 8552 |
errorString = ""
|
8505 |
errorString = ""
|
| 8553 |
missingString = "Billing Details Missing for following Orders:- "
|
8506 |
missingString = "Billing Details Missing for following Orders:- "
|
| Line 9104... |
Line 9057... |
| 9104 |
|
9057 |
|
| 9105 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
9058 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
| 9106 |
#get seller for current warehouse id
|
9059 |
#get seller for current warehouse id
|
| 9107 |
seller_id = __get_seller(order.warehouse_id)
|
9060 |
seller_id = __get_seller(order.warehouse_id)
|
| 9108 |
whaddressmapping = WarehouseAddressMapping.query.filter_by(warehouse_id=ordersList[0].warehouse_id).one()
|
9061 |
whaddressmapping = WarehouseAddressMapping.query.filter_by(warehouse_id=ordersList[0].warehouse_id).one()
|
| 9109 |
invoiceNumber = get_next_invoice_counter(seller_id, ordersList[0].warehouse_id, ordersList[0].orderType)
|
9062 |
invoiceNumber = get_next_invoice_counter(seller_id, ordersList[0].warehouse_id, hsnCode)
|
| 9110 |
|
9063 |
|
| 9111 |
|
9064 |
|
| 9112 |
|
9065 |
|
| 9113 |
invoiceTypeVal = 1
|
9066 |
invoiceTypeVal = 1
|
| 9114 |
if not individualInvoice:
|
9067 |
if not individualInvoice:
|