Subversion Repositories SmartDukaan

Rev

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

Rev 12467 Rev 12468
Line 615... Line 615...
615
        amazonScrapingHistory.promoPrice = amDetails.promoPrice
615
        amazonScrapingHistory.promoPrice = amDetails.promoPrice
616
        amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
616
        amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
617
        amazonScrapingHistory.ourRank = amDetails.ourRank
617
        amazonScrapingHistory.ourRank = amDetails.ourRank
618
        amazonScrapingHistory.ourInventory = val.ourInventory
618
        amazonScrapingHistory.ourInventory = val.ourInventory
619
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
619
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
-
 
620
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
-
 
621
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
-
 
622
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
620
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
623
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
-
 
624
        amazonScrapingHistory.secondLowestSellerShippingTime = amDetails.secondLowestSellerShippingTime
-
 
625
        amazonScrapingHistory.secondLowestSellerRating = amDetails.secondLowestSellerRating
-
 
626
        amazonScrapingHistory.secondLowestSellerType = amDetails.secondLowestSellerType
621
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
627
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
-
 
628
        amazonScrapingHistory.thirdLowestSellerShippingTime = amDetails.thirdLowestSellerShippingTime
-
 
629
        amazonScrapingHistory.thirdLowestSellerRating = amDetails.thirdLowestSellerRating
-
 
630
        amazonScrapingHistory.thirdLowestSellerType = amDetails.thirdLowestSellerType
622
        amazonScrapingHistory.wanlc = val.nlc
631
        amazonScrapingHistory.wanlc = val.nlc
623
        amazonScrapingHistory.otherCost = val.otherCost
632
        amazonScrapingHistory.otherCost = val.otherCost
624
        amazonScrapingHistory.commission = spm.commission
633
        amazonScrapingHistory.commission = spm.commission
625
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
634
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
626
        amazonScrapingHistory.returnProvision = spm.returnProvision
635
        amazonScrapingHistory.returnProvision = spm.returnProvision
Line 654... Line 663...
654
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
663
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
655
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
664
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
656
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
665
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
657
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
666
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
658
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
667
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
659
        amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
668
        amazonScrapingHistory.secondLowestSellerShippingTime = amDetails.secondLowestSellerShippingTime
660
        amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
669
        amazonScrapingHistory.secondLowestSellerRating = amDetails.secondLowestSellerRating
661
        amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
670
        amazonScrapingHistory.secondLowestSellerType = amDetails.secondLowestSellerType
662
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
671
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
663
        amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
672
        amazonScrapingHistory.thirdLowestSellerShippingTime = amDetails.thirdLowestSellerShippingTime
664
        amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
673
        amazonScrapingHistory.thirdLowestSellerRating = amDetails.thirdLowestSellerRating
665
        amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
674
        amazonScrapingHistory.thirdLowestSellerType = amDetails.thirdLowestSellerType
666
        amazonScrapingHistory.otherCost = val.otherCost
675
        amazonScrapingHistory.otherCost = val.otherCost
667
        amazonScrapingHistory.wanlc = val.nlc
676
        amazonScrapingHistory.wanlc = val.nlc
668
        amazonScrapingHistory.commission = spm.commission
677
        amazonScrapingHistory.commission = spm.commission
669
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
678
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
670
        amazonScrapingHistory.returnProvision = spm.returnProvision
679
        amazonScrapingHistory.returnProvision = spm.returnProvision
Line 679... Line 688...
679
        if amazonScrapingHistory.isPromotion:
688
        if amazonScrapingHistory.isPromotion:
680
            if amazonLongTermActivePromotions.has_key(val.sku):
689
            if amazonLongTermActivePromotions.has_key(val.sku):
681
                proposed_sp = min(proposed_sp,(amazonLongTermActivePromotions.get(val.sku)).salePrice)
690
                proposed_sp = min(proposed_sp,(amazonLongTermActivePromotions.get(val.sku)).salePrice)
682
            else:
691
            else:
683
                proposed_sp = min(proposed_sp,(amazonShortTermActivePromotions.get(val.sku)).salePrice)
692
                proposed_sp = min(proposed_sp,(amazonShortTermActivePromotions.get(val.sku)).salePrice)
684
        proposed_tp = getTargetTp(proposed_sp,spm,val)
693
        #proposed_tp = getTargetTp(proposed_sp,spm,val)
685
        amazonScrapingHistory.proposedSp = proposed_sp
694
        amazonScrapingHistory.proposedSp = proposed_sp
