Subversion Repositories SmartDukaan

Rev

Rev 18138 | Rev 18574 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18138 Rev 18139
Line 8229... Line 8229...
8229
            order.billing_timestamp = datetime.datetime.now()
8229
            order.billing_timestamp = datetime.datetime.now()
8230
            order.billed_by = billed_by
8230
            order.billed_by = billed_by
8231
            
8231
            
8232
            # Letting the billing process fail in cases where we are unable to 
8232
            # Letting the billing process fail in cases where we are unable to 
8233
            # fill in transfer price
8233
            # fill in transfer price
8234
            if order.productCondition == ProductCondition.BAD:
8234
            
8235
                try:
8235
            try:
8236
                    if not inventory_client.isAlive():
8236
                if not inventory_client.isAlive():
8237
                        inventory_client = InventoryClient().get_client()
8237
                    inventory_client = InventoryClient().get_client()
8238
                    warehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
8238
                warehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
-
 
8239
                if order.productCondition == ProductCondition.BAD:
8239
                    item_pricing = inventory_client.getItemPricing(item_id, warehouse.vendor.id)
8240
                    item_pricing = inventory_client.getItemPricing(item_id, warehouse.vendor.id)
8240
                    lineitem.transfer_price = item_pricing.transferPrice
8241
                    lineitem.transfer_price = item_pricing.transferPrice
8241
                    lineitem.nlc = item_pricing.nlc
8242
                    lineitem.nlc = item_pricing.nlc
8242
                    if order.taxType == TaxType.CFORM:
8243
                if order.taxType == TaxType.CFORM:
8243
                        lineitem.vatRate = 2
8244
                    lineitem.vatRate = 2
-
 
8245
                else:
-
 
8246
                    if not catalog_client.isAlive():
-
 
8247
                        catalog_client = CatalogClient().get_client()
-
 
8248
                    if fetchStateMaster()[warehouse.stateId].vatType==VatType.MRP:
-
 
8249
                        lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, warehouse.stateId, lineitem.mrp)
8244
                    else:
8250
                    else:
8245
                        if not catalog_client.isAlive():
-
 
8246
                            catalog_client = CatalogClient().get_client()
-
 
8247
                        if fetchStateMaster()[warehouse.stateId].vatType==VatType.MRP:
-
 
8248
                            lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, warehouse.stateId, lineitem.mrp)
-
 
8249
                        else:
-
 
8250
                            lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, warehouse.stateId, lineitem.unit_price)
8251
                        lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, warehouse.stateId, lineitem.unit_price)
8251
                    order.vendorId = warehouse.vendor.id
8252
                order.vendorId = warehouse.vendor.id
8252
                    whStateId = warehouse.stateId
8253
                whStateId = warehouse.stateId
8253
                except InventoryServiceException as e:
8254
            except InventoryServiceException as e:
8254
                    print sys.exc_info()[0]
8255
                print sys.exc_info()[0]
8255
                    print e.message
8256
                print e.message
8256
                    if warehouseDbConnection.open:
8257
                if warehouseDbConnection.open:
8257
                        warehouseDbConnection.close()
8258
                    warehouseDbConnection.close()
8258
                    raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
8259
                raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
8259
            
8260
            
8260
            if order.orderType == OrderType.B2B:
8261
            if order.orderType == OrderType.B2B:
8261
                tinNumber = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == "tinNumber").first()
8262
                tinNumber = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == "tinNumber").first()
8262
                if tinNumber is None:
8263
                if tinNumber is None:
8263
                    if warehouseDbConnection.open:
8264
                    if warehouseDbConnection.open: