| Line 2... |
Line 2... |
| 2 |
from sqlalchemy.sql import or_ ,func, asc
|
2 |
from sqlalchemy.sql import or_ ,func, asc
|
| 3 |
from shop2020.config.client.ConfigClient import ConfigClient
|
3 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 4 |
from shop2020.model.v1.catalog.impl import DataService
|
4 |
from shop2020.model.v1.catalog.impl import DataService
|
| 5 |
from shop2020.model.v1.catalog.impl.DataService import SnapdealItem, MarketplaceItems, Item, \
|
5 |
from shop2020.model.v1.catalog.impl.DataService import SnapdealItem, MarketplaceItems, Item, \
|
| 6 |
Category, SourcePercentageMaster, MarketPlaceHistory, MarketPlaceUpdateHistory, MarketPlaceItemPrice, \
|
6 |
Category, SourcePercentageMaster, MarketPlaceHistory, MarketPlaceUpdateHistory, MarketPlaceItemPrice, \
|
| 7 |
SourceCategoryPercentage, SourceItemPercentage
|
7 |
SourceCategoryPercentage, SourceItemPercentage, SourceReturnPercentage
|
| 8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| 9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotential,\
|
9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotential,\
|
| 10 |
Decision, RunType
|
10 |
Decision, RunType
|
| 11 |
from shop2020.clients.CatalogClient import CatalogClient
|
11 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 12 |
from shop2020.clients.InventoryClient import InventoryClient
|
12 |
from shop2020.clients.InventoryClient import InventoryClient
|
| Line 418... |
Line 418... |
| 418 |
|
418 |
|
| 419 |
for snapdeal_item in items:
|
419 |
for snapdeal_item in items:
|
| 420 |
it = Item.query.filter_by(id=snapdeal_item.item_id).one()
|
420 |
it = Item.query.filter_by(id=snapdeal_item.item_id).one()
|
| 421 |
category = Category.query.filter_by(id=it.category).one()
|
421 |
category = Category.query.filter_by(id=it.category).one()
|
| 422 |
parent_category = Category.query.filter_by(id=category.parent_category_id).first()
|
422 |
parent_category = Category.query.filter_by(id=category.parent_category_id).first()
|
| - |
|
423 |
srm = SourceReturnPercentage.get_by(source=OrderSource.SNAPDEAL,brand=it.brand,category_id=it.category)
|
| 423 |
sip = SourceItemPercentage.query.filter(SourceItemPercentage.item_id==it.id).filter(SourceItemPercentage.source==OrderSource.SNAPDEAL).filter(SourceItemPercentage.startDate<=time).filter(SourceItemPercentage.expiryDate>=time).first()
|
424 |
sip = SourceItemPercentage.query.filter(SourceItemPercentage.item_id==it.id).filter(SourceItemPercentage.source==OrderSource.SNAPDEAL).filter(SourceItemPercentage.startDate<=time).filter(SourceItemPercentage.expiryDate>=time).first()
|
| 424 |
sourcePercentage = None
|
425 |
sourcePercentage = None
|
| 425 |
if sip is not None:
|
426 |
if sip is not None:
|
| - |
|
427 |
sip.returnProvision = srm.returnProvision
|
| 426 |
sourcePercentage = sip
|
428 |
sourcePercentage = sip
|
| 427 |
else:
|
429 |
else:
|
| 428 |
scp = SourceCategoryPercentage.query.filter(SourceCategoryPercentage.category_id==it.category).filter(SourceCategoryPercentage.source==OrderSource.SNAPDEAL).filter(SourceCategoryPercentage.startDate<=time).filter(SourceCategoryPercentage.expiryDate>=time).first()
|
430 |
scp = SourceCategoryPercentage.query.filter(SourceCategoryPercentage.category_id==it.category).filter(SourceCategoryPercentage.source==OrderSource.SNAPDEAL).filter(SourceCategoryPercentage.startDate<=time).filter(SourceCategoryPercentage.expiryDate>=time).first()
|
| 429 |
if scp is not None:
|
431 |
if scp is not None:
|
| - |
|
432 |
scp.returnProvision = srm.returnProvision
|
| 430 |
sourcePercentage = scp
|
433 |
sourcePercentage = scp
|
| 431 |
else:
|
434 |
else:
|
| 432 |
spm = SourcePercentageMaster.get_by(source=OrderSource.SNAPDEAL)
|
435 |
spm = SourcePercentageMaster.get_by(source=OrderSource.SNAPDEAL)
|
| - |
|
436 |
spm.returnProvision = srm.returnProvision
|
| 433 |
sourcePercentage = spm
|
437 |
sourcePercentage = spm
|
| 434 |
snapdealItemInfo = __SnapdealItemInfo(snapdeal_item.supc, snapdeal_item.maxNlc,snapdeal_item.courierCostMarketplace, it.id, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, snapdeal_item.warehouseId, None, runType, parent_category.display_name,sourcePercentage)
|
438 |
snapdealItemInfo = __SnapdealItemInfo(snapdeal_item.supc, snapdeal_item.maxNlc,snapdeal_item.courierCostMarketplace, it.id, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, snapdeal_item.warehouseId, None, runType, parent_category.display_name,sourcePercentage)
|
| 435 |
itemInfo.append(snapdealItemInfo)
|
439 |
itemInfo.append(snapdealItemInfo)
|
| 436 |
return itemInfo
|
440 |
return itemInfo
|
| 437 |
|
441 |
|
| Line 1829... |
Line 1833... |
| 1829 |
|
1833 |
|
| 1830 |
def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):
|
1834 |
def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):
|
| 1831 |
if snapdealDetails.rank==0:
|
1835 |
if snapdealDetails.rank==0:
|
| 1832 |
return mpItem.minimumPossibleTp
|
1836 |
return mpItem.minimumPossibleTp
|
| 1833 |
vat = (snapdealDetails.ourSp/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100);
|
1837 |
vat = (snapdealDetails.ourSp/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100);
|
| 1834 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*snapdealDetails.ourSp+mpItem.otherCost;
|
1838 |
inHouseCost = mpItem.packagingCost+vat+(mpItem.returnProvision/100)*snapdealDetails.ourSp+mpItem.otherCost;
|
| 1835 |
lowest_possible_tp = val.nlc+inHouseCost;
|
1839 |
lowest_possible_tp = val.nlc+inHouseCost;
|
| 1836 |
return round(lowest_possible_tp,2)
|
1840 |
return round(lowest_possible_tp,2)
|
| 1837 |
|
1841 |
|
| 1838 |
def getOurTp(snapdealDetails,val,spm,mpItem):
|
1842 |
def getOurTp(snapdealDetails,val,spm,mpItem):
|
| 1839 |
if snapdealDetails.rank==0:
|
1843 |
if snapdealDetails.rank==0:
|
| Line 1841... |
Line 1845... |
| 1841 |
ourTp = snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(spm.pgFee/100)*snapdealDetails.ourSp)*(1+(spm.serviceTax/100)));
|
1845 |
ourTp = snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(spm.pgFee/100)*snapdealDetails.ourSp)*(1+(spm.serviceTax/100)));
|
| 1842 |
return round(ourTp,2)
|
1846 |
return round(ourTp,2)
|
| 1843 |
|
1847 |
|
| 1844 |
def getNewLowestPossibleTp(mpItem,nlc,vatRate,proposedSellingPrice):
|
1848 |
def getNewLowestPossibleTp(mpItem,nlc,vatRate,proposedSellingPrice):
|
| 1845 |
vat = (proposedSellingPrice/(1+(vatRate/100))-(nlc/(1+(vatRate/100))))*(vatRate/100);
|
1849 |
vat = (proposedSellingPrice/(1+(vatRate/100))-(nlc/(1+(vatRate/100))))*(vatRate/100);
|
| 1846 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*proposedSellingPrice+mpItem.otherCost;
|
1850 |
inHouseCost = mpItem.packagingCost+vat+(mpItem.returnProvision/100)*proposedSellingPrice+mpItem.otherCost;
|
| 1847 |
lowest_possible_tp = nlc+inHouseCost;
|
1851 |
lowest_possible_tp = nlc+inHouseCost;
|
| 1848 |
return round(lowest_possible_tp,2)
|
1852 |
return round(lowest_possible_tp,2)
|
| 1849 |
|
1853 |
|
| 1850 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
1854 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
| 1851 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(mpItem.pgFee/100)*proposedSellingPrice)*(1+(mpItem.serviceTax/100)));
|
1855 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(mpItem.pgFee/100)*proposedSellingPrice)*(1+(mpItem.serviceTax/100)));
|
| 1852 |
return round(ourTp,2)
|
1856 |
return round(ourTp,2)
|
| 1853 |
|
1857 |
|
| 1854 |
def getNewLowestPossibleSp(mpItem,nlc,vatRate):
|
1858 |
def getNewLowestPossibleSp(mpItem,nlc,vatRate):
|
| 1855 |
if (mpItem.pgFee/100)*mpItem.currentSp>=20:
|
1859 |
if (mpItem.pgFee/100)*mpItem.currentSp>=20:
|
| 1856 |
lowestPossibleSp = (nlc+(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(15+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
1860 |
lowestPossibleSp = (nlc+(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(mpItem.packagingCost+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
| 1857 |
else:
|
1861 |
else:
|
| 1858 |
lowestPossibleSp = (nlc+(mpItem.courierCostMarketplace+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(15+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
1862 |
lowestPossibleSp = (nlc+(mpItem.courierCostMarketplace+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(mpItem.packagingCost+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
| 1859 |
return round(lowestPossibleSp,2)
|
1863 |
return round(lowestPossibleSp,2)
|
| 1860 |
|
1864 |
|
| 1861 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
1865 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
| 1862 |
if snapdealDetails.rank==0:
|
1866 |
if snapdealDetails.rank==0:
|
| 1863 |
return mpItem.minimumPossibleSp
|
1867 |
return mpItem.minimumPossibleSp
|
| 1864 |
#lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate/100))+(15+mpItem.otherCost)*(1+(val.vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate)/100)-(mpItem.returnProvision/100)*(1+(val.vatRate)/100));
|
1868 |
#lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate/100))+(15+mpItem.otherCost)*(1+(val.vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate)/100)-(mpItem.returnProvision/100)*(1+(val.vatRate)/100));
|
| 1865 |
if (mpItem.pgFee/100)*snapdealDetails.ourSp>=20:
|
1869 |
if (mpItem.pgFee/100)*snapdealDetails.ourSp>=20:
|
| 1866 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat/100))+(15+mpItem.otherCost)*(1+(mpItem.vat)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat)/100)-(mpItem.returnProvision/100)*(1+(mpItem.vat)/100))
|
1870 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat/100))+(mpItem.packagingCost+mpItem.otherCost)*(1+(mpItem.vat)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat)/100)-(mpItem.returnProvision/100)*(1+(mpItem.vat)/100))
|
| 1867 |
else:
|
1871 |
else:
|
| 1868 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat/100))+(15+mpItem.otherCost)*(1+(mpItem.vat)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat)/100)-(mpItem.returnProvision/100)*(1+(mpItem.vat)/100))
|
1872 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat/100))+(mpItem.packagingCost+mpItem.otherCost)*(1+(mpItem.vat)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat)/100)-(mpItem.returnProvision/100)*(1+(mpItem.vat)/100))
|
| 1869 |
return round(lowestPossibleSp,2)
|
1873 |
return round(lowestPossibleSp,2)
|
| 1870 |
|
1874 |
|
| 1871 |
def getTargetTp(targetSp,mpItem):
|
1875 |
def getTargetTp(targetSp,mpItem):
|
| 1872 |
targetTp = targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(mpItem.pgFee/100)*targetSp)*(1+(mpItem.serviceTax/100)))
|
1876 |
targetTp = targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(mpItem.pgFee/100)*targetSp)*(1+(mpItem.serviceTax/100)))
|
| 1873 |
return round(targetTp,2)
|
1877 |
return round(targetTp,2)
|