686
        amazonScrapingHistory.proposedTp = proposed_tp
695
        #amazonScrapingHistory.proposedTp = proposed_tp
687
        amazonScrapingHistory.marginIncreasedPotential = proposed_tp - amPricing.ourTp
696
        #amazonScrapingHistory.marginIncreasedPotential = proposed_tp - amPricing.ourTp
688
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
697
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
689
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
698
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
690
        amazonScrapingHistory.isPromotion = val.isPromo
699
        amazonScrapingHistory.isPromotion = val.isPromo
691
    session.commit()
700
    session.commit()
692
 
701
 
Line 710... Line 719...
710
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
719
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
711
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
720
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
712
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
721
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
713
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
722
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
714
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
723
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
715
        amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
724
        amazonScrapingHistory.secondLowestSellerShippingTime = amDetails.secondLowestSellerShippingTime
716
        amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
725
        amazonScrapingHistory.secondLowestSellerRating = amDetails.secondLowestSellerRating
717
        amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
726
        amazonScrapingHistory.secondLowestSellerType = amDetails.secondLowestSellerType
718
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
727
        amazonScrapingHistory.thirdLowestLowestSellerSp = amDetails.thirdLowestLowestSellerSp
719
        amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
728
        amazonScrapingHistory.thirdLowestSellerShippingTime = amDetails.thirdLowestSellerShippingTime
720
        amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
729
        amazonScrapingHistory.thirdLowestSellerRating = amDetails.thirdLowestSellerRating
721
        amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
730
        amazonScrapingHistory.thirdLowestSellerType = amDetails.thirdLowestSellerType
722
        amazonScrapingHistory.otherCost = val.otherCost
731
        amazonScrapingHistory.otherCost = val.otherCost
723
        amazonScrapingHistory.wanlc = val.nlc
732
        amazonScrapingHistory.wanlc = val.nlc
724
        amazonScrapingHistory.commission = spm.commission
733
        amazonScrapingHistory.commission = spm.commission
725
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
734
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
726
        amazonScrapingHistory.returnProvision = spm.returnProvision
735
        amazonScrapingHistory.returnProvision = spm.returnProvision
Line 730... Line 739...
730
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
739
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
731
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE
740
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE
732
        amazonScrapingHistory.timestamp = timestamp
741
        amazonScrapingHistory.timestamp = timestamp
733
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
742
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
734
        proposed_sp = max(amDetails.lowestSellerSp - max((5, amDetails.lowestSellerSp*0.001)), amPricing.lowestPossibleSp)
743
        proposed_sp = max(amDetails.lowestSellerSp - max((5, amDetails.lowestSellerSp*0.001)), amPricing.lowestPossibleSp)
735
        proposed_tp = getTargetTp(proposed_sp,spm,val)
744
        #proposed_tp = getTargetTp(proposed_sp,spm,val)
736
        amazonScrapingHistory.proposedSp = proposed_sp
745
        amazonScrapingHistory.proposedSp = proposed_sp
737
        amazonScrapingHistory.proposedTp = proposed_tp
746
        #amazonScrapingHistory.proposedTp = proposed_tp
738
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
747
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
739
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
748
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
740
        amazonScrapingHistory.isPromotion = val.isPromo
749
        amazonScrapingHistory.isPromotion = val.isPromo
741
    session.commit()
750
    session.commit()
742
 
751
 
Line 758... Line 767...
758
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
767
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
759
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
768
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
760
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
769
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
761
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
770
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
762
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
771
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
763
        amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
772
        amazonScrapingHistory.secondLowestSellerShippingTime = amDetails.secondLowestSellerShippingTime
764
        amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
773
        amazonScrapingHistory.secondLowestSellerRating = amDetails.secondLowestSellerRating
765
        amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
774
        amazonScrapingHistory.secondLowestSellerType = amDetails.secondLowestSellerType
766
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
775
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
767
        amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
776
        amazonScrapingHistory.thirdLowestSellerShippingTime = amDetails.thirdLowestSellerShippingTime
768
        amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
777
        amazonScrapingHistory.thirdLowestSellerRating = amDetails.thirdLowestSellerRating
769
        amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
778
        amazonScrapingHistory.thirdLowestSellerType = amDetails.thirdLowestSellerType
770
        amazonScrapingHistory.otherCost = val.otherCost
779
        amazonScrapingHistory.otherCost = val.otherCost
771
        amazonScrapingHistory.wanlc = val.nlc
780
        amazonScrapingHistory.wanlc = val.nlc
772
        amazonScrapingHistory.commission = spm.commission
781
        amazonScrapingHistory.commission = spm.commission
773
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
782
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
774
        amazonScrapingHistory.returnProvision = spm.returnProvision
783
        amazonScrapingHistory.returnProvision = spm.returnProvision
Line 778... Line 787...
778
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
787
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
779
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.COMPETITIVE
788
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.COMPETITIVE
780
        amazonScrapingHistory.timestamp = timestamp
789
        amazonScrapingHistory.timestamp = timestamp
781
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
790
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
782
        proposed_sp = max(amDetails.lowestSellerSp - max((5, amDetails.lowestSellerSp*0.001)), amPricing.lowestPossibleSp)
791
        proposed_sp = max(amDetails.lowestSellerSp - max((5, amDetails.lowestSellerSp*0.001)), amPricing.lowestPossibleSp)
783
        proposed_tp = getTargetTp(proposed_sp,spm,val)
792
        #proposed_tp = getTargetTp(proposed_sp,spm,val)
784
        amazonScrapingHistory.proposedSp = proposed_sp
793
        amazonScrapingHistory.proposedSp = proposed_sp
785
        amazonScrapingHistory.proposedTp = proposed_tp
794
        #amazonScrapingHistory.proposedTp = proposed_tp
786
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
795
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
787
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
796
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
788
        amazonScrapingHistory.isPromotion = val.isPromo
797
        amazonScrapingHistory.isPromotion = val.isPromo
789
    session.commit()
798
    session.commit()
790
 
799
 
Line 806... Line 815...
806
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
815
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
807
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
816
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
808
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
817
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
809
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
818
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
810
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
819
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
811
        amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
820
        amazonScrapingHistory.secondLowestSellerShippingTime = amDetails.secondLowestSellerShippingTime
812
        amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
821
        amazonScrapingHistory.secondLowestSellerRating = amDetails.secondLowestSellerRating
813
        amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
822
        amazonScrapingHistory.secondLowestSellerType = amDetails.secondLowestSellerType
814
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
823
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
815
        amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
824
        amazonScrapingHistory.thirdLowestSellerShippingTime = amDetails.thirdLowestSellerShippingTime
816
        amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
825
        amazonScrapingHistory.thirdLowestSellerRating = amDetails.thirdLowestSellerRating
817
        amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
826
        amazonScrapingHistory.thirdLowestSellerType = amDetails.thirdLowestSellerType
818
        amazonScrapingHistory.otherCost = val.otherCost
827
        amazonScrapingHistory.otherCost = val.otherCost
819
        amazonScrapingHistory.wanlc = val.nlc
828
        amazonScrapingHistory.wanlc = val.nlc
820
        amazonScrapingHistory.commission = spm.commission
829
        amazonScrapingHistory.commission = spm.commission
821
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
830
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
822
        amazonScrapingHistory.returnProvision = spm.returnProvision
831
        amazonScrapingHistory.returnProvision = spm.returnProvision
Line 826... Line 835...
826
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
835
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
827
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.ALMOST_COMPETE
836
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.ALMOST_COMPETE
828
        amazonScrapingHistory.timestamp = timestamp
837
        amazonScrapingHistory.timestamp = timestamp
829
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
838
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
830
        proposed_sp = min(amDetails.lowestSellerSp*(1+.01),amPricing.lowestPossibleSp)
839
        proposed_sp = min(amDetails.lowestSellerSp*(1+.01),amPricing.lowestPossibleSp)
831
        proposed_tp = getTargetTp(proposed_sp,spm,val)
840
        #proposed_tp = getTargetTp(proposed_sp,spm,val)
832
        target_nlc = proposed_tp - amPricing.lowestPossibleTp + val.nlc
841
        #target_nlc = proposed_tp - amPricing.lowestPossibleTp + val.nlc
833
        amazonScrapingHistory.proposedSp = proposed_sp
842
        amazonScrapingHistory.proposedSp = proposed_sp
834
        amazonScrapingHistory.proposedTp = proposed_tp
843
        #amazonScrapingHistory.proposedTp = proposed_tp
835
        amazonScrapingHistory.targetNlc = target_nlc
844
        #amazonScrapingHistory.targetNlc = target_nlc
836
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
845
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
837
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
846
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
838
        amazonScrapingHistory.isPromotion = val.isPromo
847
        amazonScrapingHistory.isPromotion = val.isPromo
839
    session.commit()
848
    session.commit()
840
 
849
 
Line 857... Line 866...
857
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
866
        amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
858
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
867
        amazonScrapingHistory.lowestSellerShippingTime = amDetails.lowestSellerShippingTime
859
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
868
        amazonScrapingHistory.lowestSellerRating = amDetails.lowestSellerRating
860
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
869
        amazonScrapingHistory.lowestSellerType = amDetails.lowestSellerType
861
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
870
        amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
862
        amazonScrapingHistory.secondSellerShippingTime = amDetails.secondSellerShippingTime
871
        amazonScrapingHistory.secondLowestSellerShippingTime = amDetails.secondLowestSellerShippingTime
863
        amazonScrapingHistory.secondSellerRating = amDetails.secondSellerRating
872
        amazonScrapingHistory.secondLowestSellerRating = amDetails.secondLowestSellerRating
864
        amazonScrapingHistory.secondSellerType = amDetails.secondSellerType
873
        amazonScrapingHistory.secondLowestSellerType = amDetails.secondLowestSellerType
865
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
874
        amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
866
        amazonScrapingHistory.thirdSellerShippingTime = amDetails.thirdSellerShippingTime
875
        amazonScrapingHistory.thirdLowestSellerShippingTime = amDetails.thirdLowestSellerShippingTime
867
        amazonScrapingHistory.thirdSellerRating = amDetails.thirdSellerRating
876
        amazonScrapingHistory.thirdLowestSellerRating = amDetails.thirdLowestSellerRating
868
        amazonScrapingHistory.thirdSellerType = amDetails.thirdSellerType
877
        amazonScrapingHistory.thirdLowestSellerType = amDetails.thirdLowestSellerType
869
        amazonScrapingHistory.otherCost = val.otherCost
878
        amazonScrapingHistory.otherCost = val.otherCost
870
        amazonScrapingHistory.wanlc = val.nlc
879
        amazonScrapingHistory.wanlc = val.nlc
871
        amazonScrapingHistory.commission = spm.commission
880
        amazonScrapingHistory.commission = spm.commission
872
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
881
        amazonScrapingHistory.competitorCommission = spm.competitorCommissionOther
873
        amazonScrapingHistory.returnProvision = spm.returnProvision
882
        amazonScrapingHistory.returnProvision = spm.returnProvision
Line 877... Line 886...
877
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
886
        amazonScrapingHistory.totalSeller = amDetails.totalSeller
878
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.CANT_COMPETE
887
        amazonScrapingHistory.competitiveCategory = CompetitionCategory.CANT_COMPETE
879
        amazonScrapingHistory.timestamp = timestamp
888
        amazonScrapingHistory.timestamp = timestamp
880
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
889
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
881
        proposed_sp = amDetails.lowestSellerSp - max(5, amDetails.lowestSellerSp*0.001)
890
        proposed_sp = amDetails.lowestSellerSp - max(5, amDetails.lowestSellerSp*0.001)
882
        proposed_tp = getTargetTp(proposed_sp,spm,val)
891
        #proposed_tp = getTargetTp(proposed_sp,spm,val)
883
        target_nlc = proposed_tp - amPricing.lowestPossibleTp + val.nlc
892
        #target_nlc = proposed_tp - amPricing.lowestPossibleTp + val.nlc
884
        amazonScrapingHistory.proposedSp = proposed_sp
893
        amazonScrapingHistory.proposedSp = proposed_sp
885
        amazonScrapingHistory.proposedTp = proposed_tp
894
        #amazonScrapingHistory.proposedTp = proposed_tp
886
        amazonScrapingHistory.targetNlc = target_nlc
895
        #amazonScrapingHistory.targetNlc = target_nlc
887
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
896
        amazonScrapingHistory.multipleListings = amDetails.multipleListings
888
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
897
        amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
889
        amazonScrapingHistory.isPromotion = val.isPromo
898
        amazonScrapingHistory.isPromotion = val.isPromo
890
    session.commit()
899
    session.commit()
891
 
900
 
Line 976... Line 985...
976
    sheet.write(0, 26, "Competitor Commission", heading_xf)
985
    sheet.write(0, 26, "Competitor Commission", heading_xf)
977
    sheet.write(0, 27, "Return Provision", heading_xf)
986
    sheet.write(0, 27, "Return Provision", heading_xf)
978
    sheet.write(0, 28, "Margin", heading_xf)
987
    sheet.write(0, 28, "Margin", heading_xf)
979
    sheet.write(0, 29, "Risky", heading_xf)
988
    sheet.write(0, 29, "Risky", heading_xf)
980
    sheet.write(0, 30, "Proposed Sp", heading_xf)
989
    sheet.write(0, 30, "Proposed Sp", heading_xf)
981
    sheet.write(0, 31, "Proposed Tp", heading_xf)
-
 
982
    sheet.write(0, 32, "Target Nlc", heading_xf)
-
 
983
    sheet.write(0, 33, "Avg Sale", heading_xf)
990
    sheet.write(0, 31, "Avg Sale", heading_xf)
984
    sheet.write(0, 34, "Sales History", heading_xf)
991
    sheet.write(0, 32, "Sales History", heading_xf)
985
    sheet.write(0, 35, "Decision", heading_xf)
992
    sheet.write(0, 33, "Decision", heading_xf)
986
    sheet.write(0, 36, "Reason", heading_xf)
993
    sheet.write(0, 34, "Reason", heading_xf)
987
    sheet.write(0, 37, "Updated Price", heading_xf)
994
    sheet.write(0, 35, "Updated Price", heading_xf)
988
    
995
    
989
    sheet_iterator = 1
996
    sheet_iterator = 1
990
    cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
997
    cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
991
    for cantCompeteItem in cantCompeteItems:
998
    for cantCompeteItem in cantCompeteItems:
992
        amScraping =  cantCompeteItem[0]
999
        amScraping =  cantCompeteItem[0]
Line 1032... Line 1039...
1032
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1039
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1033
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1040
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1034
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1041
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1035
        sheet.write(sheet_iterator, 29, item.risky)
1042
        sheet.write(sheet_iterator, 29, item.risky)
1036
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1043
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1037
        sheet.write(sheet_iterator, 31, amScraping.proposedTp)
-
 
1038
        sheet.write(sheet_iterator, 32, amScraping.targetNlc)
-
 
1039
        sheet.write(sheet_iterator, 33, amScraping.avgSale)
1044
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1040
        sheet.write(sheet_iterator, 34, getOosString(saleMap.get(sku)))
1045
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1041
        if amScraping.decision is None:
1046
        if amScraping.decision is None:
1042
            sheet.write(sheet_iterator, 35, 'Auto Pricing Inactive')
1047
            sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
1043
            sheet_iterator+=1
1048
            sheet_iterator+=1
1044
            continue
1049
            continue
1045
        sheet.write(sheet_iterator, 35, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1050
        sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1046
        sheet.write(sheet_iterator, 36, amScraping.reason)
1051
        sheet.write(sheet_iterator, 34, amScraping.reason)
1047
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1052
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1048
            sheet.write(sheet_iterator, 37, math.ceil(amScraping.proposedSellingPrice))
1053
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
1049
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1054
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1050
            sheet.write(sheet_iterator, 37, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1055
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1051
        sheet_iterator+=1
1056
        sheet_iterator+=1
1052
    
1057
    
1053
    sheet = wbk.add_sheet('Competitive')
1058
    sheet = wbk.add_sheet('Competitive')
1054
    xstr = lambda s: s or ""
1059
    xstr = lambda s: s or ""
1055
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
1060
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 1087... Line 1092...
1087
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1092
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1088
    sheet.write(0, 27, "Return Provision", heading_xf)
1093
    sheet.write(0, 27, "Return Provision", heading_xf)
1089
    sheet.write(0, 28, "Margin", heading_xf)
1094
    sheet.write(0, 28, "Margin", heading_xf)
1090
    sheet.write(0, 29, "Risky", heading_xf)
1095
    sheet.write(0, 29, "Risky", heading_xf)
1091
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1096
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1092
    sheet.write(0, 31, "Proposed Tp", heading_xf)
-
 
1093
    sheet.write(0, 32, "Avg Sale", heading_xf)
1097
    sheet.write(0, 31, "Avg Sale", heading_xf)
1094
    sheet.write(0, 33, "Sales History", heading_xf)
1098
    sheet.write(0, 32, "Sales History", heading_xf)
1095
    sheet.write(0, 34, "Decision", heading_xf)
1099
    sheet.write(0, 33, "Decision", heading_xf)
1096
    sheet.write(0, 35, "Reason", heading_xf)
1100
    sheet.write(0, 34, "Reason", heading_xf)
1097
    sheet.write(0, 36, "Updated Price", heading_xf)
1101
    sheet.write(0, 35, "Updated Price", heading_xf)
1098
    
1102
    
1099
    sheet_iterator = 1
1103
    sheet_iterator = 1
1100
    competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).all()
1104
    competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).all()
1101
    for competitiveItem in competitiveItems:
1105
    for competitiveItem in competitiveItems:
1102
        amScraping =  competitiveItem[0]
1106
        amScraping =  competitiveItem[0]
Line 1142... Line 1146...
1142
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1146
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1143
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1147
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1144
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1148
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1145
        sheet.write(sheet_iterator, 29, item.risky)
1149
        sheet.write(sheet_iterator, 29, item.risky)
1146
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1150
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1147
        sheet.write(sheet_iterator, 31, amScraping.proposedTp)
-
 
1148
        sheet.write(sheet_iterator, 32, amScraping.avgSale)
1151
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1149
        sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
1152
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1150
        if amScraping.decision is None:
1153
        if amScraping.decision is None:
1151
            sheet.write(sheet_iterator, 34, 'Auto Pricing Inactive')
1154
            sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
1152
            sheet_iterator+=1
1155
            sheet_iterator+=1
1153
            continue
1156
            continue
1154
        sheet.write(sheet_iterator, 34, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1157
        sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1155
        sheet.write(sheet_iterator, 35, amScraping.reason)
1158
        sheet.write(sheet_iterator, 34, amScraping.reason)
1156
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1159
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1157
            sheet.write(sheet_iterator, 36, math.ceil(amScraping.proposedSellingPrice))
1160
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
1158
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1161
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1159
            sheet.write(sheet_iterator, 36, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1162
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1160
        sheet_iterator+=1
1163
        sheet_iterator+=1
1161
    
1164
    
1162
    sheet = wbk.add_sheet('Almost Competitive')
1165
    sheet = wbk.add_sheet('Almost Competitive')
1163
    xstr = lambda s: s or ""
1166
    xstr = lambda s: s or ""
1164
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
1167
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 1196... Line 1199...
1196
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1199
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1197
    sheet.write(0, 27, "Return Provision", heading_xf)
1200
    sheet.write(0, 27, "Return Provision", heading_xf)
1198
    sheet.write(0, 28, "Margin", heading_xf)
1201
    sheet.write(0, 28, "Margin", heading_xf)
1199
    sheet.write(0, 29, "Risky", heading_xf)
1202
    sheet.write(0, 29, "Risky", heading_xf)
1200
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1203
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1201
    sheet.write(0, 31, "Proposed Tp", heading_xf)
-
 
1202
    sheet.write(0, 32, "Avg Sale", heading_xf)
1204
    sheet.write(0, 31, "Avg Sale", heading_xf)
1203
    sheet.write(0, 33, "Sales History", heading_xf)
1205
    sheet.write(0, 32, "Sales History", heading_xf)
1204
    sheet.write(0, 34, "Decision", heading_xf)
1206
    sheet.write(0, 33, "Decision", heading_xf)
1205
    sheet.write(0, 35, "Reason", heading_xf)
1207
    sheet.write(0, 34, "Reason", heading_xf)
1206
    sheet.write(0, 36, "Updated Price", heading_xf)
1208
    sheet.write(0, 35, "Updated Price", heading_xf)
1207
    
1209
    
1208
    sheet_iterator = 1
1210
    sheet_iterator = 1
1209
    almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).all()
1211
    almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).all()
1210
    for almostCompetitiveItem in almostCompetitiveItems:
1212
    for almostCompetitiveItem in almostCompetitiveItems:
1211
        amScraping =  almostCompetitiveItem[0]
1213
        amScraping =  almostCompetitiveItem[0]
Line 1260... Line 1262...
1260
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1262
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1261
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1263
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1262
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1264
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1263
        sheet.write(sheet_iterator, 29, item.risky)
1265
        sheet.write(sheet_iterator, 29, item.risky)
1264
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1266
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1265
        sheet.write(sheet_iterator, 31, amScraping.proposedTp)
-
 
1266
        sheet.write(sheet_iterator, 32, amScraping.avgSale)
1267
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1267
        sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
1268
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1268
        if amScraping.decision is None:
1269
        if amScraping.decision is None:
1269
            sheet.write(sheet_iterator, 34, 'Auto Pricing Inactive')
1270
            sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
1270
            sheet_iterator+=1
1271
            sheet_iterator+=1
1271
            continue
1272
            continue
1272
        sheet.write(sheet_iterator, 34, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1273
        sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1273
        sheet.write(sheet_iterator, 35, amScraping.reason)
1274
        sheet.write(sheet_iterator, 34, amScraping.reason)
1274
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1275
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1275
            sheet.write(sheet_iterator, 36, math.ceil(amScraping.proposedSellingPrice))
1276
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
1276
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1277
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1277
            sheet.write(sheet_iterator, 36, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1278
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1278
        sheet_iterator+=1
1279
        sheet_iterator+=1
1279
    
1280
    
1280
    sheet = wbk.add_sheet('Among Cheapest')
1281
    sheet = wbk.add_sheet('Among Cheapest')
1281
    xstr = lambda s: s or ""
1282
    xstr = lambda s: s or ""
1282
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
1283
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 1314... Line 1315...
1314
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1315
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1315
    sheet.write(0, 27, "Return Provision", heading_xf)
1316
    sheet.write(0, 27, "Return Provision", heading_xf)
1316
    sheet.write(0, 28, "Margin", heading_xf)
1317
    sheet.write(0, 28, "Margin", heading_xf)
1317
    sheet.write(0, 29, "Risky", heading_xf)
1318
    sheet.write(0, 29, "Risky", heading_xf)
1318
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1319
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1319
    sheet.write(0, 31, "Proposed Tp", heading_xf)
-
 
1320
    sheet.write(0, 32, "Avg Sale", heading_xf)
1320
    sheet.write(0, 31, "Avg Sale", heading_xf)
1321
    sheet.write(0, 33, "Sales History", heading_xf)
1321
    sheet.write(0, 32, "Sales History", heading_xf)
1322
    sheet.write(0, 34, "Decision", heading_xf)
1322
    sheet.write(0, 33, "Decision", heading_xf)
1323
    sheet.write(0, 35, "Reason", heading_xf)
1323
    sheet.write(0, 34, "Reason", heading_xf)
1324
    sheet.write(0, 36, "Updated Price", heading_xf)
1324
    sheet.write(0, 35, "Updated Price", heading_xf)
1325
    
1325
    
1326
    sheet_iterator = 1
1326
    sheet_iterator = 1
1327
    amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
1327
    amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
1328
    for amongCheapestItem in amongCheapestItems:
1328
    for amongCheapestItem in amongCheapestItems:
1329
        amScraping =  amongCheapestItem[0]
1329
        amScraping =  amongCheapestItem[0]
Line 1369... Line 1369...
1369
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1369
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1370
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1370
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1371
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1371
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1372
        sheet.write(sheet_iterator, 29, item.risky)
1372
        sheet.write(sheet_iterator, 29, item.risky)
1373
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1373
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1374
        sheet.write(sheet_iterator, 31, amScraping.proposedTp)
-
 
1375
        sheet.write(sheet_iterator, 32, amScraping.avgSale)
1374
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1376
        sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
1375
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1377
        if amScraping.decision is None:
1376
        if amScraping.decision is None:
1378
            sheet.write(sheet_iterator, 34, 'Auto Pricing Inactive')
1377
            sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
1379
            sheet_iterator+=1
1378
            sheet_iterator+=1
1380
            continue
1379
            continue
1381
        sheet.write(sheet_iterator, 34, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1380
        sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1382
        sheet.write(sheet_iterator, 35, amScraping.reason)
1381
        sheet.write(sheet_iterator, 34, amScraping.reason)
1383
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1382
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1384
            sheet.write(sheet_iterator, 36, math.ceil(amScraping.proposedSellingPrice))
1383
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
1385
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1384
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1386
            sheet.write(sheet_iterator, 36, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1385
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1387
        sheet_iterator+=1
1386
        sheet_iterator+=1
1388
    
1387
    
1389
    sheet = wbk.add_sheet('Cheapest')
1388
    sheet = wbk.add_sheet('Cheapest')
1390
    xstr = lambda s: s or ""
1389
    xstr = lambda s: s or ""
1391
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
1390
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 1423... Line 1422...
1423
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1422
    sheet.write(0, 26, "Competitor Commission", heading_xf)
1424
    sheet.write(0, 27, "Return Provision", heading_xf)
1423
    sheet.write(0, 27, "Return Provision", heading_xf)
1425
    sheet.write(0, 28, "Margin", heading_xf)
1424
    sheet.write(0, 28, "Margin", heading_xf)
1426
    sheet.write(0, 29, "Risky", heading_xf)
1425
    sheet.write(0, 29, "Risky", heading_xf)
1427
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1426
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1428
    sheet.write(0, 31, "Proposed Tp", heading_xf)
-
 
1429
    sheet.write(0, 32, "Margin Increased Potential", heading_xf)
-
 
1430
    sheet.write(0, 33, "Avg Sale", heading_xf)
1427
    sheet.write(0, 31, "Avg Sale", heading_xf)
1431
    sheet.write(0, 34, "Sales History", heading_xf)
1428
    sheet.write(0, 32, "Sales History", heading_xf)
1432
    sheet.write(0, 35, "Decision", heading_xf)
1429
    sheet.write(0, 33, "Decision", heading_xf)
1433
    sheet.write(0, 36, "Reason", heading_xf)
1430
    sheet.write(0, 34, "Reason", heading_xf)
1434
    sheet.write(0, 37, "Updated Price", heading_xf)
1431
    sheet.write(0, 35, "Updated Price", heading_xf)
1435
    
1432
    
1436
    sheet_iterator = 1
1433
    sheet_iterator = 1
1437
    cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
1434
    cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
1438
    for cheapestItem in cheapestItems:
1435
    for cheapestItem in cheapestItems:
1439
        amScraping =  cheapestItem[0]
1436
        amScraping =  cheapestItem[0]
Line 1479... Line 1476...
1479
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1476
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1480
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1477
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1481
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1478
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1482
        sheet.write(sheet_iterator, 29, item.risky)
1479
        sheet.write(sheet_iterator, 29, item.risky)
1483
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1480
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1484
        sheet.write(sheet_iterator, 31, amScraping.proposedTp)
-
 
1485
        sheet.write(sheet_iterator, 32, amScraping.targetNlc)
-
 
1486
        sheet.write(sheet_iterator, 33, amScraping.avgSale)
1481
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1487
        sheet.write(sheet_iterator, 34, getOosString(saleMap.get(sku)))
1482
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1488
        if amScraping.decision is None:
1483
        if amScraping.decision is None:
1489
            sheet.write(sheet_iterator, 35, 'Auto Pricing Inactive')
1484
            sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
1490
            sheet_iterator+=1
1485
            sheet_iterator+=1
1491
            continue
1486
            continue
1492
        sheet.write(sheet_iterator, 35, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1487
        sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
1493
        sheet.write(sheet_iterator, 36, amScraping.reason)
1488
        sheet.write(sheet_iterator, 34, amScraping.reason)
1494
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1489
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
1495
            sheet.write(sheet_iterator, 37, math.ceil(amScraping.proposedSellingPrice))
1490
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
1496
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1491
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
1497
            sheet.write(sheet_iterator, 37, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1492
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
1498
        sheet_iterator+=1
1493
        sheet_iterator+=1
1499
    
1494
    
1500
    sheet = wbk.add_sheet('Negative Margin')
1495
    sheet = wbk.add_sheet('Negative Margin')
1501
    xstr = lambda s: s or ""
1496
    xstr = lambda s: s or ""
1502
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
1497
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 1580... Line 1575...
1580
        sheet.write(sheet_iterator, 23, amScraping.otherCost)
1575
        sheet.write(sheet_iterator, 23, amScraping.otherCost)
1581
        sheet.write(sheet_iterator, 24, amScraping.wanlc)
1576
        sheet.write(sheet_iterator, 24, amScraping.wanlc)
1582
        sheet.write(sheet_iterator, 25, amScraping.commission)
1577
        sheet.write(sheet_iterator, 25, amScraping.commission)
1583
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1578
        sheet.write(sheet_iterator, 26, amScraping.competitorCommission)
1584
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1579
        sheet.write(sheet_iterator, 27, amScraping.returnProvision)
1585
        sheet.write(sheet_iterator, 28, round(amScraping.ourTp - amScraping.lowestPossibleTp))
1580
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1586
        sheet.write(sheet_iterator, 29, amScraping.avgSale)
1581
        sheet.write(sheet_iterator, 29, amScraping.avgSale)
1587
        sheet.write(sheet_iterator, 30, getOosString(saleMap.get(sku)))
1582
        sheet.write(sheet_iterator, 30, getOosString(saleMap.get(sku)))
1588
        sheet_iterator+=1
1583
        sheet_iterator+=1
1589
    
1584
    
1590
    sheet = wbk.add_sheet('Exception List')
1585
    sheet = wbk.add_sheet('Exception List